[Python] Issue: ImportError in Python when using the phi library

Discussão em 'Python' iniciado por Stack, Janeiro 4, 2025.

  1. Stack

    Stack Membro Participativo

    Issue: ImportError in Python when using the phi library

    After running the following code, I encounter the following ImportError. How can I fix it?

    from os import getenv
    from phi.agent import Agent
    from phi.model.openai import OpenAIChat
    from phi.tools.duckduckgo import DuckDuckGo

    agent = Agent(model=OpenAIChat(id="gpt-4o", base_url="http://127.0.0.1:10000/v1", api_key=getenv("OPENAI_API_KEY")), tools=[DuckDuckGo()], markdown=True)
    agent.print_response("What's happening in France?", stream=True)`


    Error:

    ImportError Traceback (most recent call last)
    Cell In[2], line 2
    1 from os import getenv
    ----> 2 from phi.agent import Agent
    3 from phi.model.openai import OpenAIChat
    4 from phi.tools.duckduckgo import DuckDuckGo

    File ~\AppData\Local\anaconda3\envs\langchain_env\lib\site-packages\phi\__init__.py:8
    4 from __future__ import unicode_literals
    7 from . import utils
    ----> 8 from . import builder
    9 from . import dsl
    11 from .utils import identity

    File ~\AppData\Local\anaconda3\envs\langchain_env\lib\site-packages\phi\builder.py:18
    16 import inspect
    17 from . import utils
    ---> 18 from .utils import identity
    19 import functools
    20 from . import dsl

    ImportError: cannot import name 'identity' from 'phi.utils'



    Steps I have taken: I have installed the phi library via pip and ensured all dependencies are up to date. The error persists when trying to import the identity function from phi.utils. Can someone guide me on how to resolve this issue?

    Continue reading...

Compartilhe esta Página