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

@@ -1031,9 +1031,16 @@ def create_model(config: Dict[str, Any], use_boost: bool = False):
print(f"{config_label} 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,
)