mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 21:08:59 +00:00
experimental[minor]: add support for modin in pandas agent (#18749)
Added support for Intel's [modin](https://github.com/modin-project/modin) in `create_pandas_dataframe_agent`.
This commit is contained in:
parent
4bfe888717
commit
3b975c6ebe
@ -162,6 +162,7 @@ def create_pandas_dataframe_agent(
|
||||
include_df_in_prompt: Optional[bool] = True,
|
||||
number_of_head_rows: int = 5,
|
||||
extra_tools: Sequence[BaseTool] = (),
|
||||
engine: Literal["pandas", "modin"] = "pandas",
|
||||
**kwargs: Any,
|
||||
) -> AgentExecutor:
|
||||
"""Construct a Pandas agent from an LLM and dataframe(s).
|
||||
@ -189,6 +190,7 @@ def create_pandas_dataframe_agent(
|
||||
number_of_head_rows: Number of initial rows to include in prompt if
|
||||
include_df_in_prompt is True.
|
||||
extra_tools: Additional tools to give to agent on top of a PythonAstREPLTool.
|
||||
engine: One of "modin" or "pandas". Defaults to "pandas".
|
||||
**kwargs: DEPRECATED. Not used, kept for backwards compatibility.
|
||||
|
||||
Returns:
|
||||
@ -213,10 +215,17 @@ def create_pandas_dataframe_agent(
|
||||
|
||||
""" # noqa: E501
|
||||
try:
|
||||
if engine == "modin":
|
||||
import modin.pandas as pd
|
||||
elif engine == "pandas":
|
||||
import pandas as pd
|
||||
else:
|
||||
raise ValueError(
|
||||
f"Unsupported engine {engine}. It must be one of 'modin' or 'pandas'."
|
||||
)
|
||||
except ImportError as e:
|
||||
raise ImportError(
|
||||
"pandas package not found, please install with `pip install pandas`"
|
||||
f"`{engine}` package not found, please install with `pip install {engine}`"
|
||||
) from e
|
||||
|
||||
if is_interactive_env():
|
||||
|
Loading…
Reference in New Issue
Block a user