From c150d3360324521166b0cdb98e9ca5acefdc24ed Mon Sep 17 00:00:00 2001 From: amstrongzyf <201840057@smail.nju.edu.cn> Date: Mon, 18 Aug 2025 20:15:18 +0800 Subject: [PATCH] fix bug for embedding caused by PR 1188 (#1194) --- rdagent/oai/backend/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rdagent/oai/backend/base.py b/rdagent/oai/backend/base.py index 7210ed1d..cf0512a1 100644 --- a/rdagent/oai/backend/base.py +++ b/rdagent/oai/backend/base.py @@ -481,9 +481,12 @@ class APIBackend(ABC): or "\\'messages\\' must contain the word \\'json\\' in some form" in e.message ): kwargs["add_json_in_prompt"] = True - too_long_error_message = "maximum context length" in e.message or "input must have less than" in e.message # type: ignore[attr-defined] - if hasattr(e, "message") and embedding and too_long_error_message: + too_long_error_message = hasattr(e, "message") and ( + "maximum context length" in e.message or "input must have less than" in e.message + ) + + if embedding and too_long_error_message: if not embedding_truncated: # Handle embedding text too long error - truncate once and retry model_name = LLM_SETTINGS.embedding_model