theg8
September 20, 2024, 7:58am
1
import os
from dotenv import load_dotenv
load_dotenv()
os.environ[“OPENAI_API_KEY”] = os.getenv(“OPENAI_API_KEY”)
os.environ[“temperature”] = “0.0”
os.environ[“top_p”] = “0.1”
In the agent settings, set llm = ‘gpt-4o-mini-2024-07-18’
Is this setup correct for the API key and parameters like temperature and top_p?
matt
September 20, 2024, 11:19am
2
Im still looking into whats the correct way, please bare with
1 Like
theg8
September 20, 2024, 11:28am
3
Oh okay, wait for the good news. Thank you so much. I will stick with the older version of Crewai for setting parameters for a while.
moto
September 20, 2024, 6:51pm
4
this seems to work for gemini but you have to install google.generativeai and I am going to try the same with openai.
self.gemini_flash = genai.GenerativeModel(model_name=“gemini/gemini-1.5-flash”, generation_config = genai.GenerationConfig(max_output_tokens=8000,temperature=0.3))
1 Like
moto
September 21, 2024, 12:53am
5
I think there is a way to do this by editing the LiteLLM yaml files but not sure about the conditions to do it. anyone a LiteLLM expert here. this is getting crazy.
matt
September 24, 2024, 2:41am
6
Upgrade to latest version 0.61.3
then you can do this
llm = LLM(
model="gpt-4",
temperature=0.8,
max_tokens=150,
top_p=0.9,
frequency_penalty=0.1,
presence_penalty=0.1,
stop=["END"],
seed=42,
base_url="https://api.openai.com/v1",
api_key="your-api-key-here"
)
agent = Agent(llm=llm, ...)
Obviously change base url, api and model to your needs
And remove what ever parameters you do not need
Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
moto
September 24, 2024, 5:59am
7
@matt this seems to work fine other than for gemini models.
matt
September 24, 2024, 8:14am
8
Just tested and works fine for me, whats the issue?
moto
September 24, 2024, 3:08pm
9
Sorry. It was my mistake.
theg8
September 24, 2024, 4:13pm
10
May I ask, as I’m a bit confused, whether base_url
is optional or required in the following code?
from dotenv import load_dotenv
import os
from crewai import LLM
load_dotenv()
gpt4omini = LLM(
model=“gpt-4o-mini-2024-07-18”,
temperature=0.0,
top_p=0.1,
api_key=os.getenv(“OPENAI_API_KEY”)
)
Thank you so much for your help.
matt
September 24, 2024, 4:24pm
11
You do not need to set it for OpenAI, you only need to set your API key
system
Closed
September 25, 2024, 4:57pm
13
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.