create_csv_agent#
- langchain_cohere.csv_agent.agent.create_csv_agent(llm: BaseLanguageModel, path: str | List[str], extra_tools: List[BaseTool] = [], pandas_kwargs: dict | None = None, prompt: ChatPromptTemplate | None = None, number_of_head_rows: int = 5, verbose: bool = True, return_intermediate_steps: bool = True, temp_path_dir: str | None = None, temp_path_prefix: str | None = 'langchain', temp_path_suffix: str | None = 'csv_agent') AgentExecutor [source]#
Create csv agent with the specified language model.
- Parameters:
llm (BaseLanguageModel) – Language model to use for the agent.
path (str | List[str]) – A string path, or a list of string paths that can be read in as pandas DataFrames with pd.read_csv().
number_of_head_rows (int) – Number of rows to display in the prompt for sample data
include_df_in_prompt – Display the DataFrame sample values in the prompt.
pandas_kwargs (dict | None) – Named arguments to pass to pd.read_csv().
prefix – Prompt prefix string.
suffix – Prompt suffix string.
prompt (ChatPromptTemplate | None) – Prompt to use for the agent. This takes precedence over the other prompt arguments, such as suffix and prefix.
temp_path_dir (str | None) – Temporary directory to store the csv files in for the python repl.
delete_temp_path – Whether to delete the temporary directory after the agent is done. This only works if temp_path_dir is not provided.
extra_tools (List[BaseTool]) –
verbose (bool) –
return_intermediate_steps (bool) –
temp_path_prefix (str | None) –
temp_path_suffix (str | None) –
- Returns:
An AgentExecutor with the specified agent_type agent and access to a PythonREPL and any user-provided extra_tools.
- Return type:
Example
from langchain_cohere import ChatCohere, create_csv_agent llm = ChatCohere(model="command-r-plus", temperature=0) agent_executor = create_csv_agent( llm, "titanic.csv" ) resp = agent_executor.invoke({"input":"How many people were on the titanic?"}) print(resp.get("output"))