From 0e263f049086d3fe1db964a27065a2c799242bde Mon Sep 17 00:00:00 2001 From: Kunthawat Greethong Date: Mon, 22 Jun 2026 11:42:56 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20Step=205=20=E2=80=94=20camel-ai=20reads?= =?UTF-8?q?=20OPENAI=5FAPI=5FBASE=5FURL=20not=20OPENAI=5FBASE=5FURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- backend/app/services/oasis_profile_generator.py | 4 ++-- backend/scripts/run_parallel_simulation.py | 1 + backend/scripts/run_reddit_simulation.py | 1 + backend/scripts/run_twitter_simulation.py | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/app/services/oasis_profile_generator.py b/backend/app/services/oasis_profile_generator.py index cac49f7..e4d9e9a 100644 --- a/backend/app/services/oasis_profile_generator.py +++ b/backend/app/services/oasis_profile_generator.py @@ -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) diff --git a/backend/scripts/run_parallel_simulation.py b/backend/scripts/run_parallel_simulation.py index e3774e1..898d520 100644 --- a/backend/scripts/run_parallel_simulation.py +++ b/backend/scripts/run_parallel_simulation.py @@ -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 '默认'}...") diff --git a/backend/scripts/run_reddit_simulation.py b/backend/scripts/run_reddit_simulation.py index 803bc66..156db9d 100644 --- a/backend/scripts/run_reddit_simulation.py +++ b/backend/scripts/run_reddit_simulation.py @@ -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 '默认'}...") diff --git a/backend/scripts/run_twitter_simulation.py b/backend/scripts/run_twitter_simulation.py index 34d50dd..4c886ff 100644 --- a/backend/scripts/run_twitter_simulation.py +++ b/backend/scripts/run_twitter_simulation.py @@ -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 '默认'}...")