mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-09-11 12:00:52 +08:00
feat: better custom model support
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
// and it has not yet had a negative impact on maintenance.
|
||||
// If necessary, I will refactor.
|
||||
|
||||
import { getUserConfig, maxResponseTokenLength, Models } from '../../config/index.mjs'
|
||||
import { getUserConfig, maxResponseTokenLength } from '../../config/index.mjs'
|
||||
import { fetchSSE } from '../../utils/fetch-sse'
|
||||
import { getConversationPairs } from '../../utils/get-conversation-pairs'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
@@ -52,7 +52,7 @@ export async function generateAnswersWithCustomApi(port, question, session, apiK
|
||||
},
|
||||
body: JSON.stringify({
|
||||
messages: prompt,
|
||||
model: Models[modelName].value,
|
||||
model: modelName,
|
||||
stream: true,
|
||||
max_tokens: maxResponseTokenLength,
|
||||
}),
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
defaultConfig,
|
||||
getUserConfig,
|
||||
gptApiModelKeys,
|
||||
isUsingCustomModel,
|
||||
Models,
|
||||
} from '../config/index.mjs'
|
||||
import { isSafari } from '../utils/is-safari'
|
||||
@@ -60,7 +61,10 @@ Browser.runtime.onConnect.addListener((port) => {
|
||||
if (!session) return
|
||||
const config = await getUserConfig()
|
||||
if (!session.modelName) session.modelName = config.modelName
|
||||
if (!session.aiName) session.aiName = Models[session.modelName].desc
|
||||
if (!session.aiName)
|
||||
session.aiName =
|
||||
Models[session.modelName].desc +
|
||||
(isUsingCustomModel(config) ? ` (${config.customModelName})` : '')
|
||||
port.postMessage({ session })
|
||||
|
||||
try {
|
||||
@@ -101,8 +105,8 @@ Browser.runtime.onConnect.addListener((port) => {
|
||||
port,
|
||||
session.question,
|
||||
session,
|
||||
config.apiKey,
|
||||
session.modelName,
|
||||
'',
|
||||
config.customModelName,
|
||||
)
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user