feat:对接中心平台,完善接口鉴权
This commit is contained in:
@@ -11,6 +11,7 @@ from app.clients.llm import get_llm
|
||||
from app.processor.base import BaseNode
|
||||
from app.processor.state import QueryState
|
||||
from app.prompt.action import build_action_prompt
|
||||
from app.resources.material_fields import editable_fields
|
||||
from app.schemas.action_validation import ActionValidationError, schema_errors
|
||||
from app.schemas.actions import ActionBatch, AddAction
|
||||
from app.schemas.operations import is_direct_operation
|
||||
@@ -58,6 +59,28 @@ def action_block_reason(state: QueryState) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def update_fields(state: QueryState) -> dict[str, list[dict]]:
|
||||
"""按组件 ID 汇总可能被属性更新的已有组件的可编辑字段,没有字段的组件省略"""
|
||||
plan = state.get("screen_plan")
|
||||
if plan is None:
|
||||
target_ids = [
|
||||
target
|
||||
for change in state["requirement"].changes
|
||||
if change.target_scope == "nodes"
|
||||
for target in change.target_ids
|
||||
]
|
||||
else:
|
||||
target_ids = [
|
||||
item.target_id for item in plan.components if item.disposition == "modify"
|
||||
]
|
||||
nodes = {node.id: node for node in state["input_context"].screen.nodes}
|
||||
result = {}
|
||||
for target in dict.fromkeys(target_ids):
|
||||
if target in nodes and (fields := editable_fields(nodes[target].type)):
|
||||
result[target] = fields
|
||||
return result
|
||||
|
||||
|
||||
class ActionNode(BaseNode):
|
||||
name = "action_node"
|
||||
|
||||
@@ -92,6 +115,10 @@ class ActionNode(BaseNode):
|
||||
payload["screen_plan"] = state["screen_plan"].model_dump(mode="json")
|
||||
payload["component_materials"] = plan_materials(state)
|
||||
|
||||
# 提供待修改组件的属性面板字段,让模型把用户说的“标题”“颜色”等对应到真实路径
|
||||
if fields := update_fields(state):
|
||||
payload["editable_fields"] = fields
|
||||
|
||||
# 如果本轮是动作修正,提供修正建议、上一轮动作和校验错误供模型参考
|
||||
if state.get("repair_plan") is not None:
|
||||
payload.update(
|
||||
|
||||
Reference in New Issue
Block a user