feat:任务执行结果性能优化
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from flask import Flask, request, jsonify
|
||||
from flask import Flask, request, jsonify, Response, stream_with_context
|
||||
import json
|
||||
from DataProcess import Add_Collaboration_Brief_FrontEnd
|
||||
from AgentCoord.RehearsalEngine_V2.ExecutePlan import executePlan
|
||||
from AgentCoord.RehearsalEngine_V2.ExecutePlan_Optimized import executePlan_streaming
|
||||
from AgentCoord.PlanEngine.basePlan_Generator import generate_basePlan
|
||||
from AgentCoord.PlanEngine.fill_stepTask import fill_stepTask
|
||||
from AgentCoord.PlanEngine.fill_stepTask_TaskProcess import (
|
||||
@@ -257,6 +258,45 @@ def Handle_executePlan():
|
||||
return response
|
||||
|
||||
|
||||
@app.route("/executePlanOptimized", methods=["post"])
|
||||
def Handle_executePlanOptimized():
|
||||
"""
|
||||
优化版流式执行计划(阶段1+2:步骤级流式 + 动作级智能并行)
|
||||
|
||||
返回 SSE 流,每完成一个动作就返回结果
|
||||
- 无依赖关系的动作并行执行
|
||||
- 有依赖关系的动作串行执行
|
||||
|
||||
前端使用 EventSource 接收
|
||||
"""
|
||||
incoming_data = request.get_json()
|
||||
|
||||
def generate():
|
||||
try:
|
||||
for chunk in executePlan_streaming(
|
||||
plan=incoming_data["plan"],
|
||||
num_StepToRun=incoming_data.get("num_StepToRun"),
|
||||
RehearsalLog=incoming_data.get("RehearsalLog", []),
|
||||
AgentProfile_Dict=AgentProfile_Dict,
|
||||
):
|
||||
yield chunk
|
||||
except Exception as e:
|
||||
error_event = json.dumps({
|
||||
"type": "error",
|
||||
"message": str(e)
|
||||
}, ensure_ascii=False)
|
||||
yield f"data: {error_event}\n\n"
|
||||
|
||||
return Response(
|
||||
stream_with_context(generate()),
|
||||
mimetype="text/event-stream",
|
||||
headers={
|
||||
"Cache-Control": "no-cache",
|
||||
"X-Accel-Buffering": "no",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@app.route("/_saveRequestCashe", methods=["post"])
|
||||
def Handle_saveRequestCashe():
|
||||
with open(
|
||||
|
||||
Reference in New Issue
Block a user