From 5b8f0cba0429d078c83012ccd2876cf9c77f96d8 Mon Sep 17 00:00:00 2001 From: Zihao Zhou <33304163+ZihaoZhou@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:07:37 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=84=20refactor:=20Add=20Provider=20Fal?= =?UTF-8?q?lback=20for=20Media=20Encoding=20using=20Client=20Endpoint=20(#?= =?UTF-8?q?10656)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using direct endpoints (e.g., Google) instead of Agents, `this.options.agent` is undefined, causing provider detection to fail. This resulted in "Unknown content type document" errors for Google/Gemini PDF uploads. Added `?? this.options.endpoint` fallback in addDocuments(), addVideos(), and addAudios() methods to ensure correct provider detection for all endpoint types. --- api/app/clients/BaseClient.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/app/clients/BaseClient.js b/api/app/clients/BaseClient.js index 149d331df1..c0d9169b51 100644 --- a/api/app/clients/BaseClient.js +++ b/api/app/clients/BaseClient.js @@ -1213,8 +1213,8 @@ class BaseClient { this.options.req, attachments, { - provider: this.options.agent?.provider, - endpoint: this.options.agent?.endpoint, + provider: this.options.agent?.provider ?? this.options.endpoint, + endpoint: this.options.agent?.endpoint ?? this.options.endpoint, useResponsesApi: this.options.agent?.model_parameters?.useResponsesApi, }, getStrategyFunctions, @@ -1231,8 +1231,8 @@ class BaseClient { this.options.req, attachments, { - provider: this.options.agent?.provider, - endpoint: this.options.agent?.endpoint, + provider: this.options.agent?.provider ?? this.options.endpoint, + endpoint: this.options.agent?.endpoint ?? this.options.endpoint, }, getStrategyFunctions, ); @@ -1246,8 +1246,8 @@ class BaseClient { this.options.req, attachments, { - provider: this.options.agent?.provider, - endpoint: this.options.agent?.endpoint, + provider: this.options.agent?.provider ?? this.options.endpoint, + endpoint: this.options.agent?.endpoint ?? this.options.endpoint, }, getStrategyFunctions, );