mirror of
https://github.com/Yanyutin753/ChatGPT-Next-Web-LangChain-Gpt-4-All.git
synced 2025-10-13 14:35:00 +00:00
fix 切换传url的后缀大小写问题
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
"use client";
|
|
||||||
import {
|
import {
|
||||||
ApiPath,
|
ApiPath,
|
||||||
DEFAULT_API_HOST,
|
DEFAULT_API_HOST,
|
||||||
@@ -40,6 +39,7 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
private disableListModels = true;
|
private disableListModels = true;
|
||||||
|
|
||||||
path(path: string, model?: string): string {
|
path(path: string, model?: string): string {
|
||||||
|
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
|
|
||||||
const isAzure = accessStore.provider === ServiceProvider.Azure;
|
const isAzure = accessStore.provider === ServiceProvider.Azure;
|
||||||
@@ -54,9 +54,7 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
baseUrl = isApp
|
baseUrl = isApp ? DEFAULT_API_HOST : ApiPath.OpenAI;
|
||||||
? DEFAULT_API_HOST + "/proxy" + ApiPath.OpenAI
|
|
||||||
: ApiPath.OpenAI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
@@ -71,8 +69,6 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
return [baseUrl, model, path].join("/");
|
return [baseUrl, model, path].join("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("[Proxy Endpoint] ", baseUrl, path);
|
|
||||||
|
|
||||||
return [baseUrl, path].join("/");
|
return [baseUrl, path].join("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +173,7 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
try {
|
try {
|
||||||
// 使用正则表达式获取文件后缀
|
// 使用正则表达式获取文件后缀
|
||||||
const match = v.image_url.match(/\.(\w+)$/);
|
const match = v.image_url.match(/\.(\w+)$/);
|
||||||
if (match) {
|
if (match && match[1]) {
|
||||||
const fileExtension = match[1].toLowerCase();
|
const fileExtension = match[1].toLowerCase();
|
||||||
mimeType = extensionToMIME[fileExtension];
|
mimeType = extensionToMIME[fileExtension];
|
||||||
if (!mimeType) {
|
if (!mimeType) {
|
||||||
@@ -193,6 +189,11 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
image_url_data = `data:${mimeType};base64,${base64Data}`
|
image_url_data = `data:${mimeType};base64,${base64Data}`
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const match = v.image_url.match(/\.(\w+)$/);
|
||||||
|
if (match && match[1]) {
|
||||||
|
const fileExtension = match[1].toLowerCase();
|
||||||
|
v.image_url = v.image_url.replace(/\.\w+$/, '.' + fileExtension);
|
||||||
|
}
|
||||||
var port = window.location.port ? ':' + window.location.port : '';
|
var port = window.location.port ? ':' + window.location.port : '';
|
||||||
var url = window.location.protocol + "//" + window.location.hostname + port;
|
var url = window.location.protocol + "//" + window.location.hostname + port;
|
||||||
image_url_data = encodeURI(`${url}${v.image_url}`)
|
image_url_data = encodeURI(`${url}${v.image_url}`)
|
||||||
@@ -214,6 +215,7 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelConfig = {
|
const modelConfig = {
|
||||||
...useAppConfig.getState().modelConfig,
|
...useAppConfig.getState().modelConfig,
|
||||||
...useChatStore.getState().currentSession().mask.modelConfig,
|
...useChatStore.getState().currentSession().mask.modelConfig,
|
||||||
|
Reference in New Issue
Block a user