Skip to content

Commit

Permalink
Fixed import error in return type of parse method
Browse files Browse the repository at this point in the history
	modified:   libs/langchain/langchain/agents/react/agent.py
  • Loading branch information
Ahonanhin committed Dec 3, 2024
1 parent 08139a9 commit ffb14fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/langchain/langchain/agents/react/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from typing import List, Optional, Sequence, Union

from langchain_core.agents import AgentAction, AgentFinish

from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import BasePromptTemplate
from langchain_core.runnables import Runnable, RunnablePassthrough
from langchain_core.tools import BaseTool
from langchain_core.tools.render import ToolsRenderer, render_text_description

from langchain.agents import AgentAction, AgentFinish, AgentOutputParser
from langchain.agents import AgentOutputParser
from langchain.agents.format_scratchpad import format_log_to_str
from langchain.agents.output_parsers import ReActSingleInputOutputParser

Expand Down Expand Up @@ -139,6 +141,7 @@ def parse(self, text: str) -> Union[AgentAction, AgentFinish]:
reasoning_history = getattr(self, "_reasoning_history", [])
if text in reasoning_history:
raise ValueError("Detected repetitive reasoning. Terminating.")

reasoning_history.append(text)

setattr(self, "_reasoning_history", reasoning_history[-3:])
Expand Down

0 comments on commit ffb14fc

Please sign in to comment.