From 32c9c58adf84c5688458e49c5fd4c6a425052a65 Mon Sep 17 00:00:00 2001 From: Hugo Berg Date: Tue, 21 Jan 2025 15:26:38 +0100 Subject: [PATCH] Community: fix missing f-string modifier in oai structured output parsing error (#29326) - **Description:** The ValueError raised on certain structured-outputs parsing errors, in langchain openai community integration, was missing a f-string modifier and so didn't produce useful outputs. This is a 2-line, 2-character change. - **Issue:** None open that this fixes - **Dependencies:** Nothing changed - **Twitter handle:** None - [X] **Add tests and docs**: There's nothing to add for. - [-] **Lint and test**: Happy to run this if you deem it necessary. --------- Co-authored-by: Chester Curme --- libs/partners/openai/langchain_openai/chat_models/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 42b2501cbbf..b31742a4e10 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -2486,7 +2486,7 @@ def _oai_structured_outputs_parser(ai_msg: AIMessage) -> PydanticBaseModel: else: raise ValueError( "Structured Output response does not have a 'parsed' field nor a 'refusal' " - "field. Received message:\n\n{ai_msg}" + f"field. Received message:\n\n{ai_msg}" )