crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
18.33k stars 2.52k forks source link

AttributeError: 'Client' object has no attribute 'llm_tracker' #904

Open rmico77 opened 1 month ago

rmico77 commented 1 month ago

>>> from crewai import Agent, Task, Crew, Process
>>> from crewai_tools import PDFSearchTool
>>>
>>> from langchain_openai import ChatOpenAI
>>> from langchain_groq import ChatGroq
>>>
>>> GROQ_API_KEY = ""
>>> os.environ["GROQ_API_KEY"] = GROQ_API_KEY
>>>
>>> OPENAI_API_KEY = ""
>>> os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
>>>
>>> # Criando as LLMs
>>> llama8=ChatGroq(model_name="llama3-8b-8192", api_key=GROQ_API_KEY)
>>> llama70=ChatGroq(model_name="llama3-70b-8192", api_key=GROQ_API_KEY)
>>> gpt3=ChatOpenAI(model="gpt-3.5-turbo", api_key=OPENAI_API_KEY)
>>>
>>>
>>> # Ferramenta de busca em PDF
>>> search_tool = PDFSearchTool(pdf=r'C:\Users\rmico\Desktop\CrewAI\Gilbert_Developmental_Biology_2019.pdf')
>>>
>>> # Agente de Leitura
>>> leitor = Agent(
...     role='Leitor Acadêmico',
...     goal='Extrair informações específicas do livro acadêmico em PDF',
...     backstory="Você é um leitor experiente em textos acadêmicos.",
...     tools=[search_tool],
...     verbose=True,
...     allow_delegation=False
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\agentops\agent.py", line 29, in new_init
    raise e
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\agentops\agent.py", line 19, in new_init
    original_init(self, *args, **kwargs)
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\crewai\agent.py", line 102, in __init__    super().__init__(**config, **data)
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\crewai\agents\agent_builder\base_agent.py", line 128, in __init__
    super().__init__(**config, **data)
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydantic\main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\crewai\agent.py", line 125, in set_agent_executor
    agentops.stop_instrumenting()
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\agentops\__init__.py", line 201, in stop_instrumenting
    Client().stop_instrumenting()
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\agentops\meta_client.py", line 61, in wrapper
    raise e
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\agentops\meta_client.py", line 53, in wrapper
    return method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rmico\AppData\Local\Programs\Python\Python312\Lib\site-packages\agentops\client.py", line 532, in stop_instrumenting
    if self.llm_tracker:
       ^^^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'llm_tracker'```
theCyberTech commented 1 month ago

What version of CrewAI are you using?

rmico77 commented 1 month ago

What version of CrewAI are you using?

the last one ( v0.36.0 ). I noticed this error after new updates..

rmico77 commented 1 month ago

Interestingly, I installed v0.35.0 and it apparently returned to normal...

tomaszzdanowicz commented 1 month ago

Also encountering it in 0.36.0 release. Verbose output below:

================================================================================================================================================================================================================================= test session starts =================================================================================================================================================================================================================================
platform darwin -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0 -- /Users/datadir/Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/bin/python
cachedir: .pytest_cache
rootdir: /Users/datadir/dev/python/workflows
configfile: pyproject.toml
testpaths: tests, src/crewai
plugins: vcr-1.0.2, anyio-4.4.0
collected 80 items / 2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                         

======================================================================================================================================================================================================================================= ERRORS ========================================================================================================================================================================================================================================
__________________________________________________________________________________________________________________________________________________________________________________________________________ ERROR collecting src/crewai/tests/agent_tools/agent_tools_test.py __________________________________________________________________________________________________________________________________________________________________________________________________________
src/crewai/tests/agent_tools/agent_tools_test.py:8: in <module>
    researcher = Agent(
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/agent.py:25: in new_init
    raise e
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/agent.py:19: in new_init
    original_init(self, *args, **kwargs)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/agent.py:102: in __init__
    super().__init__(**config, **data)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/agents/agent_builder/base_agent.py:128: in __init__
    super().__init__(**config, **data)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/agent.py:125: in set_agent_executor
    agentops.stop_instrumenting()
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/__init__.py:144: in stop_instrumenting
    Client().stop_instrumenting()
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/meta_client.py:56: in wrapper
    raise e
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/meta_client.py:49: in wrapper
    return method(self, *args, **kwargs)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/client.py:425: in stop_instrumenting
    if self.llm_tracker:
E   AttributeError: 'Client' object has no attribute 'llm_tracker'
___________________________________________________________________________________________________________________________________________________________________________________________________________________ ERROR collecting src/crewai/tests/crew_test.py ____________________________________________________________________________________________________________________________________________________________________________________________________________________
src/crewai/tests/crew_test.py:18: in <module>
    ceo = Agent(
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/agent.py:25: in new_init
    raise e
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/agent.py:19: in new_init
    original_init(self, *args, **kwargs)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/agent.py:102: in __init__
    super().__init__(**config, **data)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/agents/agent_builder/base_agent.py:128: in __init__
    super().__init__(**config, **data)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/agent.py:125: in set_agent_executor
    agentops.stop_instrumenting()
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/__init__.py:144: in stop_instrumenting
    Client().stop_instrumenting()
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/meta_client.py:56: in wrapper
    raise e
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/meta_client.py:49: in wrapper
    return method(self, *args, **kwargs)
../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/agentops/client.py:425: in stop_instrumenting
    if self.llm_tracker:
E   AttributeError: 'Client' object has no attribute 'llm_tracker'
================================================================================================================================================================================================================================== warnings summary ===================================================================================================================================================================================================================================
<frozen importlib._bootstrap>:488
  <frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

<frozen importlib._bootstrap>:488
  <frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/telemetry/telemetry.py:9
  /Users/datadir/Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/crewai/telemetry/telemetry.py:9: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pkg_resources/__init__.py:3117
  /Users/datadir/Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pkg_resources/__init__.py:3117: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pkg_resources/__init__.py:3117
  /Users/datadir/Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pkg_resources/__init__.py:3117: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.cloud')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pkg_resources/__init__.py:2529
  /Users/datadir/Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pkg_resources/__init__.py:2529: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(parent)

../../../Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pydantic/_internal/_config.py:291
  /Users/datadir/Library/Caches/pypoetry/virtualenvs/workflows-jbmX4TMD-py3.12/lib/python3.12/site-packages/pydantic/_internal/_config.py:291: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================================================================================================================================================================================== short test summary info ===============================================================================================================================================================================================================================
ERROR src/crewai/tests/agent_tools/agent_tools_test.py - AttributeError: 'Client' object has no attribute 'llm_tracker'
ERROR src/crewai/tests/crew_test.py - AttributeError: 'Client' object has no attribute 'llm_tracker'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================================================================================================================================ 7 warnings, 2 errors in 3.30s ============================================================================================================================================================================================================================
AbubakrChan commented 1 month ago

any update on this one?

dav-mf commented 1 month ago

same problem here

AbubakrChan commented 1 month ago

@dav-mf downgrading back to v0.35.0 worked for me

azdolinski commented 4 weeks ago

v0.36.0:

Adding AgentOps native support

try to add env AGENTOPS_API_KEY --or-- uninstall crewai[agentops] if you not using that.. for test - you can set even some dummy value like '0' for AGENTOPS_API_KEY and that should prevent this error.

dav-mf commented 4 weeks ago

@AbubakrChan This worked for me. Thanks I was also getting crashes from Agentops. @azdolinski What does native support involve?

rmico77 commented 3 weeks ago

I tested it in the new v0.41.1 and the problem returned. What happened after v0.35.8 ? @joaomdmoura

tomaszzdanowicz commented 3 weeks ago

I tested it in the new v0.41.1 and the problem returned. What happened after v0.35.8 ? @joaomdmoura

As @azdolinski said earlier. In v0.36.0+ AgentOps native support has been added. If you are not using AgentOps then you should remove agentops from project.

C4RR13P0TT3R commented 3 weeks ago

Is there currently a valid combination of agentops and crewai that can be used without an error? I have tried several combinations and none of them worked - with the most recent versions throwing

AttributeError: 'Client' object has no attribute 'llm_tracker'

and older versions throwing:

File "/usr/local/lib/python3.11/site-packages/crewai/agents/executor.py", line 135, in _iter_next_step \n output = self.agent.plan( # type: ignore # Incompatible types in assignment (expression has type "AgentAction | AgentFinish | list[AgentAction]", variable has type "AgentAction")

andkoma commented 3 weeks ago

Try to activate your prepared environment, remove the agentops module, deactivate and start again

source ./venv/bin/activate pip uninstall agentops -Y deactivate ./run_venv.sh

In my case, this fixes for the moment the kickoff without agentops support in crewai-studio. Happy weekend.