mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-14 05:03:43 +08:00
Enhance API and Chat Actions with Improved Provider Handling
- Added logging to `getClientApi` for better debugging of provider input and standardized provider names. - Updated `ChatActions` to handle lowercase provider IDs, converting them to TitleCase for consistency with the ServiceProvider enum. - Implemented defaulting to OpenAI when provider ID is missing and added relevant logging for session updates. - Enhanced logging in `useChatStore` to track API call preparations and provider configurations.
This commit is contained in:
@@ -456,7 +456,26 @@ export const useChatStore = createPersistStore(
|
||||
]);
|
||||
});
|
||||
|
||||
const api: ClientApi = getClientApi(modelConfig.providerName);
|
||||
// --- 详细日志 (修正版) ---
|
||||
const providerNameFromConfig = modelConfig.providerName;
|
||||
console.log(
|
||||
"[onUserInput] Preparing API call. Provider from config:",
|
||||
providerNameFromConfig,
|
||||
"| Type:",
|
||||
typeof providerNameFromConfig,
|
||||
"| Is Enum value (Bedrock)?:",
|
||||
providerNameFromConfig === ServiceProvider.Bedrock, // 与枚举比较
|
||||
"| Is 'Bedrock' string?:",
|
||||
providerNameFromConfig === "Bedrock", // 与字符串比较
|
||||
"| Model:",
|
||||
modelConfig.model,
|
||||
);
|
||||
// --- 日志结束 ---
|
||||
|
||||
// 使用从配置中获取的 providerName,并提供默认值
|
||||
const api: ClientApi = getClientApi(
|
||||
providerNameFromConfig ?? ServiceProvider.OpenAI,
|
||||
);
|
||||
// make request
|
||||
api.llm.chat({
|
||||
messages: sendMessages,
|
||||
|
||||
Reference in New Issue
Block a user