Add max_execution_time to openapi, pandas, and sql creators (#2779)

In #2399 we added the ability to set `max_execution_time` when creating
an AgentExecutor. This PR adds the `max_execution_time` argument to the
built-in pandas, sql, and openapi agents.

Co-authored-by: Zachary Jones <zjones@zetaglobal.com>
This commit is contained in:
Zach Jones 2023-04-12 20:09:42 -04:00 committed by GitHub
parent f0be3b0689
commit abfca72c0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -22,6 +22,9 @@ def create_openapi_agent(
suffix: str = OPENAPI_SUFFIX, suffix: str = OPENAPI_SUFFIX,
format_instructions: str = FORMAT_INSTRUCTIONS, format_instructions: str = FORMAT_INSTRUCTIONS,
input_variables: Optional[List[str]] = None, input_variables: Optional[List[str]] = None,
max_iterations: Optional[int] = 15,
max_execution_time: Optional[float] = None,
early_stopping_method: str = "force",
verbose: bool = False, verbose: bool = False,
return_intermediate_steps: bool = False, return_intermediate_steps: bool = False,
**kwargs: Any, **kwargs: Any,
@ -47,4 +50,7 @@ def create_openapi_agent(
tools=toolkit.get_tools(), tools=toolkit.get_tools(),
verbose=verbose, verbose=verbose,
return_intermediate_steps=return_intermediate_steps, return_intermediate_steps=return_intermediate_steps,
max_iterations=max_iterations,
max_execution_time=max_execution_time,
early_stopping_method=early_stopping_method,
) )

View File

@ -20,6 +20,7 @@ def create_pandas_dataframe_agent(
verbose: bool = False, verbose: bool = False,
return_intermediate_steps: bool = False, return_intermediate_steps: bool = False,
max_iterations: Optional[int] = 15, max_iterations: Optional[int] = 15,
max_execution_time: Optional[float] = None,
early_stopping_method: str = "force", early_stopping_method: str = "force",
**kwargs: Any, **kwargs: Any,
) -> AgentExecutor: ) -> AgentExecutor:
@ -48,5 +49,6 @@ def create_pandas_dataframe_agent(
verbose=verbose, verbose=verbose,
return_intermediate_steps=return_intermediate_steps, return_intermediate_steps=return_intermediate_steps,
max_iterations=max_iterations, max_iterations=max_iterations,
max_execution_time=max_execution_time,
early_stopping_method=early_stopping_method, early_stopping_method=early_stopping_method,
) )

View File

@ -21,6 +21,7 @@ def create_sql_agent(
input_variables: Optional[List[str]] = None, input_variables: Optional[List[str]] = None,
top_k: int = 10, top_k: int = 10,
max_iterations: Optional[int] = 15, max_iterations: Optional[int] = 15,
max_execution_time: Optional[float] = None,
early_stopping_method: str = "force", early_stopping_method: str = "force",
verbose: bool = False, verbose: bool = False,
**kwargs: Any, **kwargs: Any,
@ -47,5 +48,6 @@ def create_sql_agent(
tools=tools, tools=tools,
verbose=verbose, verbose=verbose,
max_iterations=max_iterations, max_iterations=max_iterations,
max_execution_time=max_execution_time,
early_stopping_method=early_stopping_method, early_stopping_method=early_stopping_method,
) )