File tree Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -430,21 +430,28 @@ function toOllamaRequest(
430430 toolResponses . push ( c . toolResponse ) ;
431431 }
432432 } ) ;
433- // Add tool responses, if any.
434- toolResponses . forEach ( ( t ) => {
433+ if ( toolResponses . length > 0 ) {
434+ toolResponses . forEach ( ( t ) => {
435+ messages . push ( {
436+ role,
437+ content :
438+ typeof t . output === 'string'
439+ ? t . output
440+ : JSON . stringify ( t . output ) ,
441+ tool_name : t . name ,
442+ } ) ;
443+ } ) ;
444+ } else {
435445 messages . push ( {
436- role,
437- content :
438- typeof t . output === 'string' ? t . output : JSON . stringify ( t . output ) ,
446+ role : role ,
447+ content : toolRequests . length > 0 ? '' : messageText ,
448+ images : images . length > 0 ? images : undefined ,
449+ tool_calls :
450+ toolRequests . length > 0
451+ ? toOllamaToolCall ( toolRequests )
452+ : undefined ,
439453 } ) ;
440- } ) ;
441- messages . push ( {
442- role : role ,
443- content : toolRequests . length > 0 ? '' : messageText ,
444- images : images . length > 0 ? images : undefined ,
445- tool_calls :
446- toolRequests . length > 0 ? toOllamaToolCall ( toolRequests ) : undefined ,
447- } ) ;
454+ }
448455 } ) ;
449456 request . messages = messages ;
450457 } else {
Original file line number Diff line number Diff line change @@ -152,8 +152,10 @@ export interface OllamaToolCall {
152152export interface Message {
153153 role : string ;
154154 content : string ;
155+ thinking ?: string ;
155156 images ?: string [ ] ;
156157 tool_calls ?: any [ ] ;
158+ tool_name ?: string ;
157159}
158160
159161// Ollama local model definition
You can’t perform that action at this time.
0 commit comments