Closed adilazmoon closed 1 month ago
Hi @adilazmoon Could you please send me your crew so I can dig into it, obviously redact anything sensitive
@adilazmoon good catch, it was not intentional it seems there is a bug, we are patching it now
@adilazmoon , spent the day today working on a new LLM
class that will be introduced in the next version to address all the concerns in this issue, open for feedback before we cut the version.
New docs, still not live: (https://github.com/crewAIInc/crewAI/blob/main/docs/core-concepts/LLMs.md) Some high level description bellow:
By default, crewAI uses the gpt-4o-mini
model.
It uses environment variables if no LLM is specified:
OPENAI_MODEL_NAME
(defaults to "gpt-4o-mini" if not set)OPENAI_API_BASE
OPENAI_API_KEY
Aiming at simplicity and supporting who update to version 0.61.0
agent = Agent(llm="gpt-4o", ...)
List of more providers.
from crewai import LLM
llm = LLM(model="gpt-4", temperature=0.7)
agent = Agent(llm=llm, ...)
This new LLM class allow you to use an big array of attributes.
Parameter | Type | Description |
---|---|---|
model |
str | The name of the model to use (e.g., "gpt-4", "gpt-3.5-turbo", "ollama/llama3.1", more providers) |
timeout |
float, int | Maximum time (in seconds) to wait for a response |
temperature |
float | Controls randomness in output (0.0 to 1.0) |
top_p |
float | Controls diversity of output (0.0 to 1.0) |
n |
int | Number of completions to generate |
stop |
str, List[str] | Sequence(s) to stop generation |
max_tokens |
int | Maximum number of tokens to generate |
presence_penalty |
float | Penalizes new tokens based on their presence in the text so far |
frequency_penalty |
float | Penalizes new tokens based on their frequency in the text so far |
logit_bias |
Dict[int, float] | Modifies likelihood of specified tokens appearing in the completion |
response_format |
Dict[str, Any] | Specifies the format of the response (e.g., {"type": "json_object"}) |
seed |
int | Sets a random seed for deterministic results |
logprobs |
bool | Whether to return log probabilities of the output tokens |
top_logprobs |
int | Number of most likely tokens to return the log probabilities for |
base_url |
str | The base URL for the API endpoint |
api_version |
str | The version of the API to use |
api_key |
str | Your API key for authentication |
Example:
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, ...)
crewAI supports using Ollama for running open-source models locally:
ollama run llama2
agent = Agent(
llm=LLM(model="ollama/llama3.1", base_url="http://localhost:11434"),
...
)
You can change the base API URL for any LLM provider by setting the base_url
parameter:
llm = LLM(
model="custom-model-name",
base_url="https://api.your-provider.com/v1",
api_key="your-api-key"
)
agent = Agent(llm=llm, ...)
Looks good, appreciate the effort to fix it asap!
new version is out v0.63.1 env vars should work again, also ability to control all different attribute for the LLM using the LLM class, if this is still an issue let us know and we can re-open it :) gpt-4o-mini is also back as default
Description
When upgrading to 0.61.0, I found that my usage charges skyrocketed . Investigated further to realise that I was suddenly using gpt-4o instead of gpt-4o-mini. image
Have the following line in my .env file as well OPENAI_MODEL_NAME=gpt-4o-mini
Steps to Reproduce
No code change on my part, only difference was the upgrading of package version from 0.51.0 to 0.61.0.
Expected behavior
Expected to use gpt-4o-mini as in V0.51.0 instead of gpt-4o (I'm assuming that's the default)
Screenshots/Code snippets
Operating System
Windows 10
Python Version
3.12
crewAI Version
0.61.0
crewAI Tools Version
NA
Virtual Environment
Poetry
Evidence
NA
Possible Solution
Was the env variable deprecated? If so, then probably just need to update the docs
Additional context
NA