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:
AC
2025-04-06 17:03:18 +08:00
parent 78e8cb31c2
commit 04cbadb197
3 changed files with 126 additions and 18 deletions

View File

@@ -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,