Return errors from schema generation instead of panicking
jsonSchemaFor panicked on unsupported types, which meant FunctionTool, NewOutputType, and RunTyped would crash the process during setup rather than returning a normal error. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -36,11 +36,16 @@ func RunTyped[T any](
|
||||
) (*TypedResult[T], error) {
|
||||
typed := a.clone()
|
||||
|
||||
schema, err := jsonSchemaFor[T]()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create typed runner: %w", err)
|
||||
}
|
||||
|
||||
typed.responseFormat = &llm.ResponseFormat{
|
||||
Type: llm.ResponseFormatJSONSchema,
|
||||
JSONSchema: &llm.JSONSchema{
|
||||
Name: typeName[T](),
|
||||
Schema: jsonSchemaFor[T](),
|
||||
Schema: schema,
|
||||
Strict: true,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user