feat(core): add rawRequest in history for debug
This commit is contained in:
@@ -39,6 +39,8 @@ export class OpenAIClient implements LLMClient {
|
||||
: 'required',
|
||||
}
|
||||
|
||||
modelPatch(requestBody)
|
||||
|
||||
// 2. Call API
|
||||
let response: Response
|
||||
try {
|
||||
@@ -48,7 +50,7 @@ export class OpenAIClient implements LLMClient {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${this.config.apiKey}`,
|
||||
},
|
||||
body: JSON.stringify(modelPatch(requestBody)),
|
||||
body: JSON.stringify(requestBody),
|
||||
signal: abortSignal,
|
||||
})
|
||||
} catch (error: unknown) {
|
||||
@@ -216,6 +218,7 @@ export class OpenAIClient implements LLMClient {
|
||||
reasoningTokens: data.usage?.completion_tokens_details?.reasoning_tokens,
|
||||
},
|
||||
rawResponse: data,
|
||||
rawRequest: requestBody,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ export interface InvokeResult<TResult = unknown> {
|
||||
reasoningTokens?: number // OpenAI o1 series reasoning tokens
|
||||
}
|
||||
rawResponse?: unknown // Raw response for debugging
|
||||
rawRequest?: unknown // Raw request for debugging
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ export function zodToOpenAITool(name: string, tool: Tool) {
|
||||
|
||||
/**
|
||||
* Patch model specific parameters
|
||||
* @note in-place modification
|
||||
*/
|
||||
export function modelPatch(body: Record<string, any>) {
|
||||
const model: string = body.model || ''
|
||||
|
||||
Reference in New Issue
Block a user