langchain_community.agent_toolkits.spark_sql.base
.create_spark_sql_agent¶
- langchain_community.agent_toolkits.spark_sql.base.create_spark_sql_agent(llm: BaseLanguageModel, toolkit: SparkSQLToolkit, callback_manager: Optional[BaseCallbackManager] = None, callbacks: Callbacks = None, prefix: str = 'You are an agent designed to interact with Spark SQL.\nGiven an input question, create a syntactically correct Spark SQL query to run, then look at the results of the query and return the answer.\nUnless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results.\nYou can order the results by a relevant column to return the most interesting examples in the database.\nNever query for all the columns from a specific table, only ask for the relevant columns given the question.\nYou have access to tools for interacting with the database.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\nYou MUST double check your query before executing it. If you get an error while executing a query, rewrite the query and try again.\n\nDO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\n\nIf the question does not seem related to the database, just return "I don\'t know" as the answer.\n', suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should look at the tables in the database to see what I can query.\n{agent_scratchpad}', format_instructions: Optional[str] = None, input_variables: Optional[List[str]] = None, top_k: int = 10, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', verbose: bool = False, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Any) AgentExecutor [source]¶
从LLM和工具中构建Spark SQL代理。
- 参数
llm (BaseLanguageModel) – 要使用的语言模型。
toolkit (SparkSQLToolkit) – Spark SQL工具集。
callback_manager (可选[BaseCallbackManager]) – 可选。回调管理器。默认为 None。
callbacks (回调) – 可选。回调函数。默认为 None。
prefix (str) – 可选。提示的前缀。默认为 SQL_PREFIX。
suffix (str) – 可选。提示的后缀。默认为 SQL_SUFFIX。
format_instructions (可选[str]) – 可选。提示的格式说明。默认为 None。
input_variables (可选[列表[str]]) – 可选。提示的输入变量。默认为 None。
top_k (int) – 可选。提示的前 k。默认为 10。
max_iterations (可选[int]) – 可选。最大迭代次数。默认为 15。
max_execution_time (可选[float]) – 可选。最大执行时间。默认为 None。
early_stopping_method (str) – 可选。提前停止的方法。默认为 “force”。
verbose (bool) – 可选。是否打印详细信息输出。默认为 False。
agent_executor_kwargs (可选[字典[str, Any]]) – 可选。代理执行器的 kwargs。默认为 None。
kwargs (Any) – 任意。额外的关键字参数。
- 返回
代理执行器。
- 返回类型