diff --git a/app/api/bytedance/[...path]/route.ts b/app/api/bytedance/[...path]/route.ts index bffb60f6c3a..336c837f037 100644 --- a/app/api/bytedance/[...path]/route.ts +++ b/app/api/bytedance/[...path]/route.ts @@ -132,17 +132,10 @@ async function request(req: NextRequest) { console.error(`[ByteDance] filter`, e); } } - console.log("[ByteDance request]", fetchOptions.headers, req.method); + try { const res = await fetch(fetchUrl, fetchOptions); - console.log( - "[ByteDance response]", - res.status, - " ", - res.headers, - res.url, - ); // to prevent browser prompt for credentials const newHeaders = new Headers(res.headers); newHeaders.delete("www-authenticate"); diff --git a/app/client/platforms/bytedance.ts b/app/client/platforms/bytedance.ts index 92c1fd55826..ce401e68dd5 100644 --- a/app/client/platforms/bytedance.ts +++ b/app/client/platforms/bytedance.ts @@ -2,7 +2,7 @@ import { ApiPath, ByteDance, - DEFAULT_API_HOST, + BYTEDANCE_BASE_URL, REQUEST_TIMEOUT_MS, } from "@/app/constant"; import { useAccessStore, useAppConfig, useChatStore } from "@/app/store"; @@ -58,9 +58,7 @@ export class DoubaoApi implements LLMApi { if (baseUrl.length === 0) { const isApp = !!getClientConfig()?.isApp; - baseUrl = isApp - ? DEFAULT_API_HOST + "/api/proxy/bytedance" - : ApiPath.ByteDance; + baseUrl = isApp ? BYTEDANCE_BASE_URL : ApiPath.ByteDance; } if (baseUrl.endsWith("/")) { @@ -94,9 +92,10 @@ export class DoubaoApi implements LLMApi { }, }; + const shouldStream = !!options.config.stream; const requestPayload: RequestPayload = { messages, - stream: options.config.stream, + stream: shouldStream, model: modelConfig.model, temperature: modelConfig.temperature, presence_penalty: modelConfig.presence_penalty, @@ -104,9 +103,6 @@ export class DoubaoApi implements LLMApi { top_p: modelConfig.top_p, }; - console.log("[Request] ByteDance payload: ", requestPayload); - - const shouldStream = !!options.config.stream; const controller = new AbortController(); options.onController?.(controller); diff --git a/app/components/chat.tsx b/app/components/chat.tsx index b1bdf757f44..ace404c1082 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -467,6 +467,14 @@ export function ChatActions(props: { return filteredModels; } }, [allModels]); + const currentModelName = useMemo(() => { + const model = models.find( + (m) => + m.name == currentModel && + m?.provider?.providerName == currentProviderName, + ); + return model?.displayName ?? ""; + }, [models, currentModel, currentProviderName]); const [showModelSelector, setShowModelSelector] = useState(false); const [showUploadImage, setShowUploadImage] = useState(false); @@ -489,7 +497,11 @@ export function ChatActions(props: { session.mask.modelConfig.providerName = nextModel?.provider ?.providerName as ServiceProvider; }); - showToast(nextModel.name); + showToast( + nextModel?.provider?.providerName == "ByteDance" + ? nextModel.displayName + : nextModel.name, + ); } }, [chatStore, currentModel, models]); @@ -571,7 +583,7 @@ export function ChatActions(props: { setShowModelSelector(true)} - text={currentModel} + text={currentModelName} icon={} /> @@ -596,7 +608,15 @@ export function ChatActions(props: { providerName as ServiceProvider; session.mask.syncGlobalConfig = false; }); - showToast(model); + if (providerName == "ByteDance") { + const selectedModel = models.find( + (m) => + m.name == model && m?.provider.providerName == providerName, + ); + showToast(selectedModel?.displayName ?? ""); + } else { + showToast(model); + } }} /> )}