mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-06-27 18:04:15 +08:00
WIP, custom API Modes
This commit is contained in:
@@ -76,6 +76,7 @@ function setPortProxy(port, proxyTabId) {
|
||||
|
||||
async function executeApi(session, port, config) {
|
||||
console.debug('modelName', session.modelName)
|
||||
console.debug('apiMode', session.apiMode)
|
||||
if (chatgptWebModelKeys.includes(session.modelName)) {
|
||||
let tabId
|
||||
if (
|
||||
|
||||
@@ -25,7 +25,7 @@ import FileSaver from 'file-saver'
|
||||
import { render } from 'preact'
|
||||
import FloatingToolbar from '../FloatingToolbar'
|
||||
import { useClampWindowSize } from '../../hooks/use-clamp-window-size'
|
||||
import { bingWebModelKeys, getUserConfig } from '../../config/index.mjs'
|
||||
import { bingWebModelKeys, getUserConfig, Models } from '../../config/index.mjs'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import DeleteButton from '../DeleteButton'
|
||||
import { useConfig } from '../../hooks/use-config.mjs'
|
||||
@@ -380,8 +380,12 @@ function ConversationCard(props) {
|
||||
className="normal-button"
|
||||
required
|
||||
onChange={(e) => {
|
||||
const apiMode = apiModes[e.target.value]
|
||||
const modelName = apiModeToModelName(apiMode)
|
||||
let apiMode = null
|
||||
let modelName = 'customModel'
|
||||
if (e.target.value !== -1) {
|
||||
apiMode = apiModes[e.target.value]
|
||||
modelName = apiModeToModelName(apiMode)
|
||||
}
|
||||
const newSession = {
|
||||
...session,
|
||||
modelName,
|
||||
@@ -407,6 +411,9 @@ function ConversationCard(props) {
|
||||
)
|
||||
}
|
||||
})}
|
||||
<option value={-1} selected={!config.apiMode && config.modelName === 'customModel'}>
|
||||
{t(Models.customModel.desc)}
|
||||
</option>
|
||||
</select>
|
||||
</span>
|
||||
{props.draggable && !completeDraggable && (
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
ThemeMode,
|
||||
TriggerMode,
|
||||
isUsingMoonshotApi,
|
||||
Models,
|
||||
} from '../../config/index.mjs'
|
||||
import Browser from 'webextension-polyfill'
|
||||
import { languageList } from '../../config/language.mjs'
|
||||
@@ -184,6 +185,10 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
}
|
||||
required
|
||||
onChange={(e) => {
|
||||
if (e.target.value === -1) {
|
||||
updateConfig({ modelName: 'customModel', apiMode: null })
|
||||
return
|
||||
}
|
||||
const apiMode = apiModes[e.target.value]
|
||||
updateConfig({ apiMode: apiMode })
|
||||
}}
|
||||
@@ -202,6 +207,9 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
)
|
||||
}
|
||||
})}
|
||||
<option value={-1} selected={!config.apiMode && config.modelName === 'customModel'}>
|
||||
{t(Models.customModel.desc)}
|
||||
</option>
|
||||
</select>
|
||||
{isUsingMultiModeModel(config) && (
|
||||
<select
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { fetchSSE } from '../../utils/fetch-sse.mjs'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { chatgptWebModelKeys, getUserConfig, Models } from '../../config/index.mjs'
|
||||
import { getUserConfig, Models } from '../../config/index.mjs'
|
||||
import { pushRecord, setAbortController } from './shared.mjs'
|
||||
import Browser from 'webextension-polyfill'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
@@ -236,7 +236,7 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
|
||||
console.debug('models', models)
|
||||
const selectedModel = modelNameToValue(session.modelName)
|
||||
const usedModel =
|
||||
models && models.includes(selectedModel) ? selectedModel : Models[chatgptWebModelKeys[0]].value
|
||||
models && models.includes(selectedModel) ? selectedModel : Models.chatgptFree35.value
|
||||
console.debug('usedModel', usedModel)
|
||||
const needArkoseToken = requirements && requirements.arkose?.required
|
||||
if (arkoseError && needArkoseToken) throw arkoseError
|
||||
|
||||
Reference in New Issue
Block a user