Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

increase max_iters for react (#9162)

Chen Qian1c310587a7f9
diff --git a/dspy/predict/react.py b/dspy/predict/react.py
index e94b591ce..2b93575f6 100644
--- a/dspy/predict/react.py
+++ b/dspy/predict/react.py
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
class ReAct(Module):
- def __init__(self, signature: type["Signature"], tools: list[Callable], max_iters: int = 10):
+ def __init__(self, signature: type["Signature"], tools: list[Callable], max_iters: int = 20):
"""
ReAct stands for "Reasoning and Acting," a popular paradigm for building tool-using agents.
In this approach, the language model is iteratively provided with a list of tools and has
@@ -153,9 +153,7 @@ class ReAct(Module):
except ContextWindowExceededError:
logger.warning("Trajectory exceeded the context window, truncating the oldest tool call information.")
trajectory = self.truncate_trajectory(trajectory)
- raise ValueError(
- "The context window was exceeded even after 3 attempts to truncate the trajectory."
- )
+ raise ValueError("The context window was exceeded even after 3 attempts to truncate the trajectory.")
async def _async_call_with_potential_trajectory_truncation(self, module, trajectory, **input_args):
for _ in range(3):
@@ -167,9 +165,7 @@ class ReAct(Module):
except ContextWindowExceededError:
logger.warning("Trajectory exceeded the context window, truncating the oldest tool call information.")
trajectory = self.truncate_trajectory(trajectory)
- raise ValueError(
- "The context window was exceeded even after 3 attempts to truncate the trajectory."
- )
+ raise ValueError("The context window was exceeded even after 3 attempts to truncate the trajectory.")
def truncate_trajectory(self, trajectory):
"""Truncates the trajectory so that it fits in the context window.