From 5e7d9eff8487a057f1eb1b507ac4f10ae26b4529 Mon Sep 17 00:00:00 2001 From: FFXN <31929997+FFXN@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:25:23 +0800 Subject: [PATCH] feat: evaluation (#35290) Co-authored-by: jyong <718720800@qq.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hj24 Co-authored-by: hj24 Co-authored-by: Joel Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Co-authored-by: CodingOnStar Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../console/snippets/snippet_workflow.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/api/controllers/console/snippets/snippet_workflow.py b/api/controllers/console/snippets/snippet_workflow.py index d4b3ec5e4e..661a207658 100644 --- a/api/controllers/console/snippets/snippet_workflow.py +++ b/api/controllers/console/snippets/snippet_workflow.py @@ -4,7 +4,7 @@ from functools import wraps from typing import ParamSpec, TypeVar from flask import request -from flask_restx import Resource, marshal_with +from flask_restx import Resource, fields, marshal_with from sqlalchemy.orm import Session from werkzeug.exceptions import InternalServerError, NotFound @@ -63,6 +63,11 @@ register_schema_models( ) +snippet_workflow_model = console_ns.clone("SnippetWorkflow", workflow_model, { + "input_fields": fields.Raw(default=[]), +}) + + class SnippetNotFoundError(Exception): """Snippet not found error.""" @@ -100,14 +105,14 @@ def get_snippet(view_func: Callable[P, R]): @console_ns.route("/snippets//workflows/draft") class SnippetDraftWorkflowApi(Resource): @console_ns.doc("get_snippet_draft_workflow") - @console_ns.response(200, "Draft workflow retrieved successfully", workflow_model) + @console_ns.response(200, "Draft workflow retrieved successfully", snippet_workflow_model) @console_ns.response(404, "Snippet or draft workflow not found") @setup_required @login_required @account_initialization_required @get_snippet @edit_permission_required - @marshal_with(workflow_model) + @marshal_with(snippet_workflow_model) def get(self, snippet: CustomizedSnippet): """Get draft workflow for snippet.""" snippet_service = SnippetService() @@ -118,6 +123,7 @@ class SnippetDraftWorkflowApi(Resource): db.session.expunge(workflow) workflow.conversation_variables = [] + workflow.input_fields = snippet.input_fields_list return workflow @console_ns.doc("sync_snippet_draft_workflow") @@ -175,14 +181,14 @@ class SnippetDraftConfigApi(Resource): @console_ns.route("/snippets//workflows/publish") class SnippetPublishedWorkflowApi(Resource): @console_ns.doc("get_snippet_published_workflow") - @console_ns.response(200, "Published workflow retrieved successfully", workflow_model) + @console_ns.response(200, "Published workflow retrieved successfully", snippet_workflow_model) @console_ns.response(404, "Snippet not found") @setup_required @login_required @account_initialization_required @get_snippet @edit_permission_required - @marshal_with(workflow_model) + @marshal_with(snippet_workflow_model) def get(self, snippet: CustomizedSnippet): """Get published workflow for snippet.""" if not snippet.is_published: @@ -191,6 +197,9 @@ class SnippetPublishedWorkflowApi(Resource): snippet_service = SnippetService() workflow = snippet_service.get_published_workflow(snippet=snippet) + if workflow: + workflow.input_fields = snippet.input_fields_list + return workflow @console_ns.doc("publish_snippet_workflow")