Skip to content

bug: Error while attempting to execute docs/examples/agent-quickstart.py example through jupyter #283

@HanXM715

Description

@HanXM715

Initial Checklist

What happened?

Cell execution is as follows:

tc = TimeCopilot(
llm="deepseek:deepseek-chat",
retries=3,
)
result = tc.forecast(df=df)

Relevant log output

1it [00:00, 41.83it/s]
1it [00:00,  7.17it/s]
1it [00:00, 21.02it/s]
1it [00:00, 114.55it/s]
0it [00:00, ?it/s]13:29:22 - cmdstanpy - INFO - Chain [1] start processing
13:29:22 - cmdstanpy - INFO - Chain [1] done processing
1it [00:04,  4.35s/it]
Traceback (most recent call last):
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3701, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/var/folders/mg/q3vhppd56nv4rzh95jtf6vnr0000gn/T/ipykernel_52769/3262167489.py", line 1, in <module>
    result = tc.forecast(df=df)
             ^^^^^^^^^^^^^^^^^^
  File "/Users/xiaoming/Desktop/code/timecopilot-0.0.22/timecopilot/agent.py", line 1255, in forecast
    return self.analyze(df=df, h=h, freq=freq, seasonality=seasonality, query=query)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xiaoming/Desktop/code/timecopilot-0.0.22/timecopilot/agent.py", line 1202, in analyze
    result = self.forecasting_agent.run_sync(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/agent/abstract.py", line 372, in run_sync
    return _utils.get_event_loop().run_until_complete(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/nest_asyncio.py", line 98, in run_until_complete
    return f.result()
           ^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/asyncio/futures.py", line 203, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/asyncio/tasks.py", line 304, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/agent/abstract.py", line 251, in run
    async with self.iter(
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/contextlib.py", line 222, in __aexit__
    await self.gen.athrow(value)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/agent/__init__.py", line 678, in iter
    async with graph.iter(
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/contextlib.py", line 222, in __aexit__
    await self.gen.athrow(value)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_graph/beta/graph.py", line 270, in iter
    async with GraphRun[StateT, DepsT, OutputT](
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_graph/beta/graph.py", line 423, in __aexit__
    await self._async_exit_stack.__aexit__(exc_type, exc_val, exc_tb)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/contextlib.py", line 742, in __aexit__
    raise exc_details[1]
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/contextlib.py", line 723, in __aexit__
    cb_suppress = cb(*exc_details)
                  ^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_graph/beta/graph.py", line 981, in _unwrap_exception_groups
    raise exception
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/asyncio/tasks.py", line 304, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_graph/beta/graph.py", line 750, in _run_tracked_task
    result = await self._run_task(t_)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_graph/beta/graph.py", line 782, in _run_task
    output = await node.call(step_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_graph/beta/step.py", line 253, in _call_node
    return await node.run(GraphRunContext(state=ctx.state, deps=ctx.deps))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 575, in run
    async with self.stream(ctx):
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/contextlib.py", line 211, in __aexit__
    await anext(self.gen)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 589, in stream
    async for _event in stream:
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 715, in _run_stream
    async for event in self._events_iterator:
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 676, in _run_stream
    async for event in self._handle_tool_calls(ctx, tool_calls):
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 731, in _handle_tool_calls
    async for event in process_tool_calls(
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 974, in process_tool_calls
    async for event in _call_tools(
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 1110, in _call_tools
    if event := await handle_call_or_result(coro_or_task=task, index=index):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 1073, in handle_call_or_result
    (await coro_or_task) if inspect.isawaitable(coro_or_task) else coro_or_task.result()
     ^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/asyncio/futures.py", line 290, in __await__
    return self.result()  # May raise too.
           ^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/asyncio/futures.py", line 203, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/asyncio/tasks.py", line 304, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py", line 1146, in _call_tool
    tool_result = await tool_manager.handle_call(tool_call)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_tool_manager.py", line 119, in handle_call
    return await self._call_function_tool(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_tool_manager.py", line 252, in _call_function_tool
    tool_result = await self._call_tool(
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_tool_manager.py", line 175, in _call_tool
    return await self.toolset.call_tool(name, args_dict, ctx, tool)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/toolsets/combined.py", line 90, in call_tool
    return await tool.source_toolset.call_tool(name, tool_args, ctx, tool.source_tool)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/toolsets/combined.py", line 90, in call_tool
    return await tool.source_toolset.call_tool(name, tool_args, ctx, tool.source_tool)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/toolsets/function.py", line 383, in call_tool
    return await tool.call_func(tool_args, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/pydantic_ai/_function_schema.py", line 52, in call
    return await function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xiaoming/Desktop/code/timecopilot-0.0.22/timecopilot/agent.py", line 949, in cross_validation_tool
    eval_df = ctx.deps.evaluate_forecast_df(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xiaoming/Desktop/code/timecopilot-0.0.22/timecopilot/utils/experiment_handler.py", line 242, in evaluate_forecast_df
    query: str | None,
              ^^^^^^^^
  File "/opt/miniconda3/envs/timecopilot/lib/python3.12/site-packages/utilsforecast/evaluation.py", line 314, in evaluate
    result = metric(**kwargs)
             ^^^^^^^^^^^^^^^^
TypeError: mase() got an unexpected keyword argument 'cutoff_col'

Environment

versions:0.0.22
python:3.12.0
system:MacOS(arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions