File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const anthropicThinkingWithStructuredResponseMiddleware: LanguageModelV2M
2020 } ,
2121 ] ;
2222 params . toolChoice = { type : 'auto' } ;
23-
23+ params . responseFormat = { type : 'text' } ;
2424 params . prompt . push ( {
2525 role : 'user' ,
2626 content : [
@@ -33,4 +33,16 @@ export const anthropicThinkingWithStructuredResponseMiddleware: LanguageModelV2M
3333 }
3434 return Promise . resolve ( params ) ;
3535 } ,
36+ wrapGenerate : async ( { doGenerate} ) => {
37+ const result = await doGenerate ( ) ;
38+
39+ // Extract the JSON tool call (conforming to the schema) and return it as text response.
40+ for ( const r of result . content ) {
41+ if ( r . type === 'tool-call' && r . toolName === 'json' ) {
42+ result . content . push ( { type : 'text' , text : r . input } ) ;
43+ }
44+ }
45+
46+ return result ;
47+ } ,
3648} ;
You can’t perform that action at this time.
0 commit comments