mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-06-27 17:47:56 +08:00
WIP, custom API Modes
This commit is contained in:
@@ -83,7 +83,7 @@ async function executeApi(session, port, config) {
|
||||
port,
|
||||
session.question,
|
||||
session,
|
||||
config.customModelApiUrl,
|
||||
config.customModelApiUrl.trim() || 'http://localhost:8000/v1/chat/completions',
|
||||
config.customApiKey,
|
||||
config.customModelName,
|
||||
)
|
||||
@@ -92,7 +92,7 @@ async function executeApi(session, port, config) {
|
||||
port,
|
||||
session.question,
|
||||
session,
|
||||
session.apiMode.customUrl,
|
||||
session.apiMode.customUrl.trim() || 'http://localhost:8000/v1/chat/completions',
|
||||
session.apiMode.apiKey,
|
||||
session.apiMode.customName,
|
||||
)
|
||||
|
||||
@@ -88,6 +88,10 @@ async function checkBilling(apiKey, apiUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
function isUsingSpecialCustomModel(configOrSession) {
|
||||
return isUsingCustomModel(configOrSession) && !configOrSession.apiMode
|
||||
}
|
||||
|
||||
export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
const { t, i18n } = useTranslation()
|
||||
const [balance, setBalance] = useState(null)
|
||||
@@ -173,7 +177,7 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
style={
|
||||
isUsingOpenAiApiModel(config) ||
|
||||
isUsingMultiModeModel(config) ||
|
||||
isUsingCustomModel(config) ||
|
||||
isUsingSpecialCustomModel(config) ||
|
||||
isUsingAzureOpenAiApiModel(config) ||
|
||||
isUsingClaudeApiModel(config) ||
|
||||
isUsingMoonshotApiModel(config)
|
||||
@@ -255,7 +259,7 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
{isUsingCustomModel(config) && (
|
||||
{isUsingSpecialCustomModel(config) && (
|
||||
<input
|
||||
style="width: 50%;"
|
||||
type="text"
|
||||
@@ -328,7 +332,7 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
{isUsingCustomModel(config) && (
|
||||
{isUsingSpecialCustomModel(config) && (
|
||||
<input
|
||||
type="text"
|
||||
value={config.customModelApiUrl}
|
||||
@@ -339,7 +343,7 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isUsingCustomModel(config) && (
|
||||
{isUsingSpecialCustomModel(config) && (
|
||||
<input
|
||||
type="password"
|
||||
value={config.customApiKey}
|
||||
@@ -424,17 +428,6 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isUsingAzureOpenAiApiModel(config) && (
|
||||
<input
|
||||
type="text"
|
||||
value={config.azureDeploymentName}
|
||||
placeholder={t('Azure Deployment Name')}
|
||||
onChange={(e) => {
|
||||
const deploymentName = e.target.value
|
||||
updateConfig({ azureDeploymentName: deploymentName })
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isUsingGithubThirdPartyApiModel(config) && (
|
||||
<input
|
||||
type="text"
|
||||
|
||||
@@ -102,7 +102,7 @@ export function registerPortListener(executor) {
|
||||
if (!session) return
|
||||
const config = await getUserConfig()
|
||||
if (!session.modelName) session.modelName = config.modelName
|
||||
if (!session.apiMode) session.apiMode = config.apiMode
|
||||
if (!session.apiMode && session.modelName !== 'customModel') session.apiMode = config.apiMode
|
||||
if (!session.aiName)
|
||||
session.aiName = modelNameToDesc(
|
||||
session.apiMode ? apiModeToModelName(session.apiMode) : session.modelName,
|
||||
|
||||
Reference in New Issue
Block a user