Enhance LLM integration by adding OpenAI client support and enabling dynamic routing between DeepSeek and OpenAI services. Update environment configuration to include LLM_SERVICE_CODE for service selection, and modify API server to accommodate new request parameters for language and model. Implement streaming response improvements for chat interactions, allowing for segmented SSE output. Update documentation and impact analysis to reflect these changes.

This commit is contained in:
陈辅元
2026-04-16 09:15:01 +08:00
parent 85ad31348e
commit df33657099
17 changed files with 958 additions and 64 deletions
+9 -6
View File
@@ -44,6 +44,7 @@ class Text2SQLOrchestrator:
def __init__(
self,
schema_manager: SchemaManager,
llm_client: Optional[object] = None,
deepseek_api_key: Optional[str] = None,
deepseek_config: Optional[DeepSeekConfig] = None,
vector_db_path: str = "./data/embeddings/chroma",
@@ -61,6 +62,7 @@ class Text2SQLOrchestrator:
Args:
schema_manager: Schema管理器实例
llm_client: 可选:外部传入的 LLM Client(需具备 chat/chat_with_json 等方法)。
deepseek_api_key: DeepSeek API密钥(也可通过环境变量DEEPSEEK_API_KEY)
deepseek_config: DeepSeek配置对象(优先于api_key)
vector_db_path: 向量数据库路径
@@ -75,13 +77,14 @@ class Text2SQLOrchestrator:
self.use_vector_search = use_vector_search
self.translate_english_to_zh = translate_english_to_zh
# 初始化DeepSeek客户端
if deepseek_config:
self.deepseek = DeepSeekClient(deepseek_config)
# 初始化 LLM 客户端(历史属性名保留为 deepseek,避免大范围改动)
if llm_client is not None:
self.deepseek = llm_client
else:
self.deepseek = DeepSeekClient(
DeepSeekConfig(api_key=deepseek_api_key)
)
if deepseek_config:
self.deepseek = DeepSeekClient(deepseek_config)
else:
self.deepseek = DeepSeekClient(DeepSeekConfig(api_key=deepseek_api_key))
# 初始化向量索引(延迟加载)
self._vector_index: Optional[SchemaIndexer] = None