Open
Description
I get the following error when I try to pass df to a tool.
This cell raised an exception: PydanticUserError('`filter_dataset` is not fully defined; you should define `pl`, then call `filter_dataset.model_rebuild()`.
For further information visit https://errors.pydantic.dev/2.10/u/class-not-fully-defined')
import polars as pl
import ell
Code:
@ell.tool()
def filter_dataset(df: pl.DataFrame, sql_query: str):
"""
Filter a polars dataframe using SQL. Please only use fields from the schema.
"""
return df.sql(sql_query, table_name="data")
@ell.complex(
model="deepseek-chat",
client=deepseek_client,
tools=[chart_data, filter_dataset],
)
def analyze_dataset(df: pl.DataFrame, prompt: str):
"""You are a data scientist that can analyze a dataset"""
return f"""I have a dataset with schema: {df.schema}.\n These are the first 5 rows: {df.head()}.\n {prompt}"""
analyze_dataset(df, 'What is the min and median of petal length?')
I face the same issue with pandas dataframes, how do I resolve this?
Metadata
Metadata
Assignees
Labels
No labels