fix: pass base_url and api_key directly to camel-ai ModelFactory

camel-ai does not read OPENAI_BASE_URL env var reliably.
Pass api_key and base_url via model_config_dict instead.
This commit is contained in:
Kunthawat Greethong
2026-06-17 22:30:59 +07:00
parent 7c3e219a6f
commit b30ed19b16
3 changed files with 24 additions and 3 deletions

View File

@@ -454,9 +454,16 @@ class TwitterSimulationRunner:
print(f"LLM配置: model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...")
# Build model config dict for camel-ai
model_config = {"model_type": llm_model}
if llm_api_key:
model_config["api_key"] = llm_api_key
if llm_base_url:
model_config["base_url"] = llm_base_url
return ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=llm_model,
model_config_dict=model_config,
)
def _get_active_agents_for_round(