Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building Component CSVAgent: [Errno 22] Invalid argument: #25690

Open
5 tasks done
anshulyadav1976 opened this issue Aug 23, 2024 · 0 comments
Open
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@anshulyadav1976
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

Error building Component CSVAgent: [Errno 22] Invalid argument:

Error Message and Stack Trace (if applicable)

Error building Component CSVAgent: [Errno 22] Invalid argument:

Description

im using the csv agent and when i run the chatbot it returns the error :
Error building Component CSVAgent: [Errno 22] Invalid argument: and then it also shows every word in the csv file in the error message

the code for the csv agent is as follows : from langchain_experimental.agents.agent_toolkits.csv.base import create_csv_agent

from langflow.base.agents.agent import LCAgentComponent
from langflow.field_typing import AgentExecutor
from langflow.inputs import HandleInput, FileInput, DropdownInput

class CSVAgentComponent(LCAgentComponent):
display_name = "CSVAgent"
description = "Construct a CSV agent from a CSV and tools."
documentation = "https://python.langchain.com/docs/modules/agents/toolkits/csv"
name = "CSVAgent"

inputs = LCAgentComponent._base_inputs + [
    HandleInput(name="llm", display_name="Language Model", input_types=["LanguageModel"], required=True),
    FileInput(name="path", display_name="File Path", file_types=["csv"], required=True),
    DropdownInput(
        name="agent_type",
        display_name="Agent Type",
        advanced=True,
        options=["zero-shot-react-description", "openai-functions", "openai-tools"],
        value="openai-tools",
    ),
]

def build_agent(self) -> AgentExecutor:
    # Open the CSV file with 'latin-1' encoding
    with open(self.path, encoding='latin-1') as csv_file:
        csv_data = csv_file.read()

    return create_csv_agent(llm=self.llm, path=csv_data, agent_type=self.agent_type, **self.get_agent_kwargs())

System Info

windows 11

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant