chore: improve error logging
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* OpenAI Client implementation
|
* OpenAI Client implementation
|
||||||
*/
|
*/
|
||||||
|
import * as z from 'zod'
|
||||||
|
|
||||||
import { InvokeError, InvokeErrorType } from './errors'
|
import { InvokeError, InvokeErrorType } from './errors'
|
||||||
import type { InvokeOptions, InvokeResult, LLMClient, LLMConfig, Message, Tool } from './types'
|
import type { InvokeOptions, InvokeResult, LLMClient, LLMConfig, Message, Tool } from './types'
|
||||||
import { modelPatch, zodToOpenAITool } from './utils'
|
import { modelPatch, zodToOpenAITool } from './utils'
|
||||||
@@ -182,7 +184,7 @@ export class OpenAIClient implements LLMClient {
|
|||||||
// Validate with schema
|
// Validate with schema
|
||||||
const validation = tool.inputSchema.safeParse(parsedArgs)
|
const validation = tool.inputSchema.safeParse(parsedArgs)
|
||||||
if (!validation.success) {
|
if (!validation.success) {
|
||||||
console.error(validation.error)
|
console.error(z.prettifyError(validation.error))
|
||||||
throw new InvokeError(
|
throw new InvokeError(
|
||||||
InvokeErrorType.INVALID_TOOL_ARGS,
|
InvokeErrorType.INVALID_TOOL_ARGS,
|
||||||
'Tool arguments validation failed',
|
'Tool arguments validation failed',
|
||||||
|
|||||||
Reference in New Issue
Block a user