2024-03-26 14:38:10 +00:00
|
|
|
"""**Agent** is a class that uses an LLM to choose
|
|
|
|
a sequence of actions to take.
|
|
|
|
|
|
|
|
In Chains, a sequence of actions is hardcoded. In Agents,
|
|
|
|
a language model is used as a reasoning engine to determine which actions
|
|
|
|
to take and in which order.
|
|
|
|
|
|
|
|
Agents select and use **Tools** and **Toolkits** for actions.
|
|
|
|
""" # noqa: E501
|
experimental[patch]: Add experimental.agent imports (#13839)
- **Description:** The experimental package needs to be compatible with
the usage of importing agents
For example, if i use `from langchain.agents import
create_pandas_dataframe_agent`, running the program will prompt the
following information:
```
Traceback (most recent call last):
File "/Users/dongwm/test/main.py", line 1, in <module>
from langchain.agents import create_pandas_dataframe_agent
File "/Users/dongwm/test/venv/lib/python3.11/site-packages/langchain/agents/__init__.py", line 87, in __getattr__
raise ImportError(
ImportError: create_pandas_dataframe_agent has been moved to langchain experimental. See https://github.com/langchain-ai/langchain/discussions/11680 for more information.
Please update your import statement from: `langchain.agents.create_pandas_dataframe_agent` to `langchain_experimental.agents.create_pandas_dataframe_agent`.
```
But when I changed to `from langchain_experimental.agents import
create_pandas_dataframe_agent`, it was actually wrong:
```python
Traceback (most recent call last):
File "/Users/dongwm/test/main.py", line 2, in <module>
from langchain_experimental.agents import create_pandas_dataframe_agent
ImportError: cannot import name 'create_pandas_dataframe_agent' from 'langchain_experimental.agents' (/Users/dongwm/test/venv/lib/python3.11/site-packages/langchain_experimental/agents/__init__.py)
```
I should use `from langchain_experimental.agents.agent_toolkits import
create_pandas_dataframe_agent`. In order to solve the problem and make
it compatible, I added additional import code to the
langchain_experimental package. Now it can be like this Used `from
langchain_experimental.agents import create_pandas_dataframe_agent`
- **Twitter handle:** [lin_bob57617](https://twitter.com/lin_bob57617)
2023-11-27 22:03:47 +00:00
|
|
|
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",
|
|
|
|
]
|