Issues when declaring Agent with groq llm 2024-10-19 07:15:41,125 - 8140583488 - llm.py-llm:178 - ERROR: Failed to get supported params: argument of type 'NoneType' is not iterable

i am learning CrewAI and hitting error when using Groq. I am using jupyter notebook OpenAI works fine.

!pip install crewai crewai_tools langchain_community langchain-groq

Name: crewai
Version: 0.74.2


from langchain_groq import ChatGroq
import os

os.environ['GROQ_API_KEY'] = 'gsk_'
groq_api_key = os.environ.get('GROQ_API_KEY')


groq_llm = ChatGroq(
    model="llama3-70b-8192",
    groq_api_key = groq_api_key,
    temperature=0.3,
    max_tokens=4096
)
test_response = groq_llm.invoke("how are you")
print(test_response)

content=‘I'm just a language model, I don't have feelings or emotions like humans do, so I don't have good or bad days. I'm always “on” and ready to assist you with any questions or tasks you may have!\n\nThat being said, I'm functioning properly and ready to help you with anything you need. How can I assist you today?’ additional_kwargs={} response_metadata={‘token_usage’: {‘completion_tokens’: 74, ‘prompt_tokens’: 13, ‘total_tokens’: 87, ‘completion_time’: 0.238306954, ‘prompt_time’: 0.000474925, ‘queue_time’: 0.014973195, ‘total_time’: 0.238781879}, ‘model_name’: ‘llama3-70b-8192’, ‘system_fingerprint’: ‘fp_87cbfbbc4d’, ‘finish_reason’: ‘stop’, ‘logprobs’: None} id=‘run-cc14f685-8170-46ef-a083-47c5fb4b856d-0’ usage_metadata={‘input_tokens’: 13, ‘output_tokens’: 74, ‘total_tokens’: 87}

writer = Agent(
    role="Content Writer",
    goal="Write insightful and factually accurate "
         "opinion piece about the topic: {topic}",
    backstory="You're working on a writing "
              "a new opinion piece about the topic: {topic}. "
              "You base your writing on the work of "
              "the Content Planner, who provides an outline "
              "and relevant context about the topic. "
              "You follow the main objectives and "
              "direction of the outline, "
              "as provide by the Content Planner. "
              "You also provide objective and impartial insights "
              "and back them up with information "
              "provide by the Content Planner. "
              "You acknowledge in your opinion piece "
              "when your statements are opinions "
              "as opposed to objective statements.",
    allow_delegation=False,
    verbose=True,
    llm=groq_llm
)

2024-10-19 07:15:41,125 - 8140583488 - llm.py-llm:178 - ERROR: Failed to get supported params: argument of type ‘NoneType’ is not iterable

You dont need to use Langchain constructors anymore as we now use LiteLLM

Also I woudl recommend you rebuild your crew with the CLI command crewai create crew

Thank you @matt . Resolved.

import os
from crewai import LLM
groq_llm = LLM(
    model="groq/llama3-8b-8192",
    temperature=0.3,
    max_tokens=4096,
    api_key="gsk_",
    base_url="https://api.groq.com/openai/v1"
)

The langchain class showed me proper nightmare. Thanks a ton Vishal. Really a life saver.