mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-01 22:21:15 +08:00
allow filling in the API Key of CustomModel mode (#561, previously designed for local offline model or custom server, now you can also use it for regular openai API calls and freely fill in the model name(#563))
This commit is contained in:
@@ -111,7 +111,13 @@ async function executeApi(session, port, config) {
|
||||
session.modelName,
|
||||
)
|
||||
} else if (customApiModelKeys.includes(session.modelName)) {
|
||||
await generateAnswersWithCustomApi(port, session.question, session, '', config.customModelName)
|
||||
await generateAnswersWithCustomApi(
|
||||
port,
|
||||
session.question,
|
||||
session,
|
||||
config.customApiKey,
|
||||
config.customModelName,
|
||||
)
|
||||
} else if (azureOpenAiApiModelKeys.includes(session.modelName)) {
|
||||
await generateAnswersWithAzureOpenaiApi(port, session.question, session)
|
||||
} else if (claudeApiModelKeys.includes(session.modelName)) {
|
||||
|
||||
@@ -98,7 +98,10 @@ export const Models = {
|
||||
chatgptApi4_8k_0613: { value: 'gpt-4', desc: 'ChatGPT (GPT-4-8k 0613)' },
|
||||
chatgptApi4_32k: { value: 'gpt-4-32k', desc: 'ChatGPT (GPT-4-32k)' },
|
||||
chatgptApi4_32k_0613: { value: 'gpt-4-32k', desc: 'ChatGPT (GPT-4-32k 0613)' },
|
||||
chatgptApi4_128k_preview: { value: 'gpt-4-1106-preview', desc: 'ChatGPT (GPT-4-Turbo 128k Preview)' },
|
||||
chatgptApi4_128k_preview: {
|
||||
value: 'gpt-4-1106-preview',
|
||||
desc: 'ChatGPT (GPT-4-Turbo 128k Preview)',
|
||||
},
|
||||
gptApiDavinci: { value: 'text-davinci-003', desc: 'GPT-3.5' },
|
||||
customModel: { value: '', desc: 'Custom Model' },
|
||||
azureOpenAi: { value: '', desc: 'ChatGPT (Azure)' },
|
||||
@@ -149,11 +152,14 @@ export const defaultConfig = {
|
||||
poeCustomBotName: '',
|
||||
|
||||
claudeApiKey: '',
|
||||
|
||||
customApiKey: '',
|
||||
|
||||
/** @type {keyof ModelMode}*/
|
||||
modelMode: 'balanced',
|
||||
|
||||
customModelApiUrl: 'http://localhost:8000/chat/completions',
|
||||
customModelName: 'rwkv',
|
||||
customModelApiUrl: 'http://localhost:8000/v1/chat/completions',
|
||||
customModelName: 'gpt-3.5-turbo',
|
||||
githubThirdPartyUrl: 'http://127.0.0.1:3000/conversation',
|
||||
|
||||
// advanced
|
||||
|
||||
@@ -285,6 +285,17 @@ export function GeneralPart({ config, updateConfig }) {
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isUsingCustomModel(config) && (
|
||||
<input
|
||||
type="password"
|
||||
value={config.customApiKey}
|
||||
placeholder={t('API Key')}
|
||||
onChange={(e) => {
|
||||
const apiKey = e.target.value
|
||||
updateConfig({ customApiKey: apiKey })
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isUsingAzureOpenAi(config) && (
|
||||
<input
|
||||
type="password"
|
||||
|
||||
@@ -9,7 +9,7 @@ import { getUserConfig } from '../../config/index.mjs'
|
||||
import { fetchSSE } from '../../utils/fetch-sse.mjs'
|
||||
import { getConversationPairs } from '../../utils/get-conversation-pairs.mjs'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { getCustomApiPromptBase, pushRecord, setAbortController } from './shared.mjs'
|
||||
import { pushRecord, setAbortController } from './shared.mjs'
|
||||
|
||||
/**
|
||||
* @param {Browser.Runtime.Port} port
|
||||
@@ -26,7 +26,7 @@ export async function generateAnswersWithCustomApi(port, question, session, apiK
|
||||
session.conversationRecords.slice(-config.maxConversationContextLength),
|
||||
false,
|
||||
)
|
||||
prompt.unshift({ role: 'system', content: await getCustomApiPromptBase() })
|
||||
// prompt.unshift({ role: 'system', content: await getCustomApiPromptBase() })
|
||||
prompt.push({ role: 'user', content: question })
|
||||
const apiUrl = config.customModelApiUrl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user