Add 'duration' to simulator request logs (#732)

even when cache is disabled
This commit is contained in:
Rob Lourens
2025-08-23 11:55:58 -07:00
committed by GitHub
parent 22af4e2e7a
commit 3177ea45f9
2 changed files with 6 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ import { IInstantiationService } from '../../src/util/vs/platform/instantiation/
import { InterceptedRequest, ISerialisedChatResponse } from '../simulation/shared/sharedTypes';
import { CacheInfo, TestRunCacheInfo } from '../testExecutor';
import { ResponseWithMeta } from './cachingChatMLFetcher';
import { StopWatch } from '../../src/util/vs/base/common/stopwatch';
export class FetchRequestCollector {
public readonly _interceptedRequests: InterceptedRequest[] = [];
@@ -125,6 +126,7 @@ export class SpyingChatMLFetcher extends AbstractChatMLFetcher {
const respPromise = this.fetcher.fetchMany({ ...opts, finishedCb: captureToolCallsCb }, token);
const sw = new StopWatch(false);
this.requestCollector.addInterceptedRequest(respPromise.then(resp => {
let cacheKey: string | undefined;
if (typeof (resp as ResponseWithMeta).cacheKey === 'string') {
@@ -139,7 +141,7 @@ export class SpyingChatMLFetcher extends AbstractChatMLFetcher {
tool_calls: message.role === Raw.ChatRole.Assistant ? message.toolCalls : undefined,
name: message.name,
};
}), opts.requestOptions, resp, cacheKey, opts.endpoint.model);
}), opts.requestOptions, resp, cacheKey, opts.endpoint.model, sw.elapsed());
}));
return await respPromise;

View File

@@ -116,12 +116,13 @@ export class InterceptedRequest {
public readonly response: ISerialisedChatResponse,
public readonly cacheKey: string | undefined,
public readonly model: string | undefined,
public readonly duration?: number
) {
// console.log('InterceptedRequest', requestMessages, requestOptions, response, cacheKey, model);
}
static fromJSON(json: any): InterceptedRequest {
const request = new InterceptedRequest(json.requestMessages, json.requestOptions, json.response, json.cacheKey, json.model);
const request = new InterceptedRequest(json.requestMessages, json.requestOptions, json.response, json.cacheKey, json.model, json.duration);
return request;
}
@@ -132,6 +133,7 @@ export class InterceptedRequest {
response: this.response,
cacheKey: this.cacheKey,
model: this.model,
duration: this.duration
};
}
}