fix: Step 5 — camel-ai reads OPENAI_API_BASE_URL not OPENAI_BASE_URL
Root cause found in container: camel-ai v0.2.78 openai_model.py L117 reads
os.environ.get('OPENAI_API_BASE_URL') — NOT OPENAI_BASE_URL.
Fix: Set BOTH env vars (OPENAI_BASE_URL for OpenAI SDK + OPENAI_API_BASE_URL for camel-ai).
Keep model_config_dict={} empty so nothing spreads to create().
Also fix Step 2 Thai truncation: \w regex doesn't match Thai tone marks (Mn category).
Use explicit Unicode range \u0E00-\u0E7F instead.
This commit is contained in:
@@ -277,9 +277,9 @@ class OasisProfileGenerator:
|
||||
"""Generate a username from the entity name"""
|
||||
# Keep Unicode characters (Thai, Chinese, etc) and convert to lowercase
|
||||
username = name.lower().replace(" ", "_")
|
||||
# Only remove truly problematic characters for usernames
|
||||
# Remove characters that are NOT: Thai (\u0E00-\u0E7F), ASCII alphanumeric, or underscore
|
||||
import re
|
||||
username = re.sub(r'[^\w]', '', username, flags=re.UNICODE)
|
||||
username = re.sub(r'[^\u0E00-\u0E7Fa-zA-Z0-9_]', '', username)
|
||||
|
||||
# Add random suffix to avoid duplicates
|
||||
suffix = random.randint(100, 999)
|
||||
|
||||
@@ -1028,6 +1028,7 @@ def create_model(config: Dict[str, Any], use_boost: bool = False):
|
||||
|
||||
if llm_base_url:
|
||||
os.environ["OPENAI_BASE_URL"] = llm_base_url
|
||||
os.environ["OPENAI_API_BASE_URL"] = llm_base_url
|
||||
|
||||
print(f"{config_label} model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...")
|
||||
|
||||
|
||||
@@ -458,6 +458,7 @@ class RedditSimulationRunner:
|
||||
|
||||
if llm_base_url:
|
||||
os.environ["OPENAI_BASE_URL"] = llm_base_url
|
||||
os.environ["OPENAI_API_BASE_URL"] = llm_base_url
|
||||
|
||||
print(f"LLM配置: model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...")
|
||||
|
||||
|
||||
@@ -451,6 +451,7 @@ class TwitterSimulationRunner:
|
||||
|
||||
if llm_base_url:
|
||||
os.environ["OPENAI_BASE_URL"] = llm_base_url
|
||||
os.environ["OPENAI_API_BASE_URL"] = llm_base_url
|
||||
|
||||
print(f"LLM配置: model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user