Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: add await to handleResponseAPIMode to ensure proper error handling (#12640)

YuTengjing90714af0dce5
diff --git a/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts b/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts
index 61e11965271..2834fad6663 100644
--- a/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts
+++ b/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts
@@ -367,7 +367,7 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = an
} as OpenAI.ChatCompletionCreateParamsStreaming);
if ((postPayload as any).apiMode === 'responses') {
- return this.handleResponseAPIMode(processedPayload, options);
+ return await this.handleResponseAPIMode(processedPayload, options);
}
const computedBaseURL =
@@ -452,7 +452,9 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = an
log('sending chat completion request with %d messages', messages.length);
if (debugParams?.chatCompletion?.()) {
+ // eslint-disable-next-line no-console
console.log('[requestPayload]');
+ // eslint-disable-next-line no-console
console.log(JSON.stringify(finalPayload), '\n');
}
@@ -564,7 +566,7 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = an
const log = debug(`${this.logPrefix}:models`);
log('fetching available models');
- let resultModels: ChatModelCard[] = [];
+ let resultModels: ChatModelCard[];
if (typeof models === 'function') {
log('using custom models function');
resultModels = await models({ client: this.client });
@@ -957,7 +959,9 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = an
} as OpenAI.Responses.ResponseCreateParamsStreaming | OpenAI.Responses.ResponseCreateParams;
if (debugParams?.responses?.()) {
+ // eslint-disable-next-line no-console
console.log('[requestPayload]');
+ // eslint-disable-next-line no-console
console.log(JSON.stringify(postPayload), '\n');
}