mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-05 16:42:59 +08:00
feat: support gpt-4 (#22)
This commit is contained in:
@@ -38,7 +38,7 @@ export async function sendModerations(token, question, conversationId, messageId
|
||||
|
||||
export async function getModels(token) {
|
||||
const response = JSON.parse((await request(token, 'GET', '/models')).responseText)
|
||||
return response.models
|
||||
if (response.models) return response.models.map((m) => m.slug)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,12 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
|
||||
const models = await getModels(accessToken).catch(() => {
|
||||
port.onMessage.removeListener(stopListener)
|
||||
})
|
||||
console.debug('models', models)
|
||||
const config = await getUserConfig()
|
||||
const selectedModel = Models[config.modelName].value
|
||||
const usedModel =
|
||||
models && models.includes(selectedModel) ? selectedModel : Models[chatgptWebModelKeys[0]].value
|
||||
console.debug('usedModel', usedModel)
|
||||
|
||||
let answer = ''
|
||||
await fetchSSE(`${config.customChatGptWebApiUrl}${config.customChatGptWebApiPath}`, {
|
||||
@@ -94,7 +99,7 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
|
||||
},
|
||||
},
|
||||
],
|
||||
model: models ? models[0].slug : Models[chatgptWebModelKeys[0]].value,
|
||||
model: usedModel,
|
||||
parent_message_id: session.parentMessageId,
|
||||
}),
|
||||
onMessage(message) {
|
||||
|
||||
+7
-4
@@ -14,13 +14,16 @@ import { languages } from 'countries-list'
|
||||
*/
|
||||
export const Models = {
|
||||
chatgptFree: { value: 'text-davinci-002-render-sha', desc: 'ChatGPT (Web)' },
|
||||
chatgptApi: { value: 'gpt-3.5-turbo', desc: 'ChatGPT (GPT-3.5)' },
|
||||
gptDavinci: { value: 'text-davinci-003', desc: 'GPT3' },
|
||||
chatgptPlus: { value: 'gpt-4', desc: 'ChatGPT (Web, GPT-4)' },
|
||||
chatgptApi35: { value: 'gpt-3.5-turbo', desc: 'ChatGPT (GPT-3.5-turbo)' },
|
||||
chatgptApi4_8k: { value: 'gpt-4', desc: 'ChatGPT (GPT-4-8k)' },
|
||||
chatgptApi4_32k: { value: 'gpt-4-32k', desc: 'ChatGPT (GPT-4-32k)' },
|
||||
gptApiDavinci: { value: 'text-davinci-003', desc: 'GPT-3.5' },
|
||||
}
|
||||
|
||||
export const chatgptWebModelKeys = ['chatgptFree']
|
||||
export const chatgptWebModelKeys = ['chatgptFree', 'chatgptPlus']
|
||||
export const gptApiModelKeys = ['gptDavinci']
|
||||
export const chatgptApiModelKeys = ['chatgptApi']
|
||||
export const chatgptApiModelKeys = ['chatgptApi35', 'chatgptApi4_8k', 'chatgptApi4_32k']
|
||||
|
||||
export const TriggerMode = {
|
||||
always: 'Always',
|
||||
|
||||
Reference in New Issue
Block a user