mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-09-09 11:19:25 +08:00
feat: enabled API Modes option (#264)
This commit is contained in:
@@ -110,5 +110,6 @@
|
|||||||
"Modules": "Modules",
|
"Modules": "Modules",
|
||||||
"API Params": "API Params",
|
"API Params": "API Params",
|
||||||
"API Url": "API Url",
|
"API Url": "API Url",
|
||||||
"Others": "Others"
|
"Others": "Others",
|
||||||
|
"API Modes": "API Modes"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,5 +110,6 @@
|
|||||||
"Modules": "模块",
|
"Modules": "模块",
|
||||||
"API Params": "API参数",
|
"API Params": "API参数",
|
||||||
"API Url": "API地址",
|
"API Url": "API地址",
|
||||||
"Others": "其他"
|
"Others": "其他",
|
||||||
|
"API Modes": "API模式"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,5 +110,6 @@
|
|||||||
"Modules": "模組",
|
"Modules": "模組",
|
||||||
"API Params": "API參數",
|
"API Params": "API參數",
|
||||||
"API Url": "API網址",
|
"API Url": "API網址",
|
||||||
"Others": "其他"
|
"Others": "其他",
|
||||||
|
"API Modes": "API模式"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,8 @@ function ConversationCard(props) {
|
|||||||
else setSession(newSession)
|
else setSession(newSession)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.entries(Models).map(([key, model]) => {
|
{config.activeApiModes.map((key) => {
|
||||||
|
const model = Models[key]
|
||||||
return (
|
return (
|
||||||
<option value={key} key={key} selected={key === session.modelName}>
|
<option value={key} key={key} selected={key === session.modelName}>
|
||||||
{t(model.desc)}
|
{t(model.desc)}
|
||||||
|
|||||||
@@ -118,6 +118,20 @@ export const defaultConfig = {
|
|||||||
// others
|
// others
|
||||||
|
|
||||||
alwaysCreateNewConversationWindow: false,
|
alwaysCreateNewConversationWindow: false,
|
||||||
|
activeApiModes: [
|
||||||
|
'chatgptFree35',
|
||||||
|
'chatgptPlus4',
|
||||||
|
'chatgptApi35',
|
||||||
|
'bingFree4',
|
||||||
|
'bingFreeSydney',
|
||||||
|
'poeAiWebSage',
|
||||||
|
'poeAiWebGPT4',
|
||||||
|
'poeAiWebClaudePlus',
|
||||||
|
'chatgptApi4_8k',
|
||||||
|
'customModel',
|
||||||
|
'azureOpenAi',
|
||||||
|
'poeAiWebCustom',
|
||||||
|
],
|
||||||
activeSelectionTools: ['translate', 'summary', 'polish', 'code', 'ask'],
|
activeSelectionTools: ['translate', 'summary', 'polish', 'code', 'ask'],
|
||||||
activeSiteAdapters: [
|
activeSiteAdapters: [
|
||||||
'bilibili',
|
'bilibili',
|
||||||
@@ -139,6 +153,7 @@ export const defaultConfig = {
|
|||||||
// unchangeable
|
// unchangeable
|
||||||
|
|
||||||
userLanguage: getNavigatorLanguage(),
|
userLanguage: getNavigatorLanguage(),
|
||||||
|
apiModes: Object.keys(Models),
|
||||||
selectionTools: [
|
selectionTools: [
|
||||||
'translate',
|
'translate',
|
||||||
'translateToEn',
|
'translateToEn',
|
||||||
|
|||||||
@@ -304,6 +304,10 @@ async function overwriteAccessToken() {
|
|||||||
async function prepareForForegroundRequests() {
|
async function prepareForForegroundRequests() {
|
||||||
if (location.hostname !== 'chat.openai.com') return
|
if (location.hostname !== 'chat.openai.com') return
|
||||||
|
|
||||||
|
const userConfig = await getUserConfig()
|
||||||
|
|
||||||
|
if (!chatgptWebModelKeys.some((model) => userConfig.activeApiModes.includes(model))) return
|
||||||
|
|
||||||
const div = document.createElement('div')
|
const div = document.createElement('div')
|
||||||
document.body.append(div)
|
document.body.append(div)
|
||||||
render(<NotificationForChatGPTWeb container={div} />, div)
|
render(<NotificationForChatGPTWeb container={div} />, div)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { Models } from '../../config/index.mjs'
|
||||||
|
|
||||||
|
ApiModes.propTypes = {
|
||||||
|
config: PropTypes.object.isRequired,
|
||||||
|
updateConfig: PropTypes.func.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiModes({ config, updateConfig }) {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{config.apiModes.map((key) => (
|
||||||
|
<label key={key}>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={config.activeApiModes.includes(key)}
|
||||||
|
onChange={(e) => {
|
||||||
|
const checked = e.target.checked
|
||||||
|
const activeApiModes = config.activeApiModes.filter((i) => i !== key)
|
||||||
|
if (checked) activeApiModes.push(key)
|
||||||
|
updateConfig({ activeApiModes })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{t(Models[key].desc)}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -94,7 +94,8 @@ export function GeneralPart({ config, updateConfig }) {
|
|||||||
updateConfig({ modelName: modelName })
|
updateConfig({ modelName: modelName })
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.entries(Models).map(([key, model]) => {
|
{config.activeApiModes.map((key) => {
|
||||||
|
const model = Models[key]
|
||||||
return (
|
return (
|
||||||
<option value={key} key={key} selected={key === config.modelName}>
|
<option value={key} key={key} selected={key === config.modelName}>
|
||||||
{t(model.desc)}
|
{t(model.desc)}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'
|
import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'
|
||||||
|
import { ApiModes } from './ApiModes'
|
||||||
import { SelectionTools } from './SelectionTools'
|
import { SelectionTools } from './SelectionTools'
|
||||||
import { SiteAdapters } from './SiteAdapters'
|
import { SiteAdapters } from './SiteAdapters'
|
||||||
|
|
||||||
@@ -16,10 +17,14 @@ export function ModulesPart({ config, updateConfig }) {
|
|||||||
<>
|
<>
|
||||||
<Tabs selectedTabClassName="popup-tab--selected">
|
<Tabs selectedTabClassName="popup-tab--selected">
|
||||||
<TabList>
|
<TabList>
|
||||||
|
<Tab className="popup-tab">{t('API Modes')}</Tab>
|
||||||
<Tab className="popup-tab">{t('Selection Tools')}</Tab>
|
<Tab className="popup-tab">{t('Selection Tools')}</Tab>
|
||||||
<Tab className="popup-tab">{t('Sites')}</Tab>
|
<Tab className="popup-tab">{t('Sites')}</Tab>
|
||||||
</TabList>
|
</TabList>
|
||||||
|
|
||||||
|
<TabPanel>
|
||||||
|
<ApiModes config={config} updateConfig={updateConfig} />
|
||||||
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<SelectionTools config={config} updateConfig={updateConfig} />
|
<SelectionTools config={config} updateConfig={updateConfig} />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|||||||
Reference in New Issue
Block a user