chore: optimize the code

This commit is contained in:
Dogtiti 2024-07-05 23:56:10 +08:00
parent 183ad2a34b
commit 14bc1b6aac
3 changed files with 5 additions and 5 deletions

View File

@ -162,7 +162,7 @@ export function getHeaders() {
Accept: "application/json", Accept: "application/json",
}; };
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig; const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
const isGoogle = modelConfig.providerName == ServiceProvider.Azure; const isGoogle = modelConfig.providerName == ServiceProvider.Google;
const isAzure = modelConfig.providerName === ServiceProvider.Azure; const isAzure = modelConfig.providerName === ServiceProvider.Azure;
const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic; const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic;
const authHeader = isAzure const authHeader = isAzure

View File

@ -142,13 +142,12 @@ export class ChatGPTApi implements LLMApi {
try { try {
let chatPath = ""; let chatPath = "";
if (modelConfig.providerName == ServiceProvider.Azure) { if (modelConfig.providerName === ServiceProvider.Azure) {
// find model, and get displayName as deployName // find model, and get displayName as deployName
const { models: configModels, customModels: configCustomModels } = const { models: configModels, customModels: configCustomModels } =
useAppConfig.getState(); useAppConfig.getState();
const { defaultModel, customModels: accessCustomModels } = const { defaultModel, customModels: accessCustomModels } =
useAccessStore.getState(); useAccessStore.getState();
const models = collectModelsWithDefaultModel( const models = collectModelsWithDefaultModel(
configModels, configModels,
[configCustomModels, accessCustomModels].join(","), [configCustomModels, accessCustomModels].join(","),
@ -156,8 +155,8 @@ export class ChatGPTApi implements LLMApi {
); );
const model = models.find( const model = models.find(
(model) => (model) =>
model.name == modelConfig.model && model.name === modelConfig.model &&
model?.provider?.providerName == ServiceProvider.Azure, model?.provider?.providerName === ServiceProvider.Azure,
); );
chatPath = this.path( chatPath = this.path(
Azure.ChatPath( Azure.ChatPath(

View File

@ -153,6 +153,7 @@ const openaiModels = [
"gpt-4o-2024-05-13", "gpt-4o-2024-05-13",
"gpt-4-vision-preview", "gpt-4-vision-preview",
"gpt-4-turbo-2024-04-09", "gpt-4-turbo-2024-04-09",
"gpt-4-1106-preview",
]; ];
const googleModels = [ const googleModels = [