Skip to content

Commit 34c6efb

Browse files
author
benbot
committed
adds support for gpt-4-1106
1 parent f1d9fda commit 34c6efb

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

packages/plugins/googleai/server/src/functions/makeChatCompletion.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ type ChatMessage = {
1010
content: string
1111
}
1212

13-
interface ContentMessage {
14-
contents: Content[]
15-
}
1613
interface Content {
1714
parts: { text: string }[]
1815
role: string
1916
}
2017

2118
async 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

5353
async 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')) {

packages/plugins/openai/shared/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
stringSocket,
99
} from 'shared/core'
1010

11-
export const GPT4_MODELS = ['gpt-4', 'gpt-4-0613']
11+
export const GPT4_MODELS = ['gpt-4', 'gpt-4-0613', 'gpt-4-1106-preview']
1212

1313
/**
1414
* An array of PluginSecret objects containing information about API key secrets.
@@ -141,7 +141,7 @@ const completionProviders: CompletionProvider[] = [
141141
type: stringSocket,
142142
},
143143
],
144-
models: ['gpt-3.5-turbo', 'gpt-4'],
144+
models: ['gpt-3.5-turbo', ...GPT4_MODELS],
145145
},
146146
]
147147

0 commit comments

Comments
 (0)