feat(v2): 补齐模型连接与会议反馈闭环并完成真实模拟联调

This commit is contained in:
2026-10-01 14:13:58 +08:00
parent fa4163b2d0
commit 8c5999c786
21 changed files with 392 additions and 15 deletions
+13 -6
View File
@@ -13,6 +13,7 @@ from langchain_openai import ChatOpenAI
from pydantic import BaseModel, ConfigDict, Field, field_validator
from graph.agent import agent_manager
from services import model_settings
from services.assistant_materials import FIELDS
@@ -56,10 +57,7 @@ class ExperienceProposal(BaseModel):
ModelResult.model_rebuild()
def configuration():
endpoint = os.getenv("XINGBANG_LOCAL_MODEL_URL", "")
if not endpoint:
return {"available": False, "reason": "未配置受信模型,语义核查未执行"}
def validate_endpoint(endpoint):
url = urlparse(endpoint)
official_deepseek = (
url.scheme == "https"
@@ -74,7 +72,16 @@ def configuration():
pass
if url.scheme not in ("http", "https") or not allowed or url.username or url.password or url.query or url.fragment:
raise ValueError("模型须为已批准的内网地址或 DeepSeek 官方 HTTPS 地址,不允许凭据或参数嵌入 URL")
return {"available": True, "endpoint": endpoint, "name": os.getenv("XINGBANG_LOCAL_MODEL_NAME", "local-model")}
def configuration():
from services import model_settings
config = model_settings.configured()
endpoint = config.get("endpoint")
if not endpoint:
return {"available": False, "reason": "未配置受信模型,语义核查未执行"}
validate_endpoint(endpoint)
return {"available": True, "endpoint": endpoint, "name": config.get("name") or "local-model"}
PROMPT = """你是兴邦项目核查助手,必须通过受限工具读取本次冻结事实、检查结果及所选方法。
@@ -144,7 +151,7 @@ def invoke(skill, snapshot, checks, rules, requirement, experiences, model_confi
task["feedback"] = {k: feedback[k] for k in ("category", "note", "target_kind", "target_id")}
prompt += "\n本次还需依据给出的专业反馈提炼经验草稿。输出允许增加 experience_proposal 对象,字段为 title、trigger、action、exceptions、conditions(标准字段到触发值的等值映射)、required_field、exception_field。只提出可验证的缺件核查动作,不创造审批制度;触发字段与缺件字段不能相同;不写来源客户名称、编号或专有信息。草稿不会自动发布。"
with httpx.Client(trust_env=False, follow_redirects=False, timeout=min(45, budget["timeout_seconds"])) as client:
model = ChatOpenAI(model=model_config["name"], api_key=os.getenv("XINGBANG_LOCAL_MODEL_KEY", "local"),
model = ChatOpenAI(model=model_config["name"], api_key=model_settings.api_key(),
base_url=model_config["endpoint"].rstrip("/"), http_client=client, temperature=0,
max_tokens=4000, max_retries=0)
result = agent_manager.invoke_scoped(json.dumps(task, ensure_ascii=False), model=model, tools=selected, system_prompt=prompt)