Jelajahi Sumber

Move global flags into configs

StrayWarrior 2 minggu lalu
induk
melakukan
e0bf34e71b
2 mengubah file dengan 4 tambahan dan 5 penghapusan
  1. 2 4
      agent_service.py
  2. 2 1
      user_profile_extractor.py

+ 2 - 4
agent_service.py

@@ -176,8 +176,8 @@ class AgentService:
             )
 
     def _call_chat_api(self, chat_config: Dict) -> str:
-        if global_flags.DISABLE_LLM_API_CALL:
-            return 'LLM模拟回复'
+        if configs.get().get('debug_flags', {}).get('disable_llm_api_call', False):
+            return 'LLM模拟回复 {}'.format(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
         if self.chat_service_type == ChatServiceType.OPENAI_COMPATIBLE:
             chat_completion = self.llm_client.chat.completions.create(
                 messages=chat_config['messages'],
@@ -225,8 +225,6 @@ if __name__ == "__main__":
     # 初始化用户管理服务
     user_manager = LocalUserManager()
 
-    global_flags.DISABLE_LLM_API_CALL = True
-
     # 创建Agent服务
     service = AgentService(
         receive_backend=receive_queue,

+ 2 - 1
user_profile_extractor.py

@@ -6,6 +6,7 @@ import json
 from typing import Dict, Any, Optional
 
 import chat_service
+import configs
 from prompt_templates import USER_PROFILE_EXTRACT_PROMPT
 from openai import OpenAI
 import logging
@@ -77,7 +78,7 @@ class UserProfileExtractor:
         """
         使用Function Calling提取用户画像信息
         """
-        if global_flags.DISABLE_LLM_API_CALL:
+        if configs.get().get('debug_flags', {}).get('disable_llm_api_call', False):
             return None
 
         try: