File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ interface InteractionsContentBlock {
5050
5151interface InteractionsTurn {
5252 role : string ;
53+ content ?: InteractionsContentBlock [ ] ;
5354 parts ?: InteractionsContentBlock [ ] ;
5455}
5556
@@ -100,17 +101,18 @@ export function geminiInteractionsToCompletionRequest(
100101 // Turn[] format
101102 for ( const turn of req . input as InteractionsTurn [ ] ) {
102103 const role = turn . role === "model" ? "assistant" : turn . role ;
103- if ( ! turn . parts || turn . parts . length === 0 ) {
104+ const blocks = turn . content ?? turn . parts ;
105+ if ( ! blocks || blocks . length === 0 ) {
104106 if ( role === "user" || role === "assistant" ) {
105107 messages . push ( { role : role as "user" | "assistant" , content : "" } ) ;
106108 }
107109 continue ;
108110 }
109111
110112 // Check for function_call or function_result parts
111- const funcCallParts = turn . parts . filter ( ( p ) => p . type === "function_call" ) ;
112- const funcResultParts = turn . parts . filter ( ( p ) => p . type === "function_result" ) ;
113- const textParts = turn . parts . filter ( ( p ) => p . type === "text" ) ;
113+ const funcCallParts = blocks . filter ( ( p ) => p . type === "function_call" ) ;
114+ const funcResultParts = blocks . filter ( ( p ) => p . type === "function_result" ) ;
115+ const textParts = blocks . filter ( ( p ) => p . type === "text" ) ;
114116
115117 if ( funcCallParts . length > 0 ) {
116118 // Assistant tool call message
You can’t perform that action at this time.
0 commit comments