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]ΒΆ

Construct a Spark SQL agent from an LLM and tools.

Parameters
  • llm (BaseLanguageModel) –

  • toolkit (SparkSQLToolkit) –

  • callback_manager (Optional[BaseCallbackManager]) –

  • callbacks (Callbacks) –

  • prefix (str) –

  • suffix (str) –

  • format_instructions (Optional[str]) –

  • input_variables (Optional[List[str]]) –

  • top_k (int) –

  • max_iterations (Optional[int]) –

  • max_execution_time (Optional[float]) –

  • early_stopping_method (str) –

  • verbose (bool) –

  • agent_executor_kwargs (Optional[Dict[str, Any]]) –

  • kwargs (Any) –

Return type

AgentExecutor

Examples using create_spark_sql_agentΒΆ