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

@@ -274,12 +274,14 @@ class OasisProfileGenerator:
)
def _generate_username(self, name: str) -> str:
"""生成用户名"""
# 移除特殊字符,转换为小写
"""Generate a username from the entity name"""
# Keep Unicode characters (Thai, Chinese, etc) and convert to lowercase
username = name.lower().replace(" ", "_")
username = ''.join(c for c in username if c.isalnum() or c == '_')
# Only remove truly problematic characters for usernames
import re
username = re.sub(r'[^\w]', '', username, flags=re.UNICODE)
# 添加随机后缀避免重复
# Add random suffix to avoid duplicates
suffix = random.randint(100, 999)
return f"{username}_{suffix}"