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
20.9k stars 2.9k forks source link

[BUG] Changing the LLM using name as per example #1330

Closed TzurV closed 2 weeks ago

TzurV commented 1 month ago

Description

Example in https://docs.crewai.com/how-to/LLM-Connections/#changing-the-llm fails

from crewai import Agent

Using OpenAI's GPT-4

openai_agent = Agent( role='OpenAI Expert', goal='Provide insights using GPT-4', backstory="An AI assistant powered by OpenAI's latest model.", llm='gpt-4' )

with the error: File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agents\agent_builder\base_agent.py", line 253, in set_cache_handler self.create_agent_executor() File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agent.py", line 302, in create_agent_executor bind = self.llm.bind(stop=stop_words) ^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'bind'. Did you mean: 'find'?

Steps to Reproduce

simple code example taken from https://docs.crewai.com/how-to/LLM-Connections/#changing-the-llm

Expected behavior

Agent creation successfully.

Screenshots/Code snippets

openai_agent = Agent(
               ^^^^^^

File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agent.py", line 118, in init super().init(config, data) File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agents\agent_builder\base_agent.py", line 133, in init super().init(config, data) File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\pydantic\main.py", line 211, in init validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agent.py", line 147, in set_agent_executor self.set_cache_handler(self.cache_handler) File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agents\agent_builder\base_agent.py", line 253, in set_cache_handler self.create_agent_executor() File "C:\Users\tzurv\AppData\Local\pypoetry\Cache\virtualenvs\hiregenieproject-hx_BYHb5-py3.11\Lib\site-packages\crewai\agent.py", line 302, in create_agent_executor bind = self.llm.bind(stop=stop_words) ^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'bind'. Did you mean: 'find'?

Operating System

Windows 11

Python Version

3.11

crewAI Version

0.51.1

crewAI Tools Version

0.12.0

Virtual Environment

Poetry

Evidence

poetry show crewai name : crewai

version : 0.51.1

description : Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

dependencies

Possible Solution

NA

Additional context

NA

TzurV commented 1 month ago

It looks like this is supported in version 0.60.0

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for 5 days with no activity.