@@ -10,24 +10,24 @@ type ChatMessage = {
1010 content : string
1111}
1212
13- interface ContentMessage {
14- contents : Content [ ]
15- }
1613interface Content {
1714 parts : { text : string } [ ]
1815 role : string
1916}
2017
2118async function makeGeminiChatCompletion ( data : CompletionHandlerInputData ) : Promise < any > {
22- const { node, inputs, context } = data
19+ const { node, inputs } = data
2320
2421 // Get the system message and conversation inputs
2522 const system = inputs [ 'system' ] ?. [ 0 ] as ChatMessage
2623 const conversation = inputs [ 'conversation' ] ?. [ 0 ] as any
2724
25+
2826 // Initialize conversationMessages array
2927 const conversationMessages : Content [ ] = [ ]
3028
29+ conversationMessages . push ( { role : 'user' , parts : [ { text : system . content } ] } )
30+
3131 // Add elements to conversationMessages
3232 conversation ?. forEach ( event => {
3333 conversationMessages . push ( { role : event . observer === event . sender ? 'model' : 'user' , parts : [ { text : event . content } ] } )
@@ -37,8 +37,6 @@ async function makeGeminiChatCompletion(data: CompletionHandlerInputData): Promi
3737
3838 conversationMessages . push ( { role : 'user' , parts : [ { text : input } ] } )
3939
40- const examples = ( inputs [ 'examples' ] ?. [ 0 ] as string [ ] ) || [ ]
41-
4240 // Get or set default settings
4341 const request = {
4442 contents : conversationMessages ,
@@ -47,11 +45,13 @@ async function makeGeminiChatCompletion(data: CompletionHandlerInputData): Promi
4745 top_p : parseFloat ( ( node ?. data ?. top_p as string ) ?? '0.95' ) ,
4846 top_k : parseFloat ( ( node ?. data ?. top_k as string ) ?? '40' ) ,
4947 }
50- } as any
48+ }
49+
50+ return request ;
5151}
5252
5353async function makePalmChatCompletion ( data : CompletionHandlerInputData ) : Promise < any > {
54- const { node, inputs, context } = data
54+ const { node, inputs } = data
5555 // Get the system message and conversation inputs
5656 const system = inputs [ 'system' ] ?. [ 0 ] as ChatMessage
5757 const conversation = inputs [ 'conversation' ] ?. [ 0 ] as any
@@ -99,7 +99,7 @@ export async function makeChatCompletion(
9999 result ?: string | null
100100 error ?: string | null
101101} > {
102- const { node, inputs , context } = data
102+ const { node, context } = data
103103
104104 let requestData : any = null ;
105105 if ( ( node ?. data ?. model as string ) . includes ( 'gemini' ) ) {
0 commit comments