Completely refactor the LLM integration method to easily replace the LLM used by each module and optimize the retransmission mechanism.

This commit is contained in:
666ghj
2025-10-09 13:45:39 +08:00
parent ce74f00137
commit 154b29c0d7
73 changed files with 942 additions and 51758 deletions
+2 -2
View File
@@ -5,14 +5,14 @@
from abc import ABC, abstractmethod
from typing import Any, Dict, Optional
from ..llms.base import BaseLLM
from ..llms.base import LLMClient
from ..state.state import State
class BaseNode(ABC):
"""节点基类"""
def __init__(self, llm_client: BaseLLM, node_name: str = ""):
def __init__(self, llm_client: LLMClient, node_name: str = ""):
"""
初始化节点
+3 -4
View File
@@ -67,11 +67,10 @@ class ReportFormattingNode(BaseNode):
self.log_info("正在格式化最终报告")
# 调用LLM,传递更大的max_tokens以支持长文本报告
# 调用LLM生成Markdown格式
response = self.llm_client.invoke(
SYSTEM_PROMPT_REPORT_FORMATTING,
message,
max_tokens=30000 # 支持一万字的报告输出
SYSTEM_PROMPT_REPORT_FORMATTING,
message,
)
# 处理响应
+4 -6
View File
@@ -98,11 +98,10 @@ class FirstSummaryNode(StateMutationNode):
self.log_info("正在生成首次段落总结")
# 调用LLM,增加max_tokens以支持更长的总结
# 调用LLM生成总结
response = self.llm_client.invoke(
SYSTEM_PROMPT_FIRST_SUMMARY,
SYSTEM_PROMPT_FIRST_SUMMARY,
message,
max_tokens=15000 # 支持更长的总结内容
)
# 处理响应
@@ -267,11 +266,10 @@ class ReflectionSummaryNode(StateMutationNode):
self.log_info("正在生成反思总结")
# 调用LLM,增加max_tokens以支持更长的总结
# 调用LLM生成总结
response = self.llm_client.invoke(
SYSTEM_PROMPT_REFLECTION_SUMMARY,
SYSTEM_PROMPT_REFLECTION_SUMMARY,
message,
max_tokens=15000 # 支持更长的总结内容
)
# 处理响应