My .env is updated with my proper keys, I even tried setting up specific calls to it in the python code.
When I run the code it still tells me the OpenAI api key isn’t found, I can’t find anywhere in the code that points to OpenAI, so I assume it’s part of the poetry stuff, but as i’m not a coder and have only been using LLMs to put this stuff together I have no idea what to try next to.
There is this commented section in the ‘def run’ function, is this where I need to put the Groq info? “# Replace with your inputs, it will automatically interpolate any tasks and agents information”
Sorry for what I think is probably a dumb question, Claude and GPT-4o haven’t been helpful in trying to work this out.
Other than the prompt to fit my usecase, and adding my api key for groq instead of openAI, no I haven’t I don’t think (i’m sorry i’m at work and my code is at home lol)
This is one way you can customize/configure the LLM you’re using; in this case, Groq:
from typing import List
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
# Uncomment the following line to use an example of a custom tool
# from marketing_posts.tools.custom_tool import MyCustomTool
# Check our tools documentations for more information on how to use them
from crewai_tools import SerperDevTool, ScrapeWebsiteTool
from pydantic import BaseModel, Field
# Import ChatGroq
from langchain_groq import ChatGroq
... # Keep the code in this section the same
@CrewBase
class MarketingPostsCrew():
"""MarketingPosts crew"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
def __init__(self):
# Groq LLM
self.groq_llm = ChatGroq(
temperature=0.5,
groq_api_key=os.environ.get("GROQ_API_KEY"),
model_name="<MODEL-NAME>",
)
... # The rest of the code
Make sure you add the API key to the .env file then all you have to do is add the llm=self.groq_llm to each agent.
Thank you, im sorry for wasting your time with something so trivial. I have only ever used the ‘crewai create’ functions for my crews in various projects and worked it out with LLMs to get them working. This was the first time trying to use one that was already made.