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.

preparing new version

João Moura49220ec163f8
diff --git a/pyproject.toml b/pyproject.toml
index 31853a82d..b9e403140 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "crewai"
-version = "0.79.2"
+version = "0.79.3"
description = "Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks."
readme = "README.md"
requires-python = ">=3.10,<=3.13"
diff --git a/src/crewai/agent.py b/src/crewai/agent.py
index d30746808..c8998fd19 100644
--- a/src/crewai/agent.py
+++ b/src/crewai/agent.py
@@ -123,6 +123,11 @@ class Agent(BaseAgent):
@model_validator(mode="after")
def post_init_setup(self):
self.agent_ops_agent_name = self.role
+ unnacepted_attributes = [
+ "AWS_ACCESS_KEY_ID",
+ "AWS_SECRET_ACCESS_KEY",
+ "AWS_REGION_NAME",
+ ]
# Handle different cases for self.llm
if isinstance(self.llm, str):
@@ -146,39 +151,49 @@ class Agent(BaseAgent):
if api_base:
llm_params["base_url"] = api_base
+ set_provider = model_name.split("/")[0] if "/" in model_name else "openai"
+
# Iterate over all environment variables to find matching API keys or use defaults
for provider, env_vars in ENV_VARS.items():
- for env_var in env_vars:
- # Check if the environment variable is set
- if "key_name" in env_var:
- env_value = os.environ.get(env_var["key_name"])
- if env_value:
- # Map key names containing "API_KEY" to "api_key"
- key_name = (
- "api_key"
- if "API_KEY" in env_var["key_name"]
- else env_var["key_name"]
- )
- # Map key names containing "API_BASE" to "api_base"
- key_name = (
- "api_base"
- if "API_BASE" in env_var["key_name"]
- else key_name
- )
- # Map key names containing "API_VERSION" to "api_version"
- key_name = (
- "api_version"
- if "API_VERSION" in env_var["key_name"]
- else key_name
+ if provider == set_provider:
+ for env_var in env_vars:
+ if env_var["key_name"] in unnacepted_attributes:
+ continue
+ # Check if the environment variable is set
+ if "key_name" in env_var:
+ env_value = os.environ.get(env_var["key_name"])
+ print(
+ f"Checking env var {env_var['key_name']}: {env_value}"
)
- llm_params[key_name] = env_value
- # Check for default values if the environment variable is not set
- elif env_var.get("default", False):
- for key, value in env_var.items():
- if key not in ["prompt", "key_name", "default"]:
- # Only add default if the key is already set in os.environ
- if key in os.environ:
- llm_params[key] = value
+ if env_value:
+ # Map key names containing "API_KEY" to "api_key"
+ key_name = (
+ "api_key"
+ if "API_KEY" in env_var["key_name"]
+ else env_var["key_name"]
+ )
+ # Map key names containing "API_BASE" to "api_base"
+ key_name = (
+ "api_base"
+ if "API_BASE" in env_var["key_name"]
+ else key_name
+ )
+ # Map key names containing "API_VERSION" to "api_version"
+ key_name = (
+ "api_version"
+ if "API_VERSION" in env_var["key_name"]
+ else key_name
+ )
+ print(f"Mapped key name: {key_name}")
+ llm_params[key_name] = env_value
+ # Check for default values if the environment variable is not set
+ elif env_var.get("default", False):
+ for key, value in env_var.items():
+ if key not in ["prompt", "key_name", "default"]:
+ # Only add default if the key is already set in os.environ
+ if key in os.environ:
+ print(f"Using default value for {key}: {value}")
+ llm_params[key] = value
self.llm = LLM(**llm_params)
else:
diff --git a/src/crewai/agents/crew_agent_executor.py b/src/crewai/agents/crew_agent_executor.py
index 9e9ad9c7e..aa641e061 100644
--- a/src/crewai/agents/crew_agent_executor.py
+++ b/src/crewai/agents/crew_agent_executor.py
@@ -332,9 +332,9 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
if self.crew is not None and hasattr(self.crew, "_train_iteration"):
train_iteration = self.crew._train_iteration
if agent_id in training_data and isinstance(train_iteration, int):
- training_data[agent_id][train_iteration][
- "improved_output"
- ] = result.output
+ training_data[agent_id][train_iteration]["improved_output"] = (
+ result.output
+ )
training_handler.save(training_data)
else:
self._logger.log(
@@ -385,4 +385,5 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
return CrewAgentParser(agent=self.agent).parse(answer)
def _format_msg(self, prompt: str, role: str = "user") -> Dict[str, str]:
+ prompt = prompt.rstrip()
return {"role": role, "content": prompt}
diff --git a/uv.lock b/uv.lock
index b59d377ee..0b541a3e7 100644
--- a/uv.lock
+++ b/uv.lock
@@ -604,7 +604,7 @@ wheels = [
[[package]]
name = "crewai"
-version = "0.79.2"
+version = "0.79.3"
source = { editable = "." }
dependencies = [
{ name = "appdirs" },
@@ -725,9 +725,9 @@ dependencies = [
{ name = "requests" },
{ name = "selenium" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/64/bd/eff7b633a0b28ff4ed115adde1499e3dcc683e4f0b5c378a4c6f5c0c1bf6/crewai_tools-0.14.0.tar.gz", hash = "sha256:b6ac527633b7018471d892c21ac96bc961a86b6626d996b1ed7d53cd481d4505", size = 816588 }
+sdist = { url = "https://files.pythonhosted.org/packages/9b/6d/4fa91b481b120f83bb58f365203d8aa8564e8ced1035d79f8aedb7d71e2f/crewai_tools-0.14.0.tar.gz", hash = "sha256:510f3a194bcda4fdae4314bd775521964b5f229ddbe451e5d9e0216cae57f4e3", size = 815892 }
wheels = [
- { url = "https://files.pythonhosted.org/packages/6c/40/93cd347d854059cf5e54a81b70f896deea7ad1f03e9c024549eb323c4da5/crewai_tools-0.14.0-py3-none-any.whl", hash = "sha256:eda78fe3c4df57676259d8dd6b2610fa31f89b90909512f15893adb57fb9e825", size = 463703 },
+ { url = "https://files.pythonhosted.org/packages/c8/ed/9f4e64e1507062957b0118085332d38b621c1000874baef2d1c4069bfd97/crewai_tools-0.14.0-py3-none-any.whl", hash = "sha256:0a804a828c29869c3af3253f4fc4c3967a3f80f06dab22e9bbe9526608a31564", size = 462980 },
]
[[package]]