-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
154 changed files
with
12,594 additions
and
221 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from importlib import metadata | ||
|
||
try: | ||
__version__ = metadata.version(__package__) | ||
except metadata.PackageNotFoundError: | ||
# Case where package metadata is not available. | ||
__version__ = "" | ||
del metadata # optional, avoids polluting the results of dir(__package__) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from langchain_experimental.agents.agent_toolkits import ( | ||
create_csv_agent, | ||
create_pandas_dataframe_agent, | ||
create_spark_dataframe_agent, | ||
create_xorbits_agent, | ||
) | ||
|
||
__all__ = [ | ||
"create_csv_agent", | ||
"create_pandas_dataframe_agent", | ||
"create_spark_dataframe_agent", | ||
"create_xorbits_agent", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from langchain_experimental.agents.agent_toolkits.csv.base import create_csv_agent | ||
from langchain_experimental.agents.agent_toolkits.pandas.base import ( | ||
create_pandas_dataframe_agent, | ||
) | ||
from langchain_experimental.agents.agent_toolkits.python.base import create_python_agent | ||
from langchain_experimental.agents.agent_toolkits.spark.base import ( | ||
create_spark_dataframe_agent, | ||
) | ||
from langchain_experimental.agents.agent_toolkits.xorbits.base import ( | ||
create_xorbits_agent, | ||
) | ||
|
||
__all__ = [ | ||
"create_xorbits_agent", | ||
"create_pandas_dataframe_agent", | ||
"create_spark_dataframe_agent", | ||
"create_python_agent", | ||
"create_csv_agent", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""CSV toolkit.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from io import IOBase | ||
from typing import Any, List, Optional, Union | ||
|
||
from langchain.agents.agent import AgentExecutor | ||
from langchain.schema.language_model import BaseLanguageModel | ||
|
||
from langchain_experimental.agents.agent_toolkits.pandas.base import ( | ||
create_pandas_dataframe_agent, | ||
) | ||
|
||
|
||
def create_csv_agent( | ||
llm: BaseLanguageModel, | ||
path: Union[str, IOBase, List[Union[str, IOBase]]], | ||
pandas_kwargs: Optional[dict] = None, | ||
**kwargs: Any, | ||
) -> AgentExecutor: | ||
"""Create csv agent by loading to a dataframe and using pandas agent.""" | ||
try: | ||
import pandas as pd | ||
except ImportError: | ||
raise ImportError( | ||
"pandas package not found, please install with `pip install pandas`" | ||
) | ||
|
||
_kwargs = pandas_kwargs or {} | ||
if isinstance(path, (str, IOBase)): | ||
df = pd.read_csv(path, **_kwargs) | ||
elif isinstance(path, list): | ||
df = [] | ||
for item in path: | ||
if not isinstance(item, (str, IOBase)): | ||
raise ValueError(f"Expected str or file-like object, got {type(path)}") | ||
df.append(pd.read_csv(item, **_kwargs)) | ||
else: | ||
raise ValueError(f"Expected str, list, or file-like object, got {type(path)}") | ||
return create_pandas_dataframe_agent(llm, df, **kwargs) |
1 change: 1 addition & 0 deletions
1
langchain_experimental/agents/agent_toolkits/pandas/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Pandas toolkit.""" |
Oops, something went wrong.