mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 21:28:10 +00:00
fix: address three review comments on env/cli handling
- write_env_file: remove .upper() to preserve original key case - load_env_vars: strip surrounding single/double quotes from values - constants.py: fix Ollama key_name from OPENAI_API_BASE to OLLAMA_HOST - _test_new_agents: replace asyncio.run() loop with new_event_loop + run_until_complete Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -864,6 +864,9 @@ def _test_new_agents(
|
||||
all_passed = True
|
||||
agents_tested: set[str] = set()
|
||||
|
||||
_loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(_loop)
|
||||
|
||||
for iteration in range(n_iterations):
|
||||
if n_iterations > 1:
|
||||
click.secho(f"\n Iteration {iteration + 1}/{n_iterations}", fg="cyan")
|
||||
@@ -876,10 +879,10 @@ def _test_new_agents(
|
||||
with ArtifactsSandbox():
|
||||
if verbose:
|
||||
with VerboseBenchmarkOutput():
|
||||
all_results = asyncio.run(_run_all())
|
||||
all_results = _loop.run_until_complete(_run_all())
|
||||
else:
|
||||
with SuppressBenchmarkOutput():
|
||||
all_results = asyncio.run(_run_all())
|
||||
all_results = _loop.run_until_complete(_run_all())
|
||||
finally:
|
||||
if not verbose:
|
||||
if progress is None:
|
||||
@@ -914,6 +917,8 @@ def _test_new_agents(
|
||||
f" [green bold]{job['agent_name']}: PASSED all {len(results)} cases >= {job['threshold']}[/green bold]"
|
||||
)
|
||||
|
||||
_loop.close()
|
||||
|
||||
if len(agents_tested) == 0:
|
||||
click.secho("No agents completed successfully.", fg="yellow")
|
||||
raise SystemExit(1)
|
||||
|
||||
@@ -55,7 +55,7 @@ ENV_VARS: dict[str, list[dict[str, Any]]] = {
|
||||
"ollama": [
|
||||
{
|
||||
"default": True,
|
||||
"key_name": "OPENAI_API_BASE",
|
||||
"key_name": "OLLAMA_HOST",
|
||||
"API_BASE": "http://localhost:11434",
|
||||
}
|
||||
],
|
||||
|
||||
@@ -125,6 +125,12 @@ def load_env_vars(folder_path: Path) -> dict[str, Any]:
|
||||
for line in file:
|
||||
key, _, value = line.strip().partition("=")
|
||||
if key and value:
|
||||
if (
|
||||
len(value) >= 2
|
||||
and value[0] == value[-1]
|
||||
and value[0] in ('"', "'")
|
||||
):
|
||||
value = value[1:-1]
|
||||
env_vars[key] = value
|
||||
return env_vars
|
||||
|
||||
@@ -134,4 +140,4 @@ def write_env_file(folder_path: Path, env_vars: dict[str, Any]) -> None:
|
||||
env_file_path = folder_path / ".env"
|
||||
with open(env_file_path, "w") as file:
|
||||
for key, value in env_vars.items():
|
||||
file.write(f"{key.upper()}={value}\n")
|
||||
file.write(f"{key}={value}\n")
|
||||
|
||||
Reference in New Issue
Block a user