MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / applyCachedCallApiMetadata

Function applyCachedCallApiMetadata

src/providers/pythonCompletion.ts:56–78  ·  view source on GitHub ↗
(apiType: PythonApiType, parsedResult: any)

Source from the content-addressed store, hash-verified

54}
55
56function applyCachedCallApiMetadata(apiType: PythonApiType, parsedResult: any) {
57 if (apiType !== 'call_api' || typeof parsedResult !== 'object' || parsedResult === null) {
58 return parsedResult;
59 }
60
61 logger.debug(`PythonProvider setting cached=true for cached ${apiType} result`);
62 parsedResult.cached = true;
63
64 // Update token usage format for cached results
65 if (parsedResult.tokenUsage) {
66 const total = parsedResult.tokenUsage.total || 0;
67 parsedResult.tokenUsage = {
68 cached: total,
69 total,
70 numRequests: parsedResult.tokenUsage.numRequests ?? 1,
71 };
72 logger.debug(
73 `Updated token usage for cached result: ${JSON.stringify(parsedResult.tokenUsage)}`,
74 );
75 }
76
77 return parsedResult;
78}
79
80function applyFreshCallApiMetadata(apiType: PythonApiType, result: any) {
81 if (apiType !== 'call_api' || typeof result !== 'object' || result === null) {

Callers 1

executePythonScriptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…