Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

include model_name (#2310)

Brandon Hancock (bhancock_ai)59c6c29706b2
diff --git a/src/crewai/utilities/llm_utils.py b/src/crewai/utilities/llm_utils.py
index 4d34d789c..5e20cf768 100644
--- a/src/crewai/utilities/llm_utils.py
+++ b/src/crewai/utilities/llm_utils.py
@@ -43,8 +43,8 @@ def create_llm(
try:
# Extract attributes with explicit types
model = (
- getattr(llm_value, "model_name", None)
- or getattr(llm_value, "model", None)
+ getattr(llm_value, "model", None)
+ or getattr(llm_value, "model_name", None)
or getattr(llm_value, "deployment_name", None)
or str(llm_value)
)
@@ -77,8 +77,9 @@ def _llm_via_environment_or_fallback() -> Optional[LLM]:
Helper function: if llm_value is None, we load environment variables or fallback default model.
"""
model_name = (
- os.environ.get("OPENAI_MODEL_NAME")
- or os.environ.get("MODEL")
+ os.environ.get("MODEL")
+ or os.environ.get("MODEL_NAME")
+ or os.environ.get("OPENAI_MODEL_NAME")
or DEFAULT_LLM_MODEL
)