(apiType: PythonApiType, parsedResult: any)
| 54 | } |
| 55 | |
| 56 | function 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 | |
| 80 | function applyFreshCallApiMetadata(apiType: PythonApiType, result: any) { |
| 81 | if (apiType !== 'call_api' || typeof result !== 'object' || result === null) { |
no outgoing calls
no test coverage detected
searching dependent graphs…