Connecting claude llm

Traceback (most recent call last):
  File "/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 100, in get_llm_provider
    if model.split("/", 1)[0] == "azure":
       ^^^^^^^^^^^
AttributeError: 'ChatAnthropic' object has no attribute 'split'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py", line 974, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py", line 2847, in completion
    raise exception_type(
  File "/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py", line 838, in completion
    model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(`Preformatted text`

any advice on how to connect to claude LLM to all my agents? i tried langchain_anthropic but i’m getting incompatibility on langchain version used by crewai…

this error was reproduced by using crewai 0.61.0 and langchain_anthropic 0.1.21

how are you setting up your llm

i tried two ways:

from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(
    model="claude-3-5-sonnet-20240620",
    temperature=0.7,
    max_tokens=1024,
    timeout=None,
    max_retries=2,
)

and

from langchain.chat_models import ChatAnthropic

llm = ChatAnthropic(
    model="claude-3-5-sonnet-20240620",
    temperature=0.7,
    max_tokens=1024,
    timeout=None,
    max_retries=2,
)

FYI, this is the langtrace stack error:

  • exception.type"litellm.exceptions.BadRequestError"
  • exception.message"litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr(‘**********’) HUMAN_PROMPT=‘\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>>"
  • exception.stacktrace"Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 100, in get_llm_provider if model.split(“/”, 1)[0] == “azure”: ^^^^^^^^^^^ AttributeError: ‘ChatAnthropic’ object has no attribute ‘split’ During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 974, in wrapper result = original_function(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2847, in completion raise exception_type( File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 838, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 510, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr('‘) HUMAN_PROMPT=’\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>> During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agent.py”, line 182, in execute_task result = self.agent_executor.invoke( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 89, in invoke formatted_answer = self._invoke_loop() ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 162, in _invoke_loop raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 111, in _invoke_loop ).call(self.messages) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/llm.py”, line 13, in call response = completion( ^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 1061, in wrapper return litellm.completion_with_retries(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2880, in completion_with_retries return retryer(original_function, args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 418, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 185, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py”, line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py”, line 401, in __get_result raise self._exception File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 478, in call result = fn(args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 1086, in wrapper raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 974, in wrapper result = original_function(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2847, in completion raise exception_type( File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 838, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 510, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr('‘) HUMAN_PROMPT=’\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>> During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 100, in get_llm_provider if model.split(“/”, 1)[0] == “azure”: ^^^^^^^^^^^ AttributeError: ‘ChatAnthropic’ object has no attribute ‘split’ During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 974, in wrapper result = original_function(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2847, in completion raise exception_type( File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 838, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 510, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr('‘) HUMAN_PROMPT=’\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>> During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agent.py”, line 182, in execute_task result = self.agent_executor.invoke( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 89, in invoke formatted_answer = self._invoke_loop() ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 162, in _invoke_loop raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 111, in _invoke_loop ).call(self.messages) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/llm.py”, line 13, in call response = completion( ^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 1061, in wrapper return litellm.completion_with_retries(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2880, in completion_with_retries return retryer(original_function, args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 418, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 185, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py”, line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py”, line 401, in __get_result raise self._exception File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 478, in call result = fn(args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 1086, in wrapper raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 974, in wrapper result = original_function(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2847, in completion raise exception_type( File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 838, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 510, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr('‘) HUMAN_PROMPT=’\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>> During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 100, in get_llm_provider if model.split(“/”, 1)[0] == “azure”: ^^^^^^^^^^^ AttributeError: ‘ChatAnthropic’ object has no attribute ‘split’ During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 974, in wrapper result = original_function(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2847, in completion raise exception_type( File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 838, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 510, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr('*******‘) HUMAN_PROMPT=’\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>> During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/langtrace_python_sdk/instrumentation/crewai/patch.py”, line 91, in traced_method result = wrapped(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/task.py”, line 191, in execute_sync return self._execute_core(agent, context, tools) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/task.py”, line 247, in _execute_core result = agent.execute_task( ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/langtrace_python_sdk/instrumentation/crewai/patch.py”, line 91, in traced_method result = wrapped(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agent.py”, line 194, in execute_task result = self.execute_task(task, context, tools) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/langtrace_python_sdk/instrumentation/crewai/patch.py”, line 91, in traced_method result = wrapped(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agent.py”, line 194, in execute_task result = self.execute_task(task, context, tools) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/langtrace_python_sdk/instrumentation/crewai/patch.py”, line 91, in traced_method result = wrapped(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agent.py”, line 193, in execute_task raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agent.py”, line 182, in execute_task result = self.agent_executor.invoke( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 89, in invoke formatted_answer = self._invoke_loop() ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 162, in _invoke_loop raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/agents/crew_agent_executor.py”, line 111, in _invoke_loop ).call(self.messages) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/crewai/llm.py”, line 13, in call response = completion( ^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 1061, in wrapper return litellm.completion_with_retries(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2880, in completion_with_retries return retryer(original_function, args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 418, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 185, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py”, line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py”, line 401, in __get_result raise self._exception File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/tenacity/init.py”, line 478, in call result = fn(args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 1086, in wrapper raise e File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/utils.py”, line 974, in wrapper result = original_function(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 2847, in completion raise exception_type( File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/main.py”, line 838, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File “/Users/justincheu/Library/Caches/pypoetry/virtualenvs/white-paper-UmevmK66-py3.12/lib/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py”, line 510, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - ‘ChatAnthropic’ object has no attribute ‘split’ original model: client=<anthropic.Anthropic object at 0x14f3b1820> async_client=<anthropic.AsyncAnthropic object at 0x14f61c770> model=‘claude-3-5-sonnet-20240620’ anthropic_api_url=‘https://api.anthropic.com’ anthropic_api_key=SecretStr('‘) HUMAN_PROMPT=’\n\nHuman:’ AI_PROMPT=‘\n\nAssistant:’ count_tokens=<bound method Anthropic.count_tokens of <anthropic.Anthropic object at 0x14f3b1820>> "

I solved by:

from langchain_anthropic import ChatAnthropic Claude35 = ChatAnthropic(model="claude-3-5-sonnet-20240620", max_tokens=4000)

You dont need langchain anymore you just need as we now use LiteLLM

llm='claude-3-5-sonnet-20240620'

and just set your API key as normal (env or os.environ)

1 Like

Yes, you are right. I wrote the above post by mistake. This is the implementation:

from crewai import LLM

claude_llm = LLM( model="claude-3-5-sonnet-20240620", base_url="https://api.anthropic.com", max_tokens=4000, api_key=os.environ["ANTHROPIC_API_KEY"] )

1 Like

Could you please take a look at this:

Thank you Matt!

You don’t need to set the base url with anthropic, can you try without that set

1 Like

No problem now! Thank you.