Skip to content

Commit

Permalink
close
Browse files Browse the repository at this point in the history
  • Loading branch information
WuJunde committed Dec 5, 2023
1 parent a28b12e commit 223dbbe
Show file tree
Hide file tree
Showing 154 changed files with 12,594 additions and 221 deletions.
Empty file added __init__.py
Empty file.
Binary file added __pycache__/creat.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/prompt.cpython-311.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions creat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from langchain.vectorstores import FAISS
from datetime import datetime, timedelta
from typing import List
from .prompt import *
from prompt import *


from langchain_experimental.generative_agents import (
Expand Down Expand Up @@ -51,7 +51,7 @@ def create_new_memory_retriever():
# Define your embedding model
embeddings_model = HuggingFaceEmbeddings()
# Initialize the vectorstore as empty
embedding_size = 1536
embedding_size = 768 # it is a value only for llama-2-7b-chat model
index = faiss.IndexFlatL2(embedding_size)
vectorstore = FAISS(
embeddings_model.embed_query,
Expand Down
459 changes: 240 additions & 219 deletions generate.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions langchain_experimental/__init__.py
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.
13 changes: 13 additions & 0 deletions langchain_experimental/agents/__init__.py
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",
]
19 changes: 19 additions & 0 deletions langchain_experimental/agents/agent_toolkits/__init__.py
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",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""CSV toolkit."""
37 changes: 37 additions & 0 deletions langchain_experimental/agents/agent_toolkits/csv/base.py
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)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pandas toolkit."""
Loading

0 comments on commit 223dbbe

Please sign in to comment.