mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
13d1df2140
`AgentExecutor` already has support for limiting the number of iterations. But the amount of time taken for each iteration can vary quite a bit, so it is difficult to place limits on the execution time. This PR adds a new field `max_execution_time` to the `AgentExecutor` model. When called asynchronously, the agent loop is wrapped in an `asyncio.timeout()` context which triggers the early stopping response if the time limit is reached. When called synchronously, the agent loop checks for both the max_iteration limit and the time limit after each iteration. When used asynchronously `max_execution_time` gives really tight control over the max time for an execution chain. When used synchronously, the chain can unfortunately exceed max_execution_time, but it still gives more control than trying to estimate the number of max_iterations needed to cap the execution time. --------- Co-authored-by: Zachary Jones <zjones@zetaglobal.com> |
||
---|---|---|
.. | ||
agents | ||
callbacks | ||
chains | ||
data | ||
docstore | ||
document_loader | ||
llms | ||
output_parsers | ||
prompts | ||
tools | ||
utilities | ||
__init__.py | ||
test_bash.py | ||
test_formatting.py | ||
test_python.py | ||
test_sql_database_schema.py | ||
test_sql_database.py | ||
test_text_splitter.py |