From a0d5d8378743c11ba73bb28868b7fc5722201b4b Mon Sep 17 00:00:00 2001 From: FFXN Date: Tue, 24 Mar 2026 11:22:07 +0800 Subject: [PATCH] fix: fix import errors caused by dify_graph. --- .../console/evaluation/evaluation.py | 6 +- .../console/snippets/snippet_workflow.py | 2 +- .../evaluation/base_evaluation_instance.py | 4 +- .../evaluation/entities/evaluation_entity.py | 2 +- api/core/evaluation/judgment/processor.py | 4 +- .../runners/agent_evaluation_runner.py | 2 +- .../runners/base_evaluation_runner.py | 2 +- .../runners/llm_evaluation_runner.py | 2 +- .../runners/retrieval_evaluation_runner.py | 2 +- .../runners/snippet_evaluation_runner.py | 2 +- .../runners/workflow_evaluation_runner.py | 2 +- api/docs/swagger.yaml | 1642 ----------------- api/services/evaluation_service.py | 6 +- api/services/snippet_dsl_service.py | 4 +- api/services/snippet_generate_service.py | 2 +- api/services/snippet_service.py | 6 +- api/tasks/evaluation_task.py | 2 +- 17 files changed, 26 insertions(+), 1666 deletions(-) delete mode 100644 api/docs/swagger.yaml diff --git a/api/controllers/console/evaluation/evaluation.py b/api/controllers/console/evaluation/evaluation.py index 23f6300f39..b9b64715d2 100644 --- a/api/controllers/console/evaluation/evaluation.py +++ b/api/controllers/console/evaluation/evaluation.py @@ -21,7 +21,7 @@ from controllers.console.wraps import ( setup_required, ) from core.evaluation.entities.evaluation_entity import EvaluationCategory, EvaluationConfigData, EvaluationRunRequest -from core.workflow.file import helpers as file_helpers +from dify_graph.file import helpers as file_helpers from extensions.ext_database import db from extensions.ext_storage import storage from libs.helper import TimestampField @@ -161,7 +161,9 @@ def get_evaluation_target(view_func: Callable[P, R]): .first() ) elif target_type == "knowledge": - target = db.session.query(Dataset).where(Dataset.id == target_id, Dataset.tenant_id == current_tenant_id).first() + target = (db.session.query(Dataset) + .where(Dataset.id == target_id, Dataset.tenant_id == current_tenant_id) + .first()) if not target: raise NotFound(f"{str(target_type)} not found") diff --git a/api/controllers/console/snippets/snippet_workflow.py b/api/controllers/console/snippets/snippet_workflow.py index 17309fc4d4..67ec20690e 100644 --- a/api/controllers/console/snippets/snippet_workflow.py +++ b/api/controllers/console/snippets/snippet_workflow.py @@ -34,7 +34,7 @@ from controllers.console.wraps import ( ) from core.app.apps.base_app_queue_manager import AppQueueManager from core.app.entities.app_invoke_entities import InvokeFrom -from core.workflow.graph_engine.manager import GraphEngineManager +from dify_graph.graph_engine.manager import GraphEngineManager from extensions.ext_database import db from extensions.ext_redis import redis_client from factories import variable_factory diff --git a/api/core/evaluation/base_evaluation_instance.py b/api/core/evaluation/base_evaluation_instance.py index 7bf1cb47ff..e419e9523e 100644 --- a/api/core/evaluation/base_evaluation_instance.py +++ b/api/core/evaluation/base_evaluation_instance.py @@ -10,7 +10,7 @@ from core.evaluation.entities.evaluation_entity import ( EvaluationItemResult, EvaluationMetric, ) -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events.base import NodeRunResult logger = logging.getLogger(__name__) @@ -162,7 +162,7 @@ class BaseEvaluationInstance(ABC): ``node_run_result_mapping``. """ - from core.workflow.nodes.base.variable_template_parser import REGEX as VARIABLE_REGEX + from dify_graph.nodes.base.variable_template_parser import REGEX as VARIABLE_REGEX workflow_inputs: dict[str, Any] = {} diff --git a/api/core/evaluation/entities/evaluation_entity.py b/api/core/evaluation/entities/evaluation_entity.py index 04386d05be..37ae184b8f 100644 --- a/api/core/evaluation/entities/evaluation_entity.py +++ b/api/core/evaluation/entities/evaluation_entity.py @@ -103,7 +103,7 @@ LLM_METRIC_NAMES: list[EvaluationMetricName] = [ EvaluationMetricName.FAITHFULNESS, # Every claim is grounded in context; no hallucinations EvaluationMetricName.ANSWER_RELEVANCY, # Response stays on-topic and addresses the question EvaluationMetricName.ANSWER_CORRECTNESS, # Factual accuracy and completeness vs. reference - EvaluationMetricName.SEMANTIC_SIMILARITY, # Semantic closeness to the reference answer + EvaluationMetricName.SEMANTIC_SIMILARITY, # Semantic closeness to the reference answer ] RETRIEVAL_METRIC_NAMES: list[EvaluationMetricName] = [ diff --git a/api/core/evaluation/judgment/processor.py b/api/core/evaluation/judgment/processor.py index 04b0ac9924..20ee03aa75 100644 --- a/api/core/evaluation/judgment/processor.py +++ b/api/core/evaluation/judgment/processor.py @@ -23,8 +23,8 @@ from core.evaluation.entities.judgment_entity import ( JudgmentConfig, JudgmentResult, ) -from core.workflow.utils.condition.entities import SupportedComparisonOperator -from core.workflow.utils.condition.processor import _evaluate_condition # pyright: ignore[reportPrivateUsage] +from dify_graph.utils.condition.entities import SupportedComparisonOperator +from dify_graph.utils.condition.processor import _evaluate_condition # pyright: ignore[reportPrivateUsage] logger = logging.getLogger(__name__) diff --git a/api/core/evaluation/runners/agent_evaluation_runner.py b/api/core/evaluation/runners/agent_evaluation_runner.py index 32746a0a27..b8b18cf20f 100644 --- a/api/core/evaluation/runners/agent_evaluation_runner.py +++ b/api/core/evaluation/runners/agent_evaluation_runner.py @@ -12,7 +12,7 @@ from core.evaluation.entities.evaluation_entity import ( EvaluationItemResult, ) from core.evaluation.runners.base_evaluation_runner import BaseEvaluationRunner -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events import NodeRunResult from models.model import App logger = logging.getLogger(__name__) diff --git a/api/core/evaluation/runners/base_evaluation_runner.py b/api/core/evaluation/runners/base_evaluation_runner.py index 5200910f81..6f81b1d829 100644 --- a/api/core/evaluation/runners/base_evaluation_runner.py +++ b/api/core/evaluation/runners/base_evaluation_runner.py @@ -26,7 +26,7 @@ from core.evaluation.entities.evaluation_entity import ( ) from core.evaluation.entities.judgment_entity import JudgmentConfig from core.evaluation.judgment.processor import JudgmentProcessor -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events import NodeRunResult from libs.datetime_utils import naive_utc_now from models.evaluation import EvaluationRun, EvaluationRunItem, EvaluationRunStatus diff --git a/api/core/evaluation/runners/llm_evaluation_runner.py b/api/core/evaluation/runners/llm_evaluation_runner.py index f046224e51..ee37cbbc08 100644 --- a/api/core/evaluation/runners/llm_evaluation_runner.py +++ b/api/core/evaluation/runners/llm_evaluation_runner.py @@ -12,7 +12,7 @@ from core.evaluation.entities.evaluation_entity import ( EvaluationItemResult, ) from core.evaluation.runners.base_evaluation_runner import BaseEvaluationRunner -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events import NodeRunResult logger = logging.getLogger(__name__) diff --git a/api/core/evaluation/runners/retrieval_evaluation_runner.py b/api/core/evaluation/runners/retrieval_evaluation_runner.py index 9d027a0a00..11f6be72fb 100644 --- a/api/core/evaluation/runners/retrieval_evaluation_runner.py +++ b/api/core/evaluation/runners/retrieval_evaluation_runner.py @@ -11,7 +11,7 @@ from core.evaluation.entities.evaluation_entity import ( EvaluationItemResult, ) from core.evaluation.runners.base_evaluation_runner import BaseEvaluationRunner -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events import NodeRunResult logger = logging.getLogger(__name__) diff --git a/api/core/evaluation/runners/snippet_evaluation_runner.py b/api/core/evaluation/runners/snippet_evaluation_runner.py index 746424b323..f36931c6f3 100644 --- a/api/core/evaluation/runners/snippet_evaluation_runner.py +++ b/api/core/evaluation/runners/snippet_evaluation_runner.py @@ -22,7 +22,7 @@ from core.evaluation.entities.evaluation_entity import ( EvaluationItemResult, ) from core.evaluation.runners.base_evaluation_runner import BaseEvaluationRunner -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events import NodeRunResult from models.snippet import CustomizedSnippet from models.workflow import WorkflowNodeExecutionModel diff --git a/api/core/evaluation/runners/workflow_evaluation_runner.py b/api/core/evaluation/runners/workflow_evaluation_runner.py index 19411d291b..a27dd226d6 100644 --- a/api/core/evaluation/runners/workflow_evaluation_runner.py +++ b/api/core/evaluation/runners/workflow_evaluation_runner.py @@ -12,7 +12,7 @@ from core.evaluation.entities.evaluation_entity import ( EvaluationItemResult, ) from core.evaluation.runners.base_evaluation_runner import BaseEvaluationRunner -from core.workflow.node_events import NodeRunResult +from dify_graph.node_events import NodeRunResult logger = logging.getLogger(__name__) diff --git a/api/docs/swagger.yaml b/api/docs/swagger.yaml deleted file mode 100644 index 7bb26800a4..0000000000 --- a/api/docs/swagger.yaml +++ /dev/null @@ -1,1642 +0,0 @@ -openapi: 3.0.3 -info: - title: Dify Console API - description: API documentation for Dify Console – Datasets, Snippets, Snippet Workflows, and Evaluation modules. - version: 1.0.0 - -servers: - - url: /console/api - -tags: - - name: Datasets - description: Knowledge base (dataset) CRUD and ancillary operations - - name: Dataset Evaluation - description: Knowledge base retrieval evaluation - - name: Snippets - description: Customized snippet CRUD, import/export, and dependency checks - - name: Snippet Workflows - description: Snippet draft/published workflow operations, node runs, and workflow runs - - name: Evaluation - description: Evaluation configuration, runs, metrics, and node info for App / Snippet targets - -# ============================================================ -# Paths -# ============================================================ -paths: - - # ---------------------------------------------------------- - # Datasets - # ---------------------------------------------------------- - - /datasets: - get: - tags: [Datasets] - summary: List datasets - operationId: get_datasets - parameters: - - $ref: '#/components/parameters/PageParam' - - $ref: '#/components/parameters/LimitParam' - - name: keyword - in: query - schema: { type: string } - - name: include_all - in: query - schema: { type: boolean, default: false } - - name: ids - in: query - schema: { type: array, items: { type: string } } - - name: tag_ids - in: query - schema: { type: array, items: { type: string } } - responses: - '200': - description: Datasets retrieved successfully - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/DatasetDetail' } } - page: { type: integer } - limit: { type: integer } - total: { type: integer } - has_more: { type: boolean } - post: - tags: [Datasets] - summary: Create a dataset - operationId: create_dataset - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/DatasetCreatePayload' } - responses: - '201': - description: Dataset created successfully - content: - application/json: - schema: { $ref: '#/components/schemas/DatasetDetail' } - '400': - $ref: '#/components/responses/BadRequest' - - /datasets/{dataset_id}: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get dataset details - operationId: get_dataset - responses: - '200': - description: Dataset retrieved successfully - content: - application/json: - schema: { $ref: '#/components/schemas/DatasetDetail' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - patch: - tags: [Datasets] - summary: Update dataset - operationId: update_dataset - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/DatasetUpdatePayload' } - responses: - '200': - description: Dataset updated successfully - content: - application/json: - schema: { $ref: '#/components/schemas/DatasetDetail' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - delete: - tags: [Datasets] - summary: Delete dataset - operationId: delete_dataset - responses: - '204': { description: Dataset deleted successfully } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/use-check: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Check if dataset is in use - operationId: check_dataset_use - responses: - '200': - description: Dataset use status - content: - application/json: - schema: - type: object - properties: - is_using: { type: boolean } - - /datasets/{dataset_id}/queries: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get dataset query history - operationId: get_dataset_queries - parameters: - - $ref: '#/components/parameters/PageParam' - - $ref: '#/components/parameters/LimitParam' - responses: - '200': - description: Query history retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { type: object } } - page: { type: integer } - limit: { type: integer } - total: { type: integer } - has_more: { type: boolean } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/indexing-estimate: - post: - tags: [Datasets] - summary: Estimate dataset indexing cost - operationId: estimate_dataset_indexing - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/IndexingEstimatePayload' } - responses: - '200': { description: Indexing estimate calculated } - - /datasets/{dataset_id}/related-apps: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get applications related to dataset - operationId: get_dataset_related_apps - responses: - '200': - description: Related apps retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { type: object } } - total: { type: integer } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/indexing-status: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get dataset indexing status - operationId: get_dataset_indexing_status - responses: - '200': - description: Indexing status retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { type: object } } - - /datasets/api-keys: - get: - tags: [Datasets] - summary: Get dataset API keys - operationId: get_dataset_api_keys - responses: - '200': - description: API keys retrieved - content: - application/json: - schema: - type: object - properties: - items: { type: array, items: { $ref: '#/components/schemas/ApiKeyItem' } } - post: - tags: [Datasets] - summary: Create dataset API key - operationId: create_dataset_api_key - responses: - '200': - description: API key created - content: - application/json: - schema: { $ref: '#/components/schemas/ApiKeyItem' } - '400': { $ref: '#/components/responses/BadRequest' } - - /datasets/api-keys/{api_key_id}: - parameters: - - name: api_key_id - in: path - required: true - schema: { type: string, format: uuid } - delete: - tags: [Datasets] - summary: Delete dataset API key - operationId: delete_dataset_api_key - responses: - '204': { description: API key deleted } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/api-keys/{status}: - parameters: - - $ref: '#/components/parameters/DatasetId' - - name: status - in: path - required: true - schema: { type: string, enum: [enable, disable] } - post: - tags: [Datasets] - summary: Enable or disable dataset API - operationId: toggle_dataset_api - responses: - '200': { description: Status updated } - - /datasets/api-base-info: - get: - tags: [Datasets] - summary: Get dataset API base URL - operationId: get_dataset_api_base_info - responses: - '200': - description: API base info - content: - application/json: - schema: - type: object - properties: - api_base_url: { type: string } - - /datasets/retrieval-setting: - get: - tags: [Datasets] - summary: Get dataset retrieval settings - operationId: get_dataset_retrieval_setting - responses: - '200': - description: Retrieval settings - content: - application/json: - schema: - type: object - properties: - retrieval_method: { type: array, items: { type: string } } - - /datasets/retrieval-setting/{vector_type}: - parameters: - - name: vector_type - in: path - required: true - schema: { type: string } - get: - tags: [Datasets] - summary: Get mock retrieval settings by vector type - operationId: get_dataset_retrieval_setting_mock - responses: - '200': - description: Mock retrieval settings - content: - application/json: - schema: - type: object - properties: - retrieval_method: { type: array, items: { type: string } } - - /datasets/{dataset_id}/error-docs: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get dataset error documents - operationId: get_dataset_error_docs - responses: - '200': - description: Error documents retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { type: object } } - total: { type: integer } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/permission-part-users: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get dataset permission user list - operationId: get_dataset_permission_users - responses: - '200': - description: Permission users retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { type: object } } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/auto-disable-logs: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Datasets] - summary: Get dataset auto-disable logs - operationId: get_dataset_auto_disable_logs - responses: - '200': { description: Auto-disable logs retrieved } - '404': { $ref: '#/components/responses/NotFound' } - - # ---------------------------------------------------------- - # Dataset Evaluation - # ---------------------------------------------------------- - - /datasets/{dataset_id}/evaluation/template/download: - parameters: - - $ref: '#/components/parameters/DatasetId' - post: - tags: [Dataset Evaluation] - summary: Download evaluation dataset template for knowledge base - operationId: download_dataset_evaluation_template - responses: - '200': - description: XLSX template streamed as attachment - content: - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: {} - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/evaluation: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Dataset Evaluation] - summary: Get evaluation configuration for knowledge base - operationId: get_dataset_evaluation_config - responses: - '200': - description: Evaluation configuration retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationConfig' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - put: - tags: [Dataset Evaluation] - summary: Save evaluation configuration for knowledge base - operationId: save_dataset_evaluation_config - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationConfigData' } - responses: - '200': - description: Configuration saved - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationConfig' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/evaluation/run: - parameters: - - $ref: '#/components/parameters/DatasetId' - post: - tags: [Dataset Evaluation] - summary: Start evaluation run for knowledge base - operationId: start_dataset_evaluation_run - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationRunRequest' } - responses: - '200': - description: Evaluation run started - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationRun' } - '400': { $ref: '#/components/responses/BadRequest' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - '429': { description: Max concurrent runs reached } - - /datasets/{dataset_id}/evaluation/logs: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Dataset Evaluation] - summary: Get evaluation run history for knowledge base - operationId: get_dataset_evaluation_logs - parameters: - - $ref: '#/components/parameters/PageParam' - - name: page_size - in: query - schema: { type: integer, default: 20 } - responses: - '200': - description: Evaluation logs retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/EvaluationRun' } } - total: { type: integer } - page: { type: integer } - page_size: { type: integer } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/evaluation/runs/{run_id}: - parameters: - - $ref: '#/components/parameters/DatasetId' - - $ref: '#/components/parameters/RunId' - get: - tags: [Dataset Evaluation] - summary: Get evaluation run detail for knowledge base - operationId: get_dataset_evaluation_run_detail - parameters: - - $ref: '#/components/parameters/PageParam' - - name: page_size - in: query - schema: { type: integer, default: 50 } - responses: - '200': - description: Run detail with items - content: - application/json: - schema: - type: object - properties: - run: { $ref: '#/components/schemas/EvaluationRun' } - items: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/EvaluationRunItem' } } - total: { type: integer } - page: { type: integer } - page_size: { type: integer } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/evaluation/runs/{run_id}/cancel: - parameters: - - $ref: '#/components/parameters/DatasetId' - - $ref: '#/components/parameters/RunId' - post: - tags: [Dataset Evaluation] - summary: Cancel a running knowledge base evaluation - operationId: cancel_dataset_evaluation_run - responses: - '200': - description: Evaluation run cancelled - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationRun' } - '400': { $ref: '#/components/responses/BadRequest' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/evaluation/metrics: - parameters: - - $ref: '#/components/parameters/DatasetId' - get: - tags: [Dataset Evaluation] - summary: Get available retrieval evaluation metrics - operationId: get_dataset_evaluation_metrics - responses: - '200': - description: Metrics retrieved - content: - application/json: - schema: - type: object - properties: - metrics: { type: array, items: { type: string } } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - /datasets/{dataset_id}/evaluation/files/{file_id}: - parameters: - - $ref: '#/components/parameters/DatasetId' - - name: file_id - in: path - required: true - schema: { type: string, format: uuid } - get: - tags: [Dataset Evaluation] - summary: Download evaluation file for knowledge base - operationId: download_dataset_evaluation_file - responses: - '200': - description: File info and download URL - content: - application/json: - schema: { $ref: '#/components/schemas/FileInfo' } - '403': { $ref: '#/components/responses/Forbidden' } - '404': { $ref: '#/components/responses/NotFound' } - - # ---------------------------------------------------------- - # Snippets - # ---------------------------------------------------------- - - /workspaces/current/customized-snippets: - get: - tags: [Snippets] - summary: List customized snippets - operationId: list_customized_snippets - parameters: - - $ref: '#/components/parameters/PageParam' - - $ref: '#/components/parameters/LimitParam' - - name: keyword - in: query - schema: { type: string } - - name: is_published - in: query - schema: { type: boolean } - responses: - '200': - description: Snippets retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/SnippetListItem' } } - page: { type: integer } - limit: { type: integer } - total: { type: integer } - has_more: { type: boolean } - post: - tags: [Snippets] - summary: Create a customized snippet - operationId: create_customized_snippet - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/CreateSnippetPayload' } - responses: - '201': - description: Snippet created - content: - application/json: - schema: { $ref: '#/components/schemas/Snippet' } - '400': { $ref: '#/components/responses/BadRequest' } - - /workspaces/current/customized-snippets/{snippet_id}: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippets] - summary: Get snippet details - operationId: get_customized_snippet - responses: - '200': - description: Snippet retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/Snippet' } - '404': { $ref: '#/components/responses/NotFound' } - patch: - tags: [Snippets] - summary: Update snippet - operationId: update_customized_snippet - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/UpdateSnippetPayload' } - responses: - '200': - description: Snippet updated - content: - application/json: - schema: { $ref: '#/components/schemas/Snippet' } - '400': { $ref: '#/components/responses/BadRequest' } - '404': { $ref: '#/components/responses/NotFound' } - delete: - tags: [Snippets] - summary: Delete snippet - operationId: delete_customized_snippet - responses: - '204': { description: Snippet deleted } - '404': { $ref: '#/components/responses/NotFound' } - - /workspaces/current/customized-snippets/{snippet_id}/export: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippets] - summary: Export snippet as DSL (YAML) - operationId: export_customized_snippet - parameters: - - name: include_secret - in: query - schema: { type: string, enum: ['true', 'false'], default: 'false' } - responses: - '200': - description: Snippet DSL exported - content: - application/x-yaml: {} - '404': { $ref: '#/components/responses/NotFound' } - - /workspaces/current/customized-snippets/imports: - post: - tags: [Snippets] - summary: Import snippet from DSL - operationId: import_customized_snippet - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/SnippetImportPayload' } - responses: - '200': { description: Import succeeded } - '202': { description: Import pending confirmation } - '400': { $ref: '#/components/responses/BadRequest' } - - /workspaces/current/customized-snippets/imports/{import_id}/confirm: - parameters: - - name: import_id - in: path - required: true - schema: { type: string } - post: - tags: [Snippets] - summary: Confirm a pending snippet import - operationId: confirm_snippet_import - responses: - '200': { description: Import confirmed } - '400': { $ref: '#/components/responses/BadRequest' } - - /workspaces/current/customized-snippets/{snippet_id}/check-dependencies: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippets] - summary: Check snippet dependencies - operationId: check_snippet_dependencies - responses: - '200': { description: Dependencies checked } - '404': { $ref: '#/components/responses/NotFound' } - - /workspaces/current/customized-snippets/{snippet_id}/use-count/increment: - parameters: - - $ref: '#/components/parameters/SnippetId' - post: - tags: [Snippets] - summary: Increment snippet use count - operationId: increment_snippet_use_count - responses: - '200': - description: Use count incremented - content: - application/json: - schema: - type: object - properties: - result: { type: string } - use_count: { type: integer } - '404': { $ref: '#/components/responses/NotFound' } - - # ---------------------------------------------------------- - # Snippet Workflows - # ---------------------------------------------------------- - - /snippets/{snippet_id}/workflows/draft: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippet Workflows] - summary: Get draft workflow for snippet - operationId: get_snippet_draft_workflow - responses: - '200': - description: Draft workflow retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/Workflow' } - '404': { $ref: '#/components/responses/NotFound' } - post: - tags: [Snippet Workflows] - summary: Sync draft workflow - operationId: sync_snippet_draft_workflow - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/SnippetDraftSyncPayload' } - responses: - '200': - description: Draft synced - content: - application/json: - schema: - type: object - properties: - result: { type: string } - hash: { type: string } - updated_at: { type: number } - '400': { description: Hash mismatch } - - /snippets/{snippet_id}/workflows/draft/config: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippet Workflows] - summary: Get snippet draft workflow config limits - operationId: get_snippet_draft_config - responses: - '200': - description: Config retrieved - content: - application/json: - schema: - type: object - properties: - parallel_depth_limit: { type: integer } - - /snippets/{snippet_id}/workflows/publish: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippet Workflows] - summary: Get published workflow for snippet - operationId: get_snippet_published_workflow - responses: - '200': - description: Published workflow retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/Workflow' } - '404': { $ref: '#/components/responses/NotFound' } - post: - tags: [Snippet Workflows] - summary: Publish snippet workflow - operationId: publish_snippet_workflow - responses: - '200': - description: Workflow published - content: - application/json: - schema: - type: object - properties: - result: { type: string } - created_at: { type: number } - '400': { $ref: '#/components/responses/BadRequest' } - - /snippets/{snippet_id}/workflows/default-workflow-block-configs: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippet Workflows] - summary: Get default block configurations - operationId: get_snippet_default_block_configs - responses: - '200': { description: Default block configs retrieved } - - /snippets/{snippet_id}/workflow-runs: - parameters: - - $ref: '#/components/parameters/SnippetId' - get: - tags: [Snippet Workflows] - summary: List workflow runs for snippet - operationId: list_snippet_workflow_runs - parameters: - - name: last_id - in: query - schema: { type: string } - - $ref: '#/components/parameters/LimitParam' - responses: - '200': - description: Workflow runs retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/WorkflowRunPagination' } - - /snippets/{snippet_id}/workflow-runs/{run_id}: - parameters: - - $ref: '#/components/parameters/SnippetId' - - $ref: '#/components/parameters/RunId' - get: - tags: [Snippet Workflows] - summary: Get workflow run detail - operationId: get_snippet_workflow_run_detail - responses: - '200': - description: Run detail retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/WorkflowRunDetail' } - '404': { $ref: '#/components/responses/NotFound' } - - /snippets/{snippet_id}/workflow-runs/{run_id}/node-executions: - parameters: - - $ref: '#/components/parameters/SnippetId' - - $ref: '#/components/parameters/RunId' - get: - tags: [Snippet Workflows] - summary: List node executions for a workflow run - operationId: list_snippet_workflow_run_node_executions - responses: - '200': - description: Node executions retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/WorkflowNodeExecution' } } - - /snippets/{snippet_id}/workflows/draft/nodes/{node_id}/run: - parameters: - - $ref: '#/components/parameters/SnippetId' - - $ref: '#/components/parameters/NodeId' - post: - tags: [Snippet Workflows] - summary: Run a single node in draft workflow (single-step debug) - operationId: run_snippet_draft_node - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/SnippetDraftNodeRunPayload' } - responses: - '200': - description: Node run result - content: - application/json: - schema: { $ref: '#/components/schemas/WorkflowNodeExecution' } - '404': { $ref: '#/components/responses/NotFound' } - - /snippets/{snippet_id}/workflows/draft/nodes/{node_id}/last-run: - parameters: - - $ref: '#/components/parameters/SnippetId' - - $ref: '#/components/parameters/NodeId' - get: - tags: [Snippet Workflows] - summary: Get last run result for a node - operationId: get_snippet_draft_node_last_run - responses: - '200': - description: Node last run retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/WorkflowNodeExecution' } - '404': { $ref: '#/components/responses/NotFound' } - - /snippets/{snippet_id}/workflows/draft/iteration/nodes/{node_id}/run: - parameters: - - $ref: '#/components/parameters/SnippetId' - - $ref: '#/components/parameters/NodeId' - post: - tags: [Snippet Workflows] - summary: Run iteration node (SSE stream) - operationId: run_snippet_draft_iteration_node - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/SnippetIterationNodeRunPayload' } - responses: - '200': - description: SSE stream with iteration progress - content: - text/event-stream: {} - '404': { $ref: '#/components/responses/NotFound' } - - /snippets/{snippet_id}/workflows/draft/loop/nodes/{node_id}/run: - parameters: - - $ref: '#/components/parameters/SnippetId' - - $ref: '#/components/parameters/NodeId' - post: - tags: [Snippet Workflows] - summary: Run loop node (SSE stream) - operationId: run_snippet_draft_loop_node - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/SnippetLoopNodeRunPayload' } - responses: - '200': - description: SSE stream with loop progress - content: - text/event-stream: {} - '404': { $ref: '#/components/responses/NotFound' } - - /snippets/{snippet_id}/workflows/draft/run: - parameters: - - $ref: '#/components/parameters/SnippetId' - post: - tags: [Snippet Workflows] - summary: Run draft workflow (SSE stream) - operationId: run_snippet_draft_workflow - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/SnippetDraftRunPayload' } - responses: - '200': - description: SSE stream with execution progress - content: - text/event-stream: {} - '404': { $ref: '#/components/responses/NotFound' } - - /snippets/{snippet_id}/workflow-runs/tasks/{task_id}/stop: - parameters: - - $ref: '#/components/parameters/SnippetId' - - name: task_id - in: path - required: true - schema: { type: string } - post: - tags: [Snippet Workflows] - summary: Stop a running snippet workflow task - operationId: stop_snippet_workflow_task - responses: - '200': - description: Task stopped - content: - application/json: - schema: - type: object - properties: - result: { type: string } - - # ---------------------------------------------------------- - # Evaluation (App / Snippet targets) - # ---------------------------------------------------------- - - /{evaluate_target_type}/{evaluate_target_id}/dataset-template/download: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - post: - tags: [Evaluation] - summary: Download evaluation dataset template - operationId: download_evaluation_dataset_template - responses: - '200': - description: XLSX template streamed as attachment - content: - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: {} - '400': { $ref: '#/components/responses/BadRequest' } - '404': { $ref: '#/components/responses/NotFound' } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - get: - tags: [Evaluation] - summary: Get evaluation configuration - operationId: get_evaluation_detail - responses: - '200': - description: Evaluation configuration retrieved - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationConfig' } - '404': { $ref: '#/components/responses/NotFound' } - put: - tags: [Evaluation] - summary: Save evaluation configuration - operationId: save_evaluation_detail - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationConfigData' } - responses: - '200': - description: Configuration saved - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationConfig' } - '404': { $ref: '#/components/responses/NotFound' } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/logs: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - get: - tags: [Evaluation] - summary: Get evaluation run history - operationId: get_evaluation_logs - parameters: - - $ref: '#/components/parameters/PageParam' - - name: page_size - in: query - schema: { type: integer, default: 20 } - responses: - '200': - description: Evaluation logs retrieved - content: - application/json: - schema: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/EvaluationRun' } } - total: { type: integer } - page: { type: integer } - page_size: { type: integer } - '404': { $ref: '#/components/responses/NotFound' } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/run: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - post: - tags: [Evaluation] - summary: Start an evaluation run - operationId: start_evaluation_run - requestBody: - required: true - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationRunRequest' } - responses: - '200': - description: Evaluation run started - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationRun' } - '400': { $ref: '#/components/responses/BadRequest' } - '404': { $ref: '#/components/responses/NotFound' } - '429': { description: Max concurrent runs reached } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/runs/{run_id}: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - - $ref: '#/components/parameters/RunId' - get: - tags: [Evaluation] - summary: Get evaluation run detail with items - operationId: get_evaluation_run_detail - parameters: - - $ref: '#/components/parameters/PageParam' - - name: page_size - in: query - schema: { type: integer, default: 50 } - responses: - '200': - description: Run detail with paginated items - content: - application/json: - schema: - type: object - properties: - run: { $ref: '#/components/schemas/EvaluationRun' } - items: - type: object - properties: - data: { type: array, items: { $ref: '#/components/schemas/EvaluationRunItem' } } - total: { type: integer } - page: { type: integer } - page_size: { type: integer } - '404': { $ref: '#/components/responses/NotFound' } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/runs/{run_id}/cancel: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - - $ref: '#/components/parameters/RunId' - post: - tags: [Evaluation] - summary: Cancel a running evaluation - operationId: cancel_evaluation_run - responses: - '200': - description: Evaluation run cancelled - content: - application/json: - schema: { $ref: '#/components/schemas/EvaluationRun' } - '400': { $ref: '#/components/responses/BadRequest' } - '404': { $ref: '#/components/responses/NotFound' } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/metrics: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - get: - tags: [Evaluation] - summary: Get available evaluation metrics per category - operationId: get_evaluation_metrics - responses: - '200': - description: Metrics grouped by category - content: - application/json: - schema: - type: object - properties: - metrics: - type: object - additionalProperties: - type: array - items: { type: string } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/node-info: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - post: - tags: [Evaluation] - summary: Get workflow/snippet node info grouped by metric - operationId: get_evaluation_node_info - requestBody: - content: - application/json: - schema: - type: object - properties: - metrics: - type: array - items: { type: string } - description: Metric names to query. Omit or pass empty to get all nodes. - responses: - '200': - description: Node info grouped by metric or "all" - content: - application/json: - schema: - type: object - additionalProperties: - type: array - items: { $ref: '#/components/schemas/NodeInfo' } - '404': { $ref: '#/components/responses/NotFound' } - - /evaluation/available-metrics: - get: - tags: [Evaluation] - summary: Get centrally-defined list of evaluation metrics - operationId: get_available_evaluation_metrics - responses: - '200': - description: Available metrics list - content: - application/json: - schema: - type: object - properties: - metrics: - type: array - items: { type: string } - example: - - faithfulness - - answer_relevancy - - answer_correctness - - semantic_similarity - - context_precision - - context_recall - - context_relevance - - tool_correctness - - task_completion - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/files/{file_id}: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - - name: file_id - in: path - required: true - schema: { type: string, format: uuid } - get: - tags: [Evaluation] - summary: Download evaluation file - operationId: download_evaluation_file - responses: - '200': - description: File info and download URL - content: - application/json: - schema: { $ref: '#/components/schemas/FileInfo' } - '404': { $ref: '#/components/responses/NotFound' } - - /{evaluate_target_type}/{evaluate_target_id}/evaluation/version: - parameters: - - $ref: '#/components/parameters/EvaluateTargetType' - - $ref: '#/components/parameters/EvaluateTargetId' - get: - tags: [Evaluation] - summary: Get evaluation target version details - operationId: get_evaluation_version_detail - parameters: - - name: version - in: query - required: true - schema: { type: string } - responses: - '200': - description: Version graph retrieved - content: - application/json: - schema: - type: object - properties: - graph: { type: object } - '400': { $ref: '#/components/responses/BadRequest' } - '404': { $ref: '#/components/responses/NotFound' } - -# ============================================================ -# Components -# ============================================================ -components: - - # ---------- Parameters ---------- - parameters: - PageParam: - name: page - in: query - schema: { type: integer, default: 1 } - LimitParam: - name: limit - in: query - schema: { type: integer, default: 20 } - DatasetId: - name: dataset_id - in: path - required: true - schema: { type: string, format: uuid } - SnippetId: - name: snippet_id - in: path - required: true - schema: { type: string, format: uuid } - RunId: - name: run_id - in: path - required: true - schema: { type: string, format: uuid } - NodeId: - name: node_id - in: path - required: true - schema: { type: string } - EvaluateTargetType: - name: evaluate_target_type - in: path - required: true - schema: - type: string - enum: [app, snippets] - description: "Evaluation target type: app or snippets" - EvaluateTargetId: - name: evaluate_target_id - in: path - required: true - schema: { type: string, format: uuid } - description: Evaluation target ID (App ID or Snippet ID) - - # ---------- Responses ---------- - responses: - BadRequest: - description: Invalid request - content: - application/json: - schema: - type: object - properties: - message: { type: string } - NotFound: - description: Resource not found - content: - application/json: - schema: - type: object - properties: - message: { type: string } - Forbidden: - description: Permission denied - content: - application/json: - schema: - type: object - properties: - message: { type: string } - - # ---------- Schemas ---------- - schemas: - - # -- Dataset -- - DatasetDetail: - type: object - properties: - id: { type: string, format: uuid } - name: { type: string } - description: { type: string } - provider: { type: string } - permission: { type: string } - indexing_technique: { type: string } - embedding_model: { type: string } - embedding_model_provider: { type: string } - embedding_available: { type: boolean } - created_at: { type: number } - updated_at: { type: number } - - DatasetCreatePayload: - type: object - required: [name] - properties: - name: { type: string, minLength: 1, maxLength: 40 } - description: { type: string, maxLength: 400 } - indexing_technique: { type: string } - permission: { type: string, enum: [only_me, all_team_members, partial_members] } - provider: { type: string, default: vendor } - external_knowledge_api_id: { type: string } - external_knowledge_id: { type: string } - - DatasetUpdatePayload: - type: object - properties: - name: { type: string, minLength: 1, maxLength: 40 } - description: { type: string, maxLength: 400 } - permission: { type: string } - indexing_technique: { type: string } - embedding_model: { type: string } - embedding_model_provider: { type: string } - retrieval_model: { type: object } - icon_info: { type: object } - - IndexingEstimatePayload: - type: object - required: [info_list, process_rule, indexing_technique] - properties: - info_list: { type: object } - process_rule: { type: object } - indexing_technique: { type: string } - doc_form: { type: string, default: text_model } - dataset_id: { type: string } - doc_language: { type: string, default: English } - - ApiKeyItem: - type: object - properties: - id: { type: string, format: uuid } - type: { type: string } - token: { type: string } - created_at: { type: number } - - # -- Snippet -- - Snippet: - type: object - properties: - id: { type: string, format: uuid } - name: { type: string } - description: { type: string } - type: { type: string, enum: [node, group] } - is_published: { type: boolean } - version: { type: string } - use_count: { type: integer } - icon_info: { type: object } - input_fields: { type: array, items: { type: object } } - created_at: { type: number } - updated_at: { type: number } - - SnippetListItem: - type: object - properties: - id: { type: string, format: uuid } - name: { type: string } - description: { type: string } - type: { type: string } - is_published: { type: boolean } - use_count: { type: integer } - icon_info: { type: object } - created_at: { type: number } - updated_at: { type: number } - - CreateSnippetPayload: - type: object - required: [name] - properties: - name: { type: string } - description: { type: string } - type: { type: string, enum: [node, group] } - icon_info: { type: object } - input_fields: { type: array, items: { type: object } } - - UpdateSnippetPayload: - type: object - properties: - name: { type: string } - description: { type: string } - icon_info: { type: object } - - SnippetImportPayload: - type: object - properties: - mode: { type: string } - yaml_content: { type: string } - yaml_url: { type: string } - snippet_id: { type: string } - name: { type: string } - description: { type: string } - - # -- Snippet Workflow -- - Workflow: - type: object - properties: - id: { type: string, format: uuid } - graph: { type: object } - features: { type: object } - hash: { type: string } - created_at: { type: number } - updated_at: { type: number } - - SnippetDraftSyncPayload: - type: object - properties: - graph: { type: object } - hash: { type: string } - environment_variables: { type: array, items: { type: object } } - conversation_variables: { type: array, items: { type: object } } - input_variables: { type: array, items: { type: object } } - - SnippetDraftNodeRunPayload: - type: object - properties: - inputs: { type: object } - query: { type: string } - files: { type: array, items: { type: object } } - - SnippetDraftRunPayload: - type: object - properties: - inputs: { type: object } - files: { type: array, items: { type: object } } - - SnippetIterationNodeRunPayload: - type: object - properties: - inputs: { type: object } - - SnippetLoopNodeRunPayload: - type: object - properties: - inputs: { type: object } - - WorkflowRunPagination: - type: object - properties: - limit: { type: integer } - has_more: { type: boolean } - data: { type: array, items: { $ref: '#/components/schemas/WorkflowRunDetail' } } - - WorkflowRunDetail: - type: object - properties: - id: { type: string, format: uuid } - version: { type: string } - status: { type: string, enum: [running, succeeded, failed, stopped, partial-succeeded] } - elapsed_time: { type: number } - total_tokens: { type: integer } - total_steps: { type: integer } - created_at: { type: number } - finished_at: { type: number } - exceptions_count: { type: integer } - - WorkflowNodeExecution: - type: object - properties: - id: { type: string, format: uuid } - index: { type: integer } - node_id: { type: string } - node_type: { type: string } - title: { type: string } - inputs: { type: object } - process_data: { type: object } - outputs: { type: object } - status: { type: string } - error: { type: string } - elapsed_time: { type: number } - created_at: { type: number } - finished_at: { type: number } - - # -- Evaluation -- - EvaluationConfig: - type: object - properties: - evaluation_model: { type: string, nullable: true } - evaluation_model_provider: { type: string, nullable: true } - metrics_config: { type: object, nullable: true } - judgement_conditions: { type: object, nullable: true } - - EvaluationConfigData: - type: object - properties: - evaluation_model: { type: string } - evaluation_model_provider: { type: string } - default_metrics: - type: array - items: - type: object - properties: - metric: { type: string } - node_info_list: - type: array - items: { $ref: '#/components/schemas/NodeInfo' } - customized_metrics: - type: object - nullable: true - properties: - evaluation_workflow_id: { type: string } - input_fields: { type: object } - output_fields: { type: array, items: { type: object } } - judgment_config: - type: object - nullable: true - - EvaluationRunRequest: - allOf: - - $ref: '#/components/schemas/EvaluationConfigData' - - type: object - required: [file_id] - properties: - file_id: { type: string, format: uuid } - - EvaluationRun: - type: object - properties: - id: { type: string, format: uuid } - tenant_id: { type: string, format: uuid } - target_type: { type: string } - target_id: { type: string, format: uuid } - evaluation_config_id: { type: string, format: uuid } - status: { type: string, enum: [pending, running, completed, failed, cancelled] } - dataset_file_id: { type: string, format: uuid, nullable: true } - result_file_id: { type: string, format: uuid, nullable: true } - total_items: { type: integer } - completed_items: { type: integer } - failed_items: { type: integer } - progress: { type: number } - metrics_summary: { type: object } - error: { type: string, nullable: true } - created_by: { type: string, format: uuid } - started_at: { type: number, nullable: true } - completed_at: { type: number, nullable: true } - created_at: { type: number } - - EvaluationRunItem: - type: object - properties: - id: { type: string, format: uuid } - item_index: { type: integer } - inputs: { type: object } - expected_output: { type: string, nullable: true } - actual_output: { type: string, nullable: true } - metrics: - type: array - items: - type: object - properties: - name: { type: string } - value: {} - details: { type: object } - judgment: { type: object } - metadata: { type: object } - error: { type: string, nullable: true } - overall_score: { type: number, nullable: true } - - NodeInfo: - type: object - properties: - node_id: { type: string } - type: { type: string } - title: { type: string } - - FileInfo: - type: object - properties: - id: { type: string, format: uuid } - name: { type: string } - size: { type: integer } - extension: { type: string } - mime_type: { type: string } - created_at: { type: number } - download_url: { type: string } diff --git a/api/services/evaluation_service.py b/api/services/evaluation_service.py index f7993f2333..d70217f555 100644 --- a/api/services/evaluation_service.py +++ b/api/services/evaluation_service.py @@ -22,8 +22,8 @@ from core.evaluation.entities.evaluation_entity import ( NodeInfo, ) from core.evaluation.evaluation_manager import EvaluationManager -from core.workflow.enums import WorkflowNodeExecutionMetadataKey -from core.workflow.node_events.base import NodeRunResult +from dify_graph.enums import WorkflowNodeExecutionMetadataKey +from dify_graph.node_events.base import NodeRunResult from models.evaluation import ( EvaluationConfiguration, EvaluationRun, @@ -727,7 +727,7 @@ class EvaluationService: """Query all node execution records for a workflow run.""" from sqlalchemy import asc, select - from core.workflow.enums import WorkflowNodeExecutionStatus + from dify_graph.enums import WorkflowNodeExecutionStatus from models.workflow import WorkflowNodeExecutionModel stmt = ( diff --git a/api/services/snippet_dsl_service.py b/api/services/snippet_dsl_service.py index a270389ddc..d0c34501fe 100644 --- a/api/services/snippet_dsl_service.py +++ b/api/services/snippet_dsl_service.py @@ -7,15 +7,15 @@ from enum import StrEnum from urllib.parse import urlparse import yaml # type: ignore +from core.model_runtime.utils.encoders import jsonable_encoder from packaging import version from pydantic import BaseModel, Field from sqlalchemy import select from sqlalchemy.orm import Session from core.helper import ssrf_proxy -from core.model_runtime.utils.encoders import jsonable_encoder from core.plugin.entities.plugin import PluginDependency -from core.workflow.enums import NodeType +from dify_graph.enums import NodeType from extensions.ext_redis import redis_client from factories import variable_factory from models import Account diff --git a/api/services/snippet_generate_service.py b/api/services/snippet_generate_service.py index 7b32571bc1..6f59570f11 100644 --- a/api/services/snippet_generate_service.py +++ b/api/services/snippet_generate_service.py @@ -28,7 +28,7 @@ from sqlalchemy.orm import make_transient from core.app.app_config.features.file_upload.manager import FileUploadConfigManager from core.app.apps.workflow.app_generator import WorkflowAppGenerator from core.app.entities.app_invoke_entities import InvokeFrom -from core.workflow.file import File +from dify_graph.file.models import File from factories import file_factory from models import Account from models.model import AppMode, EndUser diff --git a/api/services/snippet_service.py b/api/services/snippet_service.py index db46dc8015..d7b7f7d6a0 100644 --- a/api/services/snippet_service.py +++ b/api/services/snippet_service.py @@ -7,9 +7,9 @@ from typing import Any from sqlalchemy import func, select from sqlalchemy.orm import Session, sessionmaker -from core.workflow.enums import NodeType -from core.workflow.nodes.node_mapping import LATEST_VERSION, NODE_TYPE_CLASSES_MAPPING -from core.workflow.variables.variables import VariableBase +from core.workflow.node_factory import LATEST_VERSION, NODE_TYPE_CLASSES_MAPPING +from dify_graph.enums import NodeType +from dify_graph.variables.variables import VariableBase from extensions.ext_database import db from libs.infinite_scroll_pagination import InfiniteScrollPagination from models import Account diff --git a/api/tasks/evaluation_task.py b/api/tasks/evaluation_task.py index 6e3aee5940..38233e22f6 100644 --- a/api/tasks/evaluation_task.py +++ b/api/tasks/evaluation_task.py @@ -24,7 +24,7 @@ from core.evaluation.runners.llm_evaluation_runner import LLMEvaluationRunner from core.evaluation.runners.retrieval_evaluation_runner import RetrievalEvaluationRunner from core.evaluation.runners.snippet_evaluation_runner import SnippetEvaluationRunner from core.evaluation.runners.workflow_evaluation_runner import WorkflowEvaluationRunner -from core.workflow.node_events.base import NodeRunResult +from dify_graph.node_events import NodeRunResult from extensions.ext_database import db from libs.datetime_utils import naive_utc_now from models.enums import CreatorUserRole