You've already forked bilibili-subtitle
fix serverUrl bug
This commit is contained in:
@@ -7,13 +7,17 @@ const getServerUrl = (serverUrl?: string) => {
|
|||||||
if (serverUrl.endsWith('/')) {
|
if (serverUrl.endsWith('/')) {
|
||||||
serverUrl = serverUrl.slice(0, -1)
|
serverUrl = serverUrl.slice(0, -1)
|
||||||
}
|
}
|
||||||
|
//如果serverUrl不以/vxxx结尾,则添加/v1
|
||||||
|
if (!/\/v\d+$/.test(serverUrl.toLowerCase())) {
|
||||||
|
serverUrl += '/v1'
|
||||||
|
}
|
||||||
return serverUrl
|
return serverUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handleChatCompleteTask = async (task: Task) => {
|
export const handleChatCompleteTask = async (task: Task) => {
|
||||||
const data = task.def.data
|
const data = task.def.data
|
||||||
const serverUrl = getServerUrl(task.def.serverUrl)
|
const serverUrl = getServerUrl(task.def.serverUrl)
|
||||||
const resp = await fetch(`${serverUrl}/v1/chat/completions`, {
|
const resp = await fetch(`${serverUrl}/chat/completions`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ export const SUMMARIZE_THRESHOLD = 100
|
|||||||
export const SUMMARIZE_LANGUAGE_DEFAULT = 'cn'
|
export const SUMMARIZE_LANGUAGE_DEFAULT = 'cn'
|
||||||
export const SUMMARIZE_ALL_THRESHOLD = 5
|
export const SUMMARIZE_ALL_THRESHOLD = 5
|
||||||
export const ASK_ENABLED_DEFAULT = true
|
export const ASK_ENABLED_DEFAULT = true
|
||||||
export const DEFAULT_SERVER_URL_OPENAI = 'https://api.openai.com'
|
export const DEFAULT_SERVER_URL_OPENAI = 'https://api.openai.com/v1'
|
||||||
export const CUSTOM_MODEL_TOKENS = 16385
|
export const CUSTOM_MODEL_TOKENS = 16385
|
||||||
|
|
||||||
export const MODEL_TIP = '推荐gpt-4o-mini,能力强,价格低,token上限大'
|
export const MODEL_TIP = '推荐gpt-4o-mini,能力强,价格低,token上限大'
|
||||||
|
|||||||
@@ -119,16 +119,6 @@ export const getSummaryStr = (summary: Summary) => {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServerUrl = (serverUrl?: string) => {
|
|
||||||
if (!serverUrl) {
|
|
||||||
return 'https://api.openai.com'
|
|
||||||
}
|
|
||||||
if (serverUrl.endsWith('/')) {
|
|
||||||
serverUrl = serverUrl.slice(0, -1)
|
|
||||||
}
|
|
||||||
return serverUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getModel = (envData: EnvData) => {
|
export const getModel = (envData: EnvData) => {
|
||||||
if (envData.model === 'custom') {
|
if (envData.model === 'custom') {
|
||||||
return envData.customModel
|
return envData.customModel
|
||||||
|
|||||||
Reference in New Issue
Block a user