AI4Finance-Foundation / FinRobot

FinRobot: An Open-Source AI Agent Platform for Financial Analysis using LLMs πŸš€ πŸš€ πŸš€
https://ai4finance.org
Apache License 2.0
1.63k stars 252 forks source link

ImportError: Cannot import name 'register_function' from 'autogen' in workflow.py #8

Closed sm18lr88 closed 5 months ago

sm18lr88 commented 5 months ago

Description: I encountered an ImportError when running the agent_annual_report.ipynb notebook. The error occurs in the workflow.py file while attempting to import register_function from the autogen package.

Error Message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], [line 5](vscode-notebook-cell:?execution_count=2&line=5)
      [3](vscode-notebook-cell:?execution_count=2&line=3) from textwrap import dedent
      [4](vscode-notebook-cell:?execution_count=2&line=4) from finrobot.utils import register_keys_from_json
----> [5](vscode-notebook-cell:?execution_count=2&line=5) from finrobot.agents.workflow import SingleAssistantShadow

File e:\documents\projects\apps\financial\finrobot\finrobot\agents\workflow.py:6
      [3](file:///E:/documents/projects/apps/financial/finrobot/finrobot/agents/workflow.py:3) import autogen
      [4](file:///E:/documents/projects/apps/financial/finrobot/finrobot/agents/workflow.py:4) from autogen.cache import Cache
----> [6](file:///E:/documents/projects/apps/financial/finrobot/finrobot/agents/workflow.py:6) from ..toolkits import register_toolkits
      [7](file:///E:/documents/projects/apps/financial/finrobot/finrobot/agents/workflow.py:7) from .utils import *
     [10](file:///E:/documents/projects/apps/financial/finrobot/finrobot/agents/workflow.py:10) class FinRobot(autogen.AssistantAgent):

File e:\documents\projects\apps\financial\finrobot\finrobot\toolkits.py:1
----> [1](file:///E:/documents/projects/apps/financial/finrobot/finrobot/toolkits.py:1) from autogen import register_function, ConversableAgent
      [2](file:///E:/documents/projects/apps/financial/finrobot/finrobot/toolkits.py:2) from .data_source import *
      [3](file:///E:/documents/projects/apps/financial/finrobot/finrobot/toolkits.py:3) from .functional.coding import CodingUtils

ImportError: cannot import name 'register_function' from 'autogen' (c:\Users\Admin\miniconda3\envs\finrobot\lib\site-packages\autogen\__init__.py)

Steps to Reproduce:

  1. Clone the repository.
  2. Follow the installation steps and configure API keys.
  3. Open agent_annual_report.ipynb notebook.
  4. Run the initial cell to import necessary packages and functions.

Environment:

Expected Behavior: Successful import of register_function from the autogen package without any errors.

Actual Behavior: The import statement fails, raising an ImportError.

Relevant Code:

from ..toolkits import register_toolkits

Thanks

Noir97 commented 5 months ago

Make sure you have pyautogen installed. pip list | grep autogen and verify your installation.

If it's properly installed, can you provide the version of pyautogen you're using

sm18lr88 commented 5 months ago

Thanks. I recreated the conda environment, reinstalled all the requirements, and it then worked.

Something mist have happened to my original environment.

Sorry for my error.