display doubao model name when select model
This commit is contained in:
parent
b3023543d6
commit
9d7e19cebf
|
@ -132,17 +132,10 @@ async function request(req: NextRequest) {
|
||||||
console.error(`[ByteDance] filter`, e);
|
console.error(`[ByteDance] filter`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("[ByteDance request]", fetchOptions.headers, req.method);
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(fetchUrl, fetchOptions);
|
const res = await fetch(fetchUrl, fetchOptions);
|
||||||
|
|
||||||
console.log(
|
|
||||||
"[ByteDance response]",
|
|
||||||
res.status,
|
|
||||||
" ",
|
|
||||||
res.headers,
|
|
||||||
res.url,
|
|
||||||
);
|
|
||||||
// to prevent browser prompt for credentials
|
// to prevent browser prompt for credentials
|
||||||
const newHeaders = new Headers(res.headers);
|
const newHeaders = new Headers(res.headers);
|
||||||
newHeaders.delete("www-authenticate");
|
newHeaders.delete("www-authenticate");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import {
|
import {
|
||||||
ApiPath,
|
ApiPath,
|
||||||
ByteDance,
|
ByteDance,
|
||||||
DEFAULT_API_HOST,
|
BYTEDANCE_BASE_URL,
|
||||||
REQUEST_TIMEOUT_MS,
|
REQUEST_TIMEOUT_MS,
|
||||||
} from "@/app/constant";
|
} from "@/app/constant";
|
||||||
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
||||||
|
@ -58,9 +58,7 @@ export class DoubaoApi implements LLMApi {
|
||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
baseUrl = isApp
|
baseUrl = isApp ? BYTEDANCE_BASE_URL : ApiPath.ByteDance;
|
||||||
? DEFAULT_API_HOST + "/api/proxy/bytedance"
|
|
||||||
: ApiPath.ByteDance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
|
@ -94,9 +92,10 @@ export class DoubaoApi implements LLMApi {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const shouldStream = !!options.config.stream;
|
||||||
const requestPayload: RequestPayload = {
|
const requestPayload: RequestPayload = {
|
||||||
messages,
|
messages,
|
||||||
stream: options.config.stream,
|
stream: shouldStream,
|
||||||
model: modelConfig.model,
|
model: modelConfig.model,
|
||||||
temperature: modelConfig.temperature,
|
temperature: modelConfig.temperature,
|
||||||
presence_penalty: modelConfig.presence_penalty,
|
presence_penalty: modelConfig.presence_penalty,
|
||||||
|
@ -104,9 +103,6 @@ export class DoubaoApi implements LLMApi {
|
||||||
top_p: modelConfig.top_p,
|
top_p: modelConfig.top_p,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("[Request] ByteDance payload: ", requestPayload);
|
|
||||||
|
|
||||||
const shouldStream = !!options.config.stream;
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
options.onController?.(controller);
|
options.onController?.(controller);
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,14 @@ export function ChatActions(props: {
|
||||||
return filteredModels;
|
return filteredModels;
|
||||||
}
|
}
|
||||||
}, [allModels]);
|
}, [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 [showModelSelector, setShowModelSelector] = useState(false);
|
||||||
const [showUploadImage, setShowUploadImage] = useState(false);
|
const [showUploadImage, setShowUploadImage] = useState(false);
|
||||||
|
|
||||||
|
@ -489,7 +497,11 @@ export function ChatActions(props: {
|
||||||
session.mask.modelConfig.providerName = nextModel?.provider
|
session.mask.modelConfig.providerName = nextModel?.provider
|
||||||
?.providerName as ServiceProvider;
|
?.providerName as ServiceProvider;
|
||||||
});
|
});
|
||||||
showToast(nextModel.name);
|
showToast(
|
||||||
|
nextModel?.provider?.providerName == "ByteDance"
|
||||||
|
? nextModel.displayName
|
||||||
|
: nextModel.name,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [chatStore, currentModel, models]);
|
}, [chatStore, currentModel, models]);
|
||||||
|
|
||||||
|
@ -571,7 +583,7 @@ export function ChatActions(props: {
|
||||||
|
|
||||||
<ChatAction
|
<ChatAction
|
||||||
onClick={() => setShowModelSelector(true)}
|
onClick={() => setShowModelSelector(true)}
|
||||||
text={currentModel}
|
text={currentModelName}
|
||||||
icon={<RobotIcon />}
|
icon={<RobotIcon />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -596,7 +608,15 @@ export function ChatActions(props: {
|
||||||
providerName as ServiceProvider;
|
providerName as ServiceProvider;
|
||||||
session.mask.syncGlobalConfig = false;
|
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);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue