From 1c68cbdb28f5f6758dfc9ccf21b7f7beff3ba633 Mon Sep 17 00:00:00 2001 From: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Date: Tue, 2 May 2023 15:11:23 -0700 Subject: [PATCH] Fix typing of attribute (#3999) --- langchain/agents/structured_chat/base.py | 5 +++-- langchain/agents/structured_chat/output_parser.py | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/langchain/agents/structured_chat/base.py b/langchain/agents/structured_chat/base.py index e96aac54e5..bd6ec0f00a 100644 --- a/langchain/agents/structured_chat/base.py +++ b/langchain/agents/structured_chat/base.py @@ -5,7 +5,6 @@ from pydantic import Field from langchain.agents.agent import Agent, AgentOutputParser from langchain.agents.structured_chat.output_parser import ( - StructuredChatOutputParser, StructuredChatOutputParserWithRetries, ) from langchain.agents.structured_chat.prompt import FORMAT_INSTRUCTIONS, PREFIX, SUFFIX @@ -23,7 +22,9 @@ from langchain.tools import BaseTool class StructuredChatAgent(Agent): - output_parser: AgentOutputParser = Field(default_factory=StructuredChatOutputParser) + output_parser: AgentOutputParser = Field( + default_factory=StructuredChatOutputParserWithRetries + ) @property def observation_prefix(self) -> str: diff --git a/langchain/agents/structured_chat/output_parser.py b/langchain/agents/structured_chat/output_parser.py index 9d10e833f7..4f9240ad11 100644 --- a/langchain/agents/structured_chat/output_parser.py +++ b/langchain/agents/structured_chat/output_parser.py @@ -11,7 +11,6 @@ from langchain.agents.agent import AgentOutputParser from langchain.agents.structured_chat.prompt import FORMAT_INSTRUCTIONS from langchain.base_language import BaseLanguageModel from langchain.output_parsers import OutputFixingParser -from langchain.output_parsers.pydantic import PydanticOutputParser from langchain.schema import AgentAction, AgentFinish, OutputParserException logger = logging.getLogger(__name__) @@ -43,9 +42,7 @@ class StructuredChatOutputParser(AgentOutputParser): class StructuredChatOutputParserWithRetries(AgentOutputParser): - base_parser: PydanticOutputParser = Field( - default_factory=StructuredChatOutputParser - ) + base_parser: AgentOutputParser = Field(default_factory=StructuredChatOutputParser) output_fixing_parser: Optional[OutputFixingParser] = None def get_format_instructions(self) -> str: