fix: 3 fixes for Step 2, Step 4, Step 5

1. Step 5: Use empty model_config_dict={} so camel-ai doesn't spread
   api_key into create() - AsyncOpenAI reads env vars automatically.
   Step 3 unaffected (same env vars, just cleaner ModelFactory call).

2. Step 2: Fix Thai text truncation - isalnum() stripped Thai chars.
   Use re.sub(r'[^\w]', '', username, re.UNICODE) instead.

3. Step 4: Move get_language_instruction() to START of prompt (not end)
   and strengthen wording with MUST/IMPORTANT prefix.
This commit is contained in:
Kunthawat Greethong
2026-06-22 10:57:57 +07:00
parent 270c92ed05
commit afc7afa2f5
6 changed files with 279 additions and 293 deletions

View File

@@ -1032,18 +1032,13 @@ 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 '默认'}...")
# camel-ai reads OPENAI_API_KEY from env automatically
# Pass api_key and base_url via model_config_dict
# camel-ai extracts these for the OpenAI client constructor
model_config = {}
if llm_api_key:
model_config["api_key"] = llm_api_key
if llm_base_url:
model_config["base_url"] = llm_base_url
# AsyncOpenAI reads OPENAI_API_KEY and OPENAI_BASE_URL from env automatically
# Pass empty model_config_dict so nothing is spread to create() call
return ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=llm_model,
model_config_dict=model_config,
model_config_dict={},
)