diff --git a/api/controllers/common/fields.py b/api/controllers/common/fields.py index 6a0b35aa633..7f16958090a 100644 --- a/api/controllers/common/fields.py +++ b/api/controllers/common/fields.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any +from typing import Any, Literal from pydantic import BaseModel, ConfigDict, Field, RootModel, computed_field @@ -8,7 +8,6 @@ from fields.base import ResponseModel from graphon.file import helpers as file_helpers from models.model import IconType -type JSONValue = str | int | float | bool | None | dict[str, Any] | list[Any] type JSONObject = dict[str, Any] @@ -24,10 +23,6 @@ class SimpleResultResponse(ResponseModel): result: str -class GeneratedAppResponse(RootModel[JSONValue]): - root: JSONValue - - class EventStreamResponse(RootModel[str]): root: str @@ -52,6 +47,11 @@ class AudioTranscriptResponse(ResponseModel): text: str +class ValidationResultResponse(ResponseModel): + result: Literal["success", "error"] + error: str | None = None + + class SimpleResultMessageResponse(ResponseModel): result: str message: str diff --git a/api/controllers/console/app/completion.py b/api/controllers/console/app/completion.py index 545fad34cde..73201af44c6 100644 --- a/api/controllers/console/app/completion.py +++ b/api/controllers/console/app/completion.py @@ -8,7 +8,7 @@ from pydantic import BaseModel, Field, field_validator from werkzeug.exceptions import BadRequest, InternalServerError, NotFound import services -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import SimpleResultResponse from controllers.common.schema import register_response_schema_models, register_schema_models from controllers.console import console_ns from controllers.console.agent.app_helpers import resolve_agent_app_model @@ -103,7 +103,7 @@ class ChatMessagePayload(BaseMessagePayload): register_schema_models(console_ns, CompletionMessagePayload, ChatMessagePayload) -register_response_schema_models(console_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(console_ns, SimpleResultResponse) # define completion message api for user @@ -113,7 +113,7 @@ class CompletionMessageApi(Resource): @console_ns.doc(description="Generate completion message for debugging") @console_ns.doc(params={"app_id": "Application ID"}) @console_ns.expect(console_ns.models[CompletionMessagePayload.__name__]) - @console_ns.response(200, "Completion generated successfully", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Completion generated successfully") @console_ns.response(400, "Invalid request parameters") @console_ns.response(404, "App not found") @setup_required @@ -134,6 +134,7 @@ class CompletionMessageApi(Resource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.DEBUGGER, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -177,7 +178,7 @@ class CompletionMessageStopApi(Resource): app_mode=AppMode.value_of(app_model.mode), ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 @console_ns.route("/apps//chat-messages") @@ -186,7 +187,7 @@ class ChatMessageApi(Resource): @console_ns.doc(description="Generate chat message for debugging") @console_ns.doc(params={"app_id": "Application ID"}) @console_ns.expect(console_ns.models[ChatMessagePayload.__name__]) - @console_ns.response(200, "Chat message generated successfully", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Chat message generated successfully") @console_ns.response(400, "Invalid request parameters") @console_ns.response(404, "App or conversation not found") @setup_required @@ -207,7 +208,7 @@ class AgentChatMessageApi(Resource): @console_ns.doc(description="Generate an Agent App chat message for debugging") @console_ns.doc(params={"agent_id": "Agent ID"}) @console_ns.expect(console_ns.models[ChatMessagePayload.__name__]) - @console_ns.response(200, "Chat message generated successfully", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Chat message generated successfully") @console_ns.response(400, "Invalid request parameters") @console_ns.response(404, "Agent or conversation not found") @setup_required @@ -315,6 +316,7 @@ def _create_chat_message( app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.DEBUGGER, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -348,4 +350,4 @@ def _stop_chat_message(*, current_user_id: str, app_model: App, task_id: str): app_mode=AppMode.value_of(app_model.mode), ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 diff --git a/api/controllers/console/app/message.py b/api/controllers/console/app/message.py index 195a41f2888..f987ecca745 100644 --- a/api/controllers/console/app/message.py +++ b/api/controllers/console/app/message.py @@ -167,12 +167,16 @@ register_schema_models( ChatMessagesQuery, MessageFeedbackPayload, FeedbackExportQuery, +) +register_response_schema_models( + console_ns, AnnotationCountResponse, SuggestedQuestionsResponse, MessageDetailResponse, MessageInfiniteScrollPaginationResponse, + SimpleResultResponse, + TextFileResponse, ) -register_response_schema_models(console_ns, SimpleResultResponse, TextFileResponse) @console_ns.route("/apps//chat-messages") diff --git a/api/controllers/console/app/workflow.py b/api/controllers/console/app/workflow.py index aff32035233..e92d3266d9e 100644 --- a/api/controllers/console/app/workflow.py +++ b/api/controllers/console/app/workflow.py @@ -1,19 +1,19 @@ import json import logging -from collections.abc import Sequence +from collections.abc import Mapping, Sequence from datetime import datetime -from typing import Any, NotRequired, TypedDict, cast +from typing import Any, Literal, NotRequired, TypedDict, cast from flask import abort, request -from flask_restx import Resource, fields -from pydantic import AliasChoices, BaseModel, Field, RootModel, ValidationError, field_validator +from flask_restx import Resource +from pydantic import AliasChoices, BaseModel, Field, ValidationError, field_validator from sqlalchemy.orm import Session, sessionmaker from werkzeug.exceptions import BadRequest, Forbidden, InternalServerError, NotFound import services from controllers.common.controller_schemas import DefaultBlockConfigQuery, WorkflowListQuery, WorkflowUpdatePayload from controllers.common.errors import InvalidArgumentError -from controllers.common.fields import GeneratedAppResponse, NewAppResponse, SimpleResultResponse +from controllers.common.fields import NewAppResponse, SimpleResultResponse from controllers.common.schema import ( query_params_from_model, register_response_schema_model, @@ -21,11 +21,7 @@ from controllers.common.schema import ( register_schema_models, ) from controllers.console import console_ns -from controllers.console.app.error import ( - ConversationCompletedError, - DraftWorkflowNotExist, - DraftWorkflowNotSync, -) +from controllers.console.app.error import ConversationCompletedError, DraftWorkflowNotExist, DraftWorkflowNotSync from controllers.console.app.permission_keys import get_app_permission_keys from controllers.console.app.wraps import get_app_model from controllers.console.wraps import ( @@ -58,7 +54,7 @@ from extensions.ext_database import db from extensions.ext_redis import redis_client from factories import file_factory, variable_factory from fields.base import ResponseModel -from fields.member_fields import SimpleAccount +from fields.member_fields import SimpleAccountResponse from fields.workflow_run_fields import WorkflowRunNodeExecutionResponse from graphon.enums import NodeType from graphon.file import File @@ -69,7 +65,7 @@ from graphon.variables import SecretVariable, SegmentType, VariableBase from graphon.variables.exc import VariableError from libs import helper from libs.datetime_utils import naive_utc_now -from libs.helper import TimestampField, dump_response, to_timestamp, uuid_value +from libs.helper import dump_response, to_timestamp, uuid_value from libs.login import login_required from models import Account, App from models.model import AppMode @@ -103,20 +99,16 @@ class SyncDraftWorkflowPayload(BaseModel): graph: dict[str, Any] features: dict[str, Any] hash: str | None = None - environment_variables: list[dict[str, Any]] = Field( - default_factory=list, - ) - conversation_variables: list[dict[str, Any]] = Field( - default_factory=list, - ) + environment_variables: list[dict[str, Any]] = Field(default_factory=list) + conversation_variables: list[dict[str, Any]] = Field(default_factory=list) class BaseWorkflowRunPayload(BaseModel): - files: list[dict[str, Any]] | None = Field(default=None) + files: list[dict[str, Any]] | None = None class AdvancedChatWorkflowRunPayload(BaseWorkflowRunPayload): - inputs: dict[str, Any] | None = Field(default=None) + inputs: dict[str, Any] | None = None query: str = "" conversation_id: str | None = None parent_message_id: str | None = None @@ -130,11 +122,11 @@ class AdvancedChatWorkflowRunPayload(BaseWorkflowRunPayload): class IterationNodeRunPayload(BaseModel): - inputs: dict[str, Any] | None = Field(default=None) + inputs: dict[str, Any] | None = None class LoopNodeRunPayload(BaseModel): - inputs: dict[str, Any] | None = Field(default=None) + inputs: dict[str, Any] | None = None class DraftWorkflowRunPayload(BaseWorkflowRunPayload): @@ -159,10 +151,7 @@ class ConvertToWorkflowPayload(BaseModel): class WorkflowFeaturesPayload(BaseModel): - features: dict[str, Any] = Field( - ..., - description="Workflow feature configuration", - ) + features: dict[str, Any] = Field(..., description="Workflow feature configuration") class WorkflowOnlineUsersPayload(BaseModel): @@ -197,7 +186,7 @@ class PipelineVariableResponse(ResponseModel): max_length: int | None = None required: bool unit: str | None = None - default_value: Any = Field(default=None) + default_value: Any = None options: list[str] | None = None placeholder: str | None = None tooltips: str | None = None @@ -220,21 +209,17 @@ class WorkflowEnvironmentVariableResponse(ResponseModel): class WorkflowResponse(ResponseModel): id: str - graph: dict[str, Any] = Field( - validation_alias=AliasChoices("graph_dict", "graph"), - ) - features: dict[str, Any] = Field( - validation_alias=AliasChoices("features_dict", "features"), - ) + graph: dict[str, Any] = Field(validation_alias=AliasChoices("graph_dict", "graph")) + features: dict[str, Any] = Field(validation_alias=AliasChoices("features_dict", "features")) hash: str = Field(validation_alias=AliasChoices("unique_hash", "hash")) version: str marked_name: str marked_comment: str - created_by: SimpleAccount | None = Field( + created_by: SimpleAccountResponse | None = Field( default=None, validation_alias=AliasChoices("created_by_account", "created_by") ) created_at: int - updated_by: SimpleAccount | None = Field( + updated_by: SimpleAccountResponse | None = Field( default=None, validation_alias=AliasChoices("updated_by_account", "updated_by") ) updated_at: int @@ -267,6 +252,53 @@ class WorkflowPaginationResponse(ResponseModel): has_more: bool +class SyncDraftWorkflowResponse(ResponseModel): + result: str + hash: str + updated_at: int + + +class PublishWorkflowResponse(ResponseModel): + result: str + created_at: int + + +class HumanInputUserActionResponse(ResponseModel): + id: str + title: str + button_style: str = "default" + + +class HumanInputFormPreviewResponse(ResponseModel): + # Draft previews are shape-compatible with live human_input_required events, + # but they do not persist a form or mint recipient tokens (no expiration_time) + type_: Literal["human_input_required"] = Field(default="human_input_required", alias="TYPE") + form_id: str + form_content: str + inputs: list[Mapping[str, Any]] = Field(default_factory=list) + actions: list[HumanInputUserActionResponse] = Field(default_factory=list) + node_id: str + node_title: str + resolved_default_values: Mapping[str, Any] = Field(default_factory=dict) + display_in_ui: bool = Field(default=False, description="Always false for draft preview responses.") + form_token: str | None = Field(default=None, description="Always null for draft preview responses.") + expiration_time: int | None = Field(default=None, description="Always null for draft preview responses.") + + +class HumanInputDeliveryTestResponse(ResponseModel): + pass + + +class TriggerDebugWaitingResponse(ResponseModel): + status: Literal["waiting"] + retry_in: int + + +class TriggerDebugErrorResponse(ResponseModel): + status: Literal["error"] + error: str | None = None + + class WorkflowOnlineUser(ResponseModel): user_id: str username: str @@ -282,46 +314,6 @@ class WorkflowOnlineUsersResponse(ResponseModel): data: list[WorkflowOnlineUsersByApp] -class WorkflowPublishResponse(ResponseModel): - result: str - created_at: int - - -class WorkflowRestoreResponse(ResponseModel): - result: str - hash: str - updated_at: int - - -class DefaultBlockConfigsResponse(RootModel[list[dict[str, Any]]]): - root: list[dict[str, Any]] - - -class DefaultBlockConfigResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - -class HumanInputFormPreviewResponse(ResponseModel): - form_id: str - node_id: str - node_title: str - form_content: str - inputs: list[dict[str, Any]] = Field(default_factory=list) - actions: list[dict[str, Any]] = Field(default_factory=list) - display_in_ui: bool | None = None - form_token: str | None = None - resolved_default_values: dict[str, Any] = Field(default_factory=dict) - expiration_time: int | None = None - - -class HumanInputFormSubmitResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - -class EmptyObjectResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - class DraftWorkflowTriggerRunPayload(BaseModel): node_id: str @@ -356,19 +348,19 @@ register_response_schema_models( WorkflowEnvironmentVariableResponse, WorkflowResponse, WorkflowPaginationResponse, + SyncDraftWorkflowResponse, + PublishWorkflowResponse, + HumanInputUserActionResponse, + HumanInputFormPreviewResponse, + HumanInputDeliveryTestResponse, + TriggerDebugWaitingResponse, + TriggerDebugErrorResponse, WorkflowOnlineUser, WorkflowOnlineUsersByApp, WorkflowOnlineUsersResponse, - WorkflowPublishResponse, - WorkflowRestoreResponse, - DefaultBlockConfigsResponse, - DefaultBlockConfigResponse, - HumanInputFormPreviewResponse, - HumanInputFormSubmitResponse, - EmptyObjectResponse, - GeneratedAppResponse, NewAppResponse, SimpleResultResponse, + WorkflowRunNodeExecutionResponse, ) @@ -426,6 +418,14 @@ def _serialize_environment_variable(value: Any) -> EnvironmentVariableResponseDi return value +def _trigger_debug_waiting_response() -> dict[str, int | str]: + return TriggerDebugWaitingResponse(status="waiting", retry_in=LISTENING_RETRY_IN).model_dump(mode="json") + + +def _trigger_debug_error_response(error: str | None = None) -> dict[str, str]: + return TriggerDebugErrorResponse(status="error", error=error).model_dump(mode="json", exclude_none=True) + + @console_ns.route("/apps//workflows/draft") class DraftWorkflowApi(Resource): @console_ns.doc("get_draft_workflow") @@ -475,14 +475,7 @@ class DraftWorkflowApi(Resource): @console_ns.response( 200, "Draft workflow synced successfully", - console_ns.model( - "SyncDraftWorkflowResponse", - { - "result": fields.String, - "hash": fields.String, - "updated_at": fields.String, - }, - ), + console_ns.models[SyncDraftWorkflowResponse.__name__], ) @console_ns.response(400, "Invalid workflow configuration") @console_ns.response(403, "Permission denied") @@ -535,11 +528,11 @@ class DraftWorkflowApi(Resource): except VariableError as e: raise InvalidArgumentError(description=str(e)) - return { - "result": "success", - "hash": workflow.unique_hash, - "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at), - } + return SyncDraftWorkflowResponse( + result="success", + hash=workflow.unique_hash, + updated_at=to_timestamp(workflow.updated_at or workflow.created_at), + ).model_dump(mode="json") @console_ns.route("/apps//advanced-chat/workflows/draft/run") @@ -548,7 +541,7 @@ class AdvancedChatDraftWorkflowRunApi(Resource): @console_ns.doc(description="Run draft workflow for advanced chat application") @console_ns.doc(params={"app_id": "Application ID"}) @console_ns.expect(console_ns.models[AdvancedChatWorkflowRunPayload.__name__]) - @console_ns.response(200, "Workflow run started successfully", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Workflow run started successfully") @console_ns.response(400, "Invalid request parameters") @console_ns.response(403, "Permission denied") @setup_required @@ -574,6 +567,7 @@ class AdvancedChatDraftWorkflowRunApi(Resource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.DEBUGGER, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -594,11 +588,7 @@ class AdvancedChatDraftRunIterationNodeApi(Resource): @console_ns.doc(description="Run draft workflow iteration node for advanced chat") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[IterationNodeRunPayload.__name__]) - @console_ns.response( - 200, - "Iteration node run started successfully", - console_ns.models[GeneratedAppResponse.__name__], - ) + @console_ns.response(200, "Iteration node run started successfully") @console_ns.response(403, "Permission denied") @console_ns.response(404, "Node not found") @setup_required @@ -619,6 +609,7 @@ class AdvancedChatDraftRunIterationNodeApi(Resource): app_model=app_model, user=current_user, node_id=node_id, args=args, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -637,11 +628,7 @@ class WorkflowDraftRunIterationNodeApi(Resource): @console_ns.doc(description="Run draft workflow iteration node") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[IterationNodeRunPayload.__name__]) - @console_ns.response( - 200, - "Workflow iteration node run started successfully", - console_ns.models[GeneratedAppResponse.__name__], - ) + @console_ns.response(200, "Workflow iteration node run started successfully") @console_ns.response(403, "Permission denied") @console_ns.response(404, "Node not found") @setup_required @@ -662,6 +649,7 @@ class WorkflowDraftRunIterationNodeApi(Resource): app_model=app_model, user=current_user, node_id=node_id, args=args, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -680,7 +668,7 @@ class AdvancedChatDraftRunLoopNodeApi(Resource): @console_ns.doc(description="Run draft workflow loop node for advanced chat") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[LoopNodeRunPayload.__name__]) - @console_ns.response(200, "Loop node run started successfully", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Loop node run started successfully") @console_ns.response(403, "Permission denied") @console_ns.response(404, "Node not found") @setup_required @@ -701,6 +689,7 @@ class AdvancedChatDraftRunLoopNodeApi(Resource): app_model=app_model, user=current_user, node_id=node_id, args=args, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -719,11 +708,7 @@ class WorkflowDraftRunLoopNodeApi(Resource): @console_ns.doc(description="Run draft workflow loop node") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[LoopNodeRunPayload.__name__]) - @console_ns.response( - 200, - "Workflow loop node run started successfully", - console_ns.models[GeneratedAppResponse.__name__], - ) + @console_ns.response(200, "Workflow loop node run started successfully") @console_ns.response(403, "Permission denied") @console_ns.response(404, "Node not found") @setup_required @@ -744,6 +729,7 @@ class WorkflowDraftRunLoopNodeApi(Resource): app_model=app_model, user=current_user, node_id=node_id, args=args, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -764,10 +750,7 @@ class HumanInputFormPreviewPayload(BaseModel): class HumanInputFormSubmitPayload(BaseModel): - form_inputs: dict[str, Any] = Field( - ..., - description="Values the user provides for the form's own fields", - ) + form_inputs: dict[str, Any] = Field(..., description="Values the user provides for the form's own fields") inputs: dict[str, Any] = Field( ..., description="Values used to fill missing upstream variables referenced in form_content", @@ -797,7 +780,11 @@ class AdvancedChatDraftHumanInputFormPreviewApi(Resource): @console_ns.doc(description="Get human input form preview for advanced chat workflow") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[HumanInputFormPreviewPayload.__name__]) - @console_ns.response(200, "Human input form preview", console_ns.models[HumanInputFormPreviewResponse.__name__]) + @console_ns.response( + 200, + "Human input form preview retrieved", + console_ns.models[HumanInputFormPreviewResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -819,7 +806,7 @@ class AdvancedChatDraftHumanInputFormPreviewApi(Resource): node_id=node_id, inputs=inputs, ) - return jsonable_encoder(preview) + return dump_response(HumanInputFormPreviewResponse, preview) @console_ns.route("/apps//advanced-chat/workflows/draft/human-input/nodes//form/run") @@ -830,8 +817,7 @@ class AdvancedChatDraftHumanInputFormRunApi(Resource): @console_ns.expect(console_ns.models[HumanInputFormSubmitPayload.__name__]) @console_ns.response( 200, - "Human input form submission result", - console_ns.models[HumanInputFormSubmitResponse.__name__], + "Human input form submitted", ) @setup_required @login_required @@ -854,6 +840,7 @@ class AdvancedChatDraftHumanInputFormRunApi(Resource): inputs=args.inputs, action=args.action, ) + # TODO: typing here for result return jsonable_encoder(result) @@ -863,7 +850,11 @@ class WorkflowDraftHumanInputFormPreviewApi(Resource): @console_ns.doc(description="Get human input form preview for workflow") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[HumanInputFormPreviewPayload.__name__]) - @console_ns.response(200, "Human input form preview", console_ns.models[HumanInputFormPreviewResponse.__name__]) + @console_ns.response( + 200, + "Human input form preview retrieved", + console_ns.models[HumanInputFormPreviewResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -885,7 +876,7 @@ class WorkflowDraftHumanInputFormPreviewApi(Resource): node_id=node_id, inputs=inputs, ) - return jsonable_encoder(preview) + return dump_response(HumanInputFormPreviewResponse, preview) @console_ns.route("/apps//workflows/draft/human-input/nodes//form/run") @@ -896,8 +887,7 @@ class WorkflowDraftHumanInputFormRunApi(Resource): @console_ns.expect(console_ns.models[HumanInputFormSubmitPayload.__name__]) @console_ns.response( 200, - "Human input form submission result", - console_ns.models[HumanInputFormSubmitResponse.__name__], + "Human input form submitted", ) @setup_required @login_required @@ -920,6 +910,7 @@ class WorkflowDraftHumanInputFormRunApi(Resource): inputs=args.inputs, action=args.action, ) + # TODO: typing here return jsonable_encoder(result) @@ -929,7 +920,11 @@ class WorkflowDraftHumanInputDeliveryTestApi(Resource): @console_ns.doc(description="Test human input delivery for workflow") @console_ns.doc(params={"app_id": "Application ID", "node_id": "Node ID"}) @console_ns.expect(console_ns.models[HumanInputDeliveryTestPayload.__name__]) - @console_ns.response(200, "Human input delivery test result", console_ns.models[EmptyObjectResponse.__name__]) + @console_ns.response( + 200, + "Human input delivery tested", + console_ns.models[HumanInputDeliveryTestResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -950,7 +945,7 @@ class WorkflowDraftHumanInputDeliveryTestApi(Resource): delivery_method_id=args.delivery_method_id, inputs=args.inputs, ) - return jsonable_encoder({}) + return HumanInputDeliveryTestResponse().model_dump(mode="json") @console_ns.route("/apps//workflows/draft/run") @@ -959,11 +954,7 @@ class DraftWorkflowRunApi(Resource): @console_ns.doc(description="Run draft workflow") @console_ns.doc(params={"app_id": "Application ID"}) @console_ns.expect(console_ns.models[DraftWorkflowRunPayload.__name__]) - @console_ns.response( - 200, - "Draft workflow run started successfully", - console_ns.models[GeneratedAppResponse.__name__], - ) + @console_ns.response(200, "Draft workflow run started successfully") @console_ns.response(403, "Permission denied") @setup_required @login_required @@ -991,6 +982,7 @@ class DraftWorkflowRunApi(Resource): streaming=True, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except InvokeRateLimitError as ex: raise InvokeRateLimitHttpError(ex.description) @@ -1021,7 +1013,7 @@ class WorkflowTaskStopApi(Resource): # New graph engine command channel mechanism GraphEngineManager(redis_client).send_stop_command(task_id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") @console_ns.route("/apps//workflows/draft/nodes//run") @@ -1109,7 +1101,7 @@ class PublishedWorkflowApi(Resource): return dump_response(WorkflowResponse, workflow) @console_ns.expect(console_ns.models[PublishWorkflowPayload.__name__]) - @console_ns.response(200, "Workflow published successfully", console_ns.models[WorkflowPublishResponse.__name__]) + @console_ns.response(200, "Workflow published successfully", console_ns.models[PublishWorkflowResponse.__name__]) @setup_required @login_required @account_initialization_required @@ -1141,12 +1133,9 @@ class PublishedWorkflowApi(Resource): app_model_in_session.updated_by = current_user.id app_model_in_session.updated_at = naive_utc_now() - workflow_created_at = TimestampField().format(workflow.created_at) + workflow_created_at = to_timestamp(workflow.created_at) - return { - "result": "success", - "created_at": workflow_created_at, - } + return PublishWorkflowResponse(result="success", created_at=workflow_created_at).model_dump(mode="json") @console_ns.route("/apps//workflows/default-workflow-block-configs") @@ -1157,7 +1146,6 @@ class DefaultBlockConfigsApi(Resource): @console_ns.response( 200, "Default block configurations retrieved successfully", - console_ns.models[DefaultBlockConfigsResponse.__name__], ) @setup_required @login_required @@ -1179,13 +1167,12 @@ class DefaultBlockConfigApi(Resource): @console_ns.doc("get_default_block_config") @console_ns.doc(description="Get default block configuration by type") @console_ns.doc(params={"app_id": "Application ID", "block_type": "Block type"}) + @console_ns.doc(params=query_params_from_model(DefaultBlockConfigQuery)) @console_ns.response( 200, "Default block configuration retrieved successfully", - console_ns.models[DefaultBlockConfigResponse.__name__], ) @console_ns.response(404, "Block type not found") - @console_ns.doc(params=query_params_from_model(DefaultBlockConfigQuery)) @setup_required @login_required @account_initialization_required @@ -1279,15 +1266,14 @@ class WorkflowFeaturesApi(Resource): workflow_service = WorkflowService() workflow_service.update_draft_workflow_features(app_model=app_model, features=features, account=current_user) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") @console_ns.route("/apps//workflows") class PublishedAllWorkflowApi(Resource): - @console_ns.doc(params=query_params_from_model(WorkflowListQuery)) @console_ns.doc("get_all_published_workflows") @console_ns.doc(description="Get all published workflows for an application") - @console_ns.doc(params={"app_id": "Application ID"}) + @console_ns.doc(params={"app_id": "Application ID", **query_params_from_model(WorkflowListQuery)}) @console_ns.response( 200, "Published workflows retrieved successfully", @@ -1340,7 +1326,11 @@ class DraftWorkflowRestoreApi(Resource): @console_ns.doc("restore_workflow_to_draft") @console_ns.doc(description="Restore a published workflow version into the draft workflow") @console_ns.doc(params={"app_id": "Application ID", "workflow_id": "Published workflow ID"}) - @console_ns.response(200, "Workflow restored successfully", console_ns.models[WorkflowRestoreResponse.__name__]) + @console_ns.response( + 200, + "Workflow restored successfully", + console_ns.models[SyncDraftWorkflowResponse.__name__], + ) @console_ns.response(400, "Source workflow must be published") @console_ns.response(404, "Workflow not found") @setup_required @@ -1366,11 +1356,11 @@ class DraftWorkflowRestoreApi(Resource): except ValueError as exc: raise BadRequest(str(exc)) from exc - return { - "result": "success", - "hash": workflow.unique_hash, - "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at), - } + return SyncDraftWorkflowResponse( + result="success", + hash=workflow.unique_hash, + updated_at=to_timestamp(workflow.updated_at or workflow.created_at), + ).model_dump(mode="json") @console_ns.route("/apps//workflows/") @@ -1422,6 +1412,7 @@ class WorkflowByIdApi(Resource): return dump_response(WorkflowResponse, workflow) + @console_ns.response(204, "Workflow deleted successfully") @setup_required @login_required @account_initialization_required @@ -1480,7 +1471,7 @@ class DraftWorkflowNodeLastRunApi(Resource): ) if node_exec is None: raise NotFound("last run not found") - return WorkflowRunNodeExecutionResponse.model_validate(node_exec, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionResponse, node_exec) @console_ns.route("/apps//workflows/draft/trigger/run") @@ -1493,19 +1484,8 @@ class DraftWorkflowTriggerRunApi(Resource): @console_ns.doc("poll_draft_workflow_trigger_run") @console_ns.doc(description="Poll for trigger events and execute full workflow when event arrives") @console_ns.doc(params={"app_id": "Application ID"}) - @console_ns.expect( - console_ns.model( - "DraftWorkflowTriggerRunRequest", - { - "node_id": fields.String(required=True, description="Node ID"), - }, - ) - ) - @console_ns.response( - 200, - "Trigger event received and workflow executed successfully", - console_ns.models[GeneratedAppResponse.__name__], - ) + @console_ns.expect(console_ns.models[DraftWorkflowTriggerRunPayload.__name__]) + @console_ns.response(200, "Trigger event received and workflow executed successfully") @console_ns.response(403, "Permission denied") @console_ns.response(500, "Internal server error") @setup_required @@ -1537,10 +1517,11 @@ class DraftWorkflowTriggerRunApi(Resource): try: event = poller.poll() if not event: - return jsonable_encoder({"status": "waiting", "retry_in": LISTENING_RETRY_IN}) + return _trigger_debug_waiting_response() workflow_args = dict(event.workflow_args) workflow_args[SKIP_PREPARE_USER_INPUTS_KEY] = True + # response-contract:ignore compact_generate_response return helper.compact_generate_response( AppGenerateService.generate( app_model=app_model, @@ -1554,7 +1535,7 @@ class DraftWorkflowTriggerRunApi(Resource): except InvokeRateLimitError as ex: raise InvokeRateLimitHttpError(ex.description) except PluginInvokeError as e: - return jsonable_encoder({"status": "error", "error": e.to_user_friendly_error()}), 400 + return _trigger_debug_error_response(e.to_user_friendly_error()), 400 except Exception as e: logger.exception("Error polling trigger debug event") raise e @@ -1573,7 +1554,7 @@ class DraftWorkflowTriggerNodeApi(Resource): @console_ns.response( 200, "Trigger event received and node executed successfully", - console_ns.models[GeneratedAppResponse.__name__], + console_ns.models[WorkflowRunNodeExecutionResponse.__name__], ) @console_ns.response(403, "Permission denied") @console_ns.response(500, "Internal server error") @@ -1617,12 +1598,12 @@ class DraftWorkflowTriggerNodeApi(Resource): ) event = poller.poll() except PluginInvokeError as e: - return jsonable_encoder({"status": "error", "error": e.to_user_friendly_error()}), 400 + return _trigger_debug_error_response(e.to_user_friendly_error()), 400 except Exception as e: logger.exception("Error polling trigger debug event") raise e if not event: - return jsonable_encoder({"status": "waiting", "retry_in": LISTENING_RETRY_IN}) + return _trigger_debug_waiting_response() raw_files = event.workflow_args.get("files") files = _parse_file(draft_workflow, raw_files if isinstance(raw_files, list) else None) @@ -1636,12 +1617,10 @@ class DraftWorkflowTriggerNodeApi(Resource): query="", files=files, ) - return jsonable_encoder(node_execution) + return dump_response(WorkflowRunNodeExecutionResponse, node_execution) except Exception as e: logger.exception("Error running draft workflow trigger node") - return jsonable_encoder( - {"status": "error", "error": "An unexpected error occurred while running the node."} - ), 400 + return _trigger_debug_error_response("An unexpected error occurred while running the node."), 400 @console_ns.route("/apps//workflows/draft/trigger/run-all") @@ -1655,7 +1634,7 @@ class DraftWorkflowTriggerRunAllApi(Resource): @console_ns.doc(description="Full workflow debug when the start node is a trigger") @console_ns.doc(params={"app_id": "Application ID"}) @console_ns.expect(console_ns.models[DraftWorkflowTriggerRunAllPayload.__name__]) - @console_ns.response(200, "Workflow executed successfully", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Workflow executed successfully") @console_ns.response(403, "Permission denied") @console_ns.response(500, "Internal server error") @setup_required @@ -1685,12 +1664,12 @@ class DraftWorkflowTriggerRunAllApi(Resource): node_ids=node_ids, ) except PluginInvokeError as e: - return jsonable_encoder({"status": "error", "error": e.to_user_friendly_error()}), 400 + return _trigger_debug_error_response(e.to_user_friendly_error()), 400 except Exception as e: logger.exception("Error polling trigger debug event") raise e if trigger_debug_event is None: - return jsonable_encoder({"status": "waiting", "retry_in": LISTENING_RETRY_IN}) + return _trigger_debug_waiting_response() try: workflow_args = dict(trigger_debug_event.workflow_args) @@ -1704,16 +1683,13 @@ class DraftWorkflowTriggerRunAllApi(Resource): streaming=True, root_node_id=trigger_debug_event.node_id, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except InvokeRateLimitError as ex: raise InvokeRateLimitHttpError(ex.description) except Exception: logger.exception("Error running draft workflow trigger run-all") - return jsonable_encoder( - { - "status": "error", - } - ), 400 + return _trigger_debug_error_response(), 400 @console_ns.route("/apps/workflows/online-users") @@ -1738,7 +1714,7 @@ class WorkflowOnlineUsersApi(Resource): raise BadRequest(f"Maximum {MAX_WORKFLOW_ONLINE_USERS_REQUEST_IDS} app_ids are allowed per request.") if not app_ids: - return {"data": []} + return WorkflowOnlineUsersResponse(data=[]).model_dump(mode="json") workflow_service = WorkflowService() accessible_app_ids = workflow_service.get_accessible_app_ids(app_ids, current_tenant_id) diff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py index fdc55ea9737..adf0a0006be 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py @@ -1,5 +1,6 @@ import json import logging +from collections.abc import Mapping from typing import Any, Literal, cast from uuid import UUID @@ -21,8 +22,6 @@ from controllers.console.app.error import ( ) from controllers.console.app.workflow import ( RESTORE_SOURCE_WORKFLOW_MUST_BE_PUBLISHED_MESSAGE, - DefaultBlockConfigResponse, - DefaultBlockConfigsResponse, WorkflowPaginationResponse, WorkflowResponse, ) @@ -41,6 +40,7 @@ from controllers.web.error import InvokeRateLimitError as InvokeRateLimitHttpErr from core.app.apps.base_app_queue_manager import AppQueueManager from core.app.apps.pipeline.pipeline_generator import PipelineGenerator from core.app.entities.app_invoke_entities import InvokeFrom +from core.plugin.entities.plugin_daemon import PluginDatasourceProviderEntity from extensions.ext_database import db from factories import variable_factory from fields.base import ResponseModel @@ -50,9 +50,8 @@ from fields.workflow_run_fields import ( WorkflowRunNodeExecutionResponse, WorkflowRunPaginationResponse, ) -from graphon.model_runtime.utils.encoders import jsonable_encoder from libs import helper -from libs.helper import TimestampField, UUIDStrOrEmpty, dump_response +from libs.helper import UUIDStrOrEmpty, dump_response, to_timestamp from libs.login import login_required from models import Account from models.dataset import Pipeline @@ -72,14 +71,14 @@ logger = logging.getLogger(__name__) class DraftWorkflowSyncPayload(BaseModel): graph: dict[str, Any] hash: str | None = None - environment_variables: list[dict[str, Any]] | None = Field(default=None) - conversation_variables: list[dict[str, Any]] | None = Field(default=None) - rag_pipeline_variables: list[dict[str, Any]] | None = Field(default=None) - features: dict[str, Any] | None = Field(default=None) + environment_variables: list[dict[str, Any]] | None = None + conversation_variables: list[dict[str, Any]] | None = None + rag_pipeline_variables: list[dict[str, Any]] | None = None + features: dict[str, Any] | None = None class NodeRunPayload(BaseModel): - inputs: dict[str, Any] | None = Field(default=None) + inputs: dict[str, Any] | None = None class NodeRunRequiredPayload(BaseModel): @@ -136,14 +135,30 @@ class RagPipelineWorkflowPublishResponse(ResponseModel): created_at: int -class RagPipelineOpaqueResponse(RootModel[Any]): - root: Any - - -class RagPipelineStepParametersResponse(ResponseModel): +class RagPipelineVariablesResponse(ResponseModel): + # TODO: Replace Any with a response model that mirrors graphon.variables.variables.RAGPipelineVariable. variables: Any +class DatasourcePluginListResponse(RootModel[list[PluginDatasourceProviderEntity]]): + pass + + +class RagPipelineRecommendedPluginResponse(ResponseModel): + installed_recommended_plugins: list[Mapping[str, object]] = Field( + description="Installed tool provider payloads. Shape follows the tool provider serializer." + ) + uninstalled_recommended_plugins: list[Mapping[str, object]] = Field( + description="Marketplace plugin manifest payloads returned by the marketplace service." + ) + + +class RagPipelineTransformResponse(ResponseModel): + pipeline_id: str + dataset_id: str + status: str + + register_schema_models( console_ns, DraftWorkflowSyncPayload, @@ -162,10 +177,10 @@ register_schema_models( ) register_response_schema_models( console_ns, - DefaultBlockConfigResponse, - DefaultBlockConfigsResponse, - RagPipelineOpaqueResponse, - RagPipelineStepParametersResponse, + DatasourcePluginListResponse, + RagPipelineRecommendedPluginResponse, + RagPipelineTransformResponse, + RagPipelineVariablesResponse, RagPipelineWorkflowPublishResponse, RagPipelineWorkflowSyncResponse, SimpleResultResponse, @@ -254,17 +269,16 @@ class DraftRagPipelineApi(Resource): except WorkflowHashNotEqualError: raise DraftWorkflowNotSync() - return { - "result": "success", - "hash": workflow.unique_hash, - "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at), - } + return RagPipelineWorkflowSyncResponse( + result="success", + hash=workflow.unique_hash, + updated_at=to_timestamp(workflow.updated_at or workflow.created_at), + ).model_dump(mode="json") @console_ns.route("/rag/pipelines//workflows/draft/iteration/nodes//run") class RagPipelineDraftRunIterationNodeApi(Resource): @console_ns.expect(console_ns.models[NodeRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) @setup_required @login_required @account_initialization_required @@ -284,6 +298,7 @@ class RagPipelineDraftRunIterationNodeApi(Resource): pipeline=pipeline, user=current_user, node_id=node_id, args=args, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -299,7 +314,6 @@ class RagPipelineDraftRunIterationNodeApi(Resource): @console_ns.route("/rag/pipelines//workflows/draft/loop/nodes//run") class RagPipelineDraftRunLoopNodeApi(Resource): @console_ns.expect(console_ns.models[NodeRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) @setup_required @login_required @account_initialization_required @@ -319,6 +333,7 @@ class RagPipelineDraftRunLoopNodeApi(Resource): pipeline=pipeline, user=current_user, node_id=node_id, args=args, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -334,7 +349,6 @@ class RagPipelineDraftRunLoopNodeApi(Resource): @console_ns.route("/rag/pipelines//workflows/draft/run") class DraftRagPipelineRunApi(Resource): @console_ns.expect(console_ns.models[DraftWorkflowRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) @setup_required @login_required @account_initialization_required @@ -358,6 +372,7 @@ class DraftRagPipelineRunApi(Resource): streaming=True, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except InvokeRateLimitError as ex: raise InvokeRateLimitHttpError(ex.description) @@ -366,7 +381,6 @@ class DraftRagPipelineRunApi(Resource): @console_ns.route("/rag/pipelines//workflows/published/run") class PublishedRagPipelineRunApi(Resource): @console_ns.expect(console_ns.models[PublishedWorkflowRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) @setup_required @login_required @account_initialization_required @@ -391,6 +405,7 @@ class PublishedRagPipelineRunApi(Resource): streaming=streaming, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except InvokeRateLimitError as ex: raise InvokeRateLimitHttpError(ex.description) @@ -399,7 +414,6 @@ class PublishedRagPipelineRunApi(Resource): @console_ns.route("/rag/pipelines//workflows/published/datasource/nodes//run") class RagPipelinePublishedDatasourceNodeRunApi(Resource): @console_ns.expect(console_ns.models[DatasourceNodeRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) @setup_required @login_required @account_initialization_required @@ -414,6 +428,7 @@ class RagPipelinePublishedDatasourceNodeRunApi(Resource): payload = DatasourceNodeRunPayload.model_validate(console_ns.payload or {}) rag_pipeline_service = RagPipelineService() + # response-contract:ignore compact_generate_response return helper.compact_generate_response( PipelineGenerator.convert_to_event_stream( rag_pipeline_service.run_datasource_workflow_node( @@ -432,7 +447,6 @@ class RagPipelinePublishedDatasourceNodeRunApi(Resource): @console_ns.route("/rag/pipelines//workflows/draft/datasource/nodes//run") class RagPipelineDraftDatasourceNodeRunApi(Resource): @console_ns.expect(console_ns.models[DatasourceNodeRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) @setup_required @login_required @edit_permission_required @@ -447,6 +461,7 @@ class RagPipelineDraftDatasourceNodeRunApi(Resource): payload = DatasourceNodeRunPayload.model_validate(console_ns.payload or {}) rag_pipeline_service = RagPipelineService() + # response-contract:ignore compact_generate_response return helper.compact_generate_response( PipelineGenerator.convert_to_event_stream( rag_pipeline_service.run_datasource_workflow_node( @@ -492,9 +507,7 @@ class RagPipelineDraftNodeRunApi(Resource): if workflow_node_execution is None: raise ValueError("Workflow node execution not found") - return WorkflowRunNodeExecutionResponse.model_validate( - workflow_node_execution, from_attributes=True - ).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionResponse, workflow_node_execution) @console_ns.route("/rag/pipelines//workflow-runs/tasks//stop") @@ -513,7 +526,7 @@ class RagPipelineTaskStopApi(Resource): """ AppQueueManager.set_stop_flag(task_id, InvokeFrom.DEBUGGER, current_user.id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") @console_ns.route("/rag/pipelines//workflows/publish") @@ -567,20 +580,18 @@ class PublishedRagPipelineApi(Resource): pipeline.is_published = True pipeline.workflow_id = workflow.id db.session.commit() - workflow_created_at = TimestampField().format(workflow.created_at) + workflow_created_at = to_timestamp(workflow.created_at) - return { - "result": "success", - "created_at": workflow_created_at, - } + return RagPipelineWorkflowPublishResponse(result="success", created_at=workflow_created_at).model_dump( + mode="json" + ) @console_ns.route("/rag/pipelines//workflows/default-workflow-block-configs") class DefaultRagPipelineBlockConfigsApi(Resource): @console_ns.response( 200, - "Default block configs retrieved successfully", - console_ns.models[DefaultBlockConfigsResponse.__name__], + "Default workflow block configurations retrieved successfully", ) @setup_required @login_required @@ -602,8 +613,7 @@ class DefaultRagPipelineBlockConfigApi(Resource): @console_ns.doc(params=query_params_from_model(DefaultBlockConfigQuery)) @console_ns.response( 200, - "Default block config retrieved successfully", - console_ns.models[DefaultBlockConfigResponse.__name__], + "Default workflow block configuration retrieved successfully", ) @setup_required @login_required @@ -631,13 +641,13 @@ class DefaultRagPipelineBlockConfigApi(Resource): @console_ns.route("/rag/pipelines//workflows") class PublishedAllRagPipelineApi(Resource): - @console_ns.doc(params=query_params_from_model(WorkflowListQuery)) @console_ns.response( 200, "Published workflows retrieved successfully", console_ns.models[WorkflowPaginationResponse.__name__], ) @console_ns.response(403, "Permission denied") + @console_ns.doc(params=query_params_from_model(WorkflowListQuery)) @setup_required @login_required @account_initialization_required @@ -671,14 +681,15 @@ class PublishedAllRagPipelineApi(Resource): named_only=named_only, ) - return WorkflowPaginationResponse.model_validate( + return dump_response( + WorkflowPaginationResponse, { "items": workflows, "page": page, "limit": limit, "has_more": has_more, - } - ).model_dump(mode="json") + }, + ) @console_ns.route("/rag/pipelines//workflows//restore") @@ -706,11 +717,11 @@ class RagPipelineDraftWorkflowRestoreApi(Resource): except WorkflowNotFoundError as exc: raise NotFound(str(exc)) from exc - return { - "result": "success", - "hash": workflow.unique_hash, - "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at), - } + return RagPipelineWorkflowSyncResponse( + result="success", + hash=workflow.unique_hash, + updated_at=to_timestamp(workflow.updated_at or workflow.created_at), + ).model_dump(mode="json") @console_ns.route("/rag/pipelines//workflows/") @@ -784,13 +795,17 @@ class RagPipelineByIdApi(Resource): except ValueError as e: raise NotFound(str(e)) - return None, 204 + return "", 204 @console_ns.route("/rag/pipelines//workflows/published/processing/parameters") class PublishedRagPipelineSecondStepApi(Resource): @console_ns.doc(params=query_params_from_model(NodeIdQuery)) - @console_ns.response(200, "Success", console_ns.models[RagPipelineStepParametersResponse.__name__]) + @console_ns.response( + 200, + "Second step parameters retrieved successfully", + console_ns.models[RagPipelineVariablesResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -805,15 +820,17 @@ class PublishedRagPipelineSecondStepApi(Resource): node_id = query.node_id rag_pipeline_service = RagPipelineService() variables = rag_pipeline_service.get_second_step_parameters(pipeline=pipeline, node_id=node_id, is_draft=False) - return { - "variables": variables, - } + return dump_response(RagPipelineVariablesResponse, {"variables": variables}) @console_ns.route("/rag/pipelines//workflows/published/pre-processing/parameters") class PublishedRagPipelineFirstStepApi(Resource): @console_ns.doc(params=query_params_from_model(NodeIdQuery)) - @console_ns.response(200, "Success", console_ns.models[RagPipelineStepParametersResponse.__name__]) + @console_ns.response( + 200, + "First step parameters retrieved successfully", + console_ns.models[RagPipelineVariablesResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -828,15 +845,17 @@ class PublishedRagPipelineFirstStepApi(Resource): node_id = query.node_id rag_pipeline_service = RagPipelineService() variables = rag_pipeline_service.get_first_step_parameters(pipeline=pipeline, node_id=node_id, is_draft=False) - return { - "variables": variables, - } + return dump_response(RagPipelineVariablesResponse, {"variables": variables}) @console_ns.route("/rag/pipelines//workflows/draft/pre-processing/parameters") class DraftRagPipelineFirstStepApi(Resource): @console_ns.doc(params=query_params_from_model(NodeIdQuery)) - @console_ns.response(200, "Success", console_ns.models[RagPipelineStepParametersResponse.__name__]) + @console_ns.response( + 200, + "First step parameters retrieved successfully", + console_ns.models[RagPipelineVariablesResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -851,15 +870,17 @@ class DraftRagPipelineFirstStepApi(Resource): node_id = query.node_id rag_pipeline_service = RagPipelineService() variables = rag_pipeline_service.get_first_step_parameters(pipeline=pipeline, node_id=node_id, is_draft=True) - return { - "variables": variables, - } + return dump_response(RagPipelineVariablesResponse, {"variables": variables}) @console_ns.route("/rag/pipelines//workflows/draft/processing/parameters") class DraftRagPipelineSecondStepApi(Resource): @console_ns.doc(params=query_params_from_model(NodeIdQuery)) - @console_ns.response(200, "Success", console_ns.models[RagPipelineStepParametersResponse.__name__]) + @console_ns.response( + 200, + "Second step parameters retrieved successfully", + console_ns.models[RagPipelineVariablesResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -875,9 +896,7 @@ class DraftRagPipelineSecondStepApi(Resource): rag_pipeline_service = RagPipelineService() variables = rag_pipeline_service.get_second_step_parameters(pipeline=pipeline, node_id=node_id, is_draft=True) - return { - "variables": variables, - } + return dump_response(RagPipelineVariablesResponse, {"variables": variables}) @console_ns.route("/rag/pipelines//workflow-runs") @@ -910,7 +929,7 @@ class RagPipelineWorkflowRunListApi(Resource): rag_pipeline_service = RagPipelineService() result = rag_pipeline_service.get_rag_pipeline_paginate_workflow_runs(pipeline=pipeline, args=args) - return WorkflowRunPaginationResponse.model_validate(result, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunPaginationResponse, result) @console_ns.route("/rag/pipelines//workflow-runs/") @@ -935,7 +954,7 @@ class RagPipelineWorkflowRunDetailApi(Resource): if workflow_run is None: raise NotFound("Workflow run not found") - return WorkflowRunDetailResponse.model_validate(workflow_run, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunDetailResponse, workflow_run) @console_ns.route("/rag/pipelines//workflow-runs//node-executions") @@ -964,20 +983,25 @@ class RagPipelineWorkflowRunNodeExecutionListApi(Resource): user=user, ) - return WorkflowRunNodeExecutionListResponse.model_validate( - {"data": node_executions}, from_attributes=True - ).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionListResponse, {"data": node_executions}) @console_ns.route("/rag/pipelines/datasource-plugins") class DatasourceListApi(Resource): - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) + @console_ns.response( + 200, + "Datasource plugins retrieved successfully", + console_ns.models[DatasourcePluginListResponse.__name__], + ) @setup_required @login_required @account_initialization_required @with_current_tenant_id def get(self, current_tenant_id: str): - return jsonable_encoder(RagPipelineManageService.list_rag_pipeline_datasources(current_tenant_id)) + return dump_response( + DatasourcePluginListResponse, + RagPipelineManageService.list_rag_pipeline_datasources(current_tenant_id), + ) @console_ns.route("/rag/pipelines//workflows/draft/nodes//last-run") @@ -1003,12 +1027,16 @@ class RagPipelineWorkflowLastRunApi(Resource): ) if node_exec is None: raise NotFound("last run not found") - return WorkflowRunNodeExecutionResponse.model_validate(node_exec, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionResponse, node_exec) @console_ns.route("/rag/pipelines/transform/datasets/") class RagPipelineTransformApi(Resource): - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) + @console_ns.response( + 200, + "Dataset transformed successfully", + console_ns.models[RagPipelineTransformResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -1020,7 +1048,7 @@ class RagPipelineTransformApi(Resource): dataset_id_str = str(dataset_id) rag_pipeline_transform_service = RagPipelineTransformService() result = rag_pipeline_transform_service.transform_dataset(dataset_id_str, db.session) - return result + return dump_response(RagPipelineTransformResponse, result) @console_ns.route("/rag/pipelines//workflows/draft/datasource/variables-inspect") @@ -1050,15 +1078,17 @@ class RagPipelineDatasourceVariableApi(Resource): args=args, current_user=current_user, ) - return WorkflowRunNodeExecutionResponse.model_validate( - workflow_node_execution, from_attributes=True - ).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionResponse, workflow_node_execution) @console_ns.route("/rag/pipelines/recommended-plugins") class RagPipelineRecommendedPluginApi(Resource): @console_ns.doc(params=query_params_from_model(RagPipelineRecommendedPluginQuery)) - @console_ns.response(200, "Success", console_ns.models[RagPipelineOpaqueResponse.__name__]) + @console_ns.response( + 200, + "Recommended plugins retrieved successfully", + console_ns.models[RagPipelineRecommendedPluginResponse.__name__], + ) @setup_required @login_required @account_initialization_required @@ -1069,4 +1099,4 @@ class RagPipelineRecommendedPluginApi(Resource): rag_pipeline_service = RagPipelineService() recommended_plugins = rag_pipeline_service.get_recommended_plugins(query.type, current_user, current_tenant_id) - return recommended_plugins + return dump_response(RagPipelineRecommendedPluginResponse, recommended_plugins) diff --git a/api/controllers/console/explore/completion.py b/api/controllers/console/explore/completion.py index 729be6a909b..eb108f6760c 100644 --- a/api/controllers/console/explore/completion.py +++ b/api/controllers/console/explore/completion.py @@ -6,7 +6,7 @@ from pydantic import BaseModel, Field, field_validator from werkzeug.exceptions import InternalServerError, NotFound import services -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import SimpleResultResponse from controllers.common.schema import register_response_schema_models, register_schema_models from controllers.console.app.error import ( AppUnavailableError, @@ -73,7 +73,7 @@ class ChatMessagePayload(BaseModel): register_schema_models(console_ns, CompletionMessageExplorePayload, ChatMessagePayload) -register_response_schema_models(console_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(console_ns, SimpleResultResponse) # define completion api for user @@ -83,7 +83,7 @@ register_response_schema_models(console_ns, GeneratedAppResponse, SimpleResultRe ) class CompletionApi(InstalledAppResource): @console_ns.expect(console_ns.models[CompletionMessageExplorePayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Success") @with_current_user def post(self, current_user: Account, installed_app: InstalledApp): app_model = installed_app.app @@ -106,6 +106,7 @@ class CompletionApi(InstalledAppResource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -150,7 +151,7 @@ class CompletionStopApi(InstalledAppResource): app_mode=AppMode.value_of(app_model.mode), ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 @console_ns.route( @@ -159,7 +160,7 @@ class CompletionStopApi(InstalledAppResource): ) class ChatApi(InstalledAppResource): @console_ns.expect(console_ns.models[ChatMessagePayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Success") @with_current_user def post(self, current_user: Account, installed_app: InstalledApp): app_model = installed_app.app @@ -182,6 +183,7 @@ class ChatApi(InstalledAppResource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -229,4 +231,4 @@ class ChatStopApi(InstalledAppResource): app_mode=app_mode, ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 diff --git a/api/controllers/console/explore/message.py b/api/controllers/console/explore/message.py index 2be550b2f28..8f248955709 100644 --- a/api/controllers/console/explore/message.py +++ b/api/controllers/console/explore/message.py @@ -7,7 +7,6 @@ from pydantic import BaseModel, TypeAdapter from werkzeug.exceptions import InternalServerError, NotFound from controllers.common.controller_schemas import MessageFeedbackPayload, MessageListQuery -from controllers.common.fields import GeneratedAppResponse from controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_models from controllers.console.app.error import ( AppMoreLikeThisDisabledError, @@ -59,7 +58,6 @@ class MoreLikeThisQuery(BaseModel): register_schema_models(console_ns, MessageListQuery, MessageFeedbackPayload, MoreLikeThisQuery) register_response_schema_models( console_ns, - GeneratedAppResponse, ExploreMessageInfiniteScrollPagination, ResultResponse, SuggestedQuestionsResponse, @@ -142,7 +140,7 @@ class MessageFeedbackApi(InstalledAppResource): ) class MessageMoreLikeThisApi(InstalledAppResource): @console_ns.doc(params=query_params_from_model(MoreLikeThisQuery)) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Success") @with_current_user def get(self, current_user: Account, installed_app: InstalledApp, message_id: UUID): app_model = installed_app.app @@ -165,6 +163,7 @@ class MessageMoreLikeThisApi(InstalledAppResource): invoke_from=InvokeFrom.EXPLORE, streaming=streaming, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except MessageNotExistsError: raise NotFound("Message Not Exists.") diff --git a/api/controllers/console/explore/trial.py b/api/controllers/console/explore/trial.py index 6aef9129780..fd614ece87f 100644 --- a/api/controllers/console/explore/trial.py +++ b/api/controllers/console/explore/trial.py @@ -1,28 +1,24 @@ import logging -from typing import Any, Literal, cast +from typing import Literal from flask import request -from flask_restx import Resource, fields, marshal, marshal_with +from flask_restx import Resource from pydantic import BaseModel, Field from sqlalchemy import select from werkzeug.exceptions import Forbidden, InternalServerError, NotFound import services -from controllers.common.fields import ( - AudioBinaryResponse, - AudioTranscriptResponse, - GeneratedAppResponse, - SimpleResultResponse, -) +from controllers.common.fields import AudioBinaryResponse, AudioTranscriptResponse, SimpleResultResponse from controllers.common.fields import Parameters as ParametersResponse from controllers.common.fields import Site as SiteResponse from controllers.common.schema import ( - get_or_create_model, query_params_from_model, + query_params_from_request, register_response_schema_models, register_schema_models, ) from controllers.console import console_ns +from controllers.console.app.app import AppDetailWithSite from controllers.console.app.error import ( AppUnavailableError, AudioTooLargeError, @@ -36,6 +32,7 @@ from controllers.console.app.error import ( ProviderQuotaExceededError, UnsupportedAudioTypeError, ) +from controllers.console.app.workflow import WorkflowResponse from controllers.console.app.wraps import get_app_model_with_trial from controllers.console.explore.error import ( AppSuggestedQuestionsAfterAnswerDisabledError, @@ -56,26 +53,13 @@ from core.errors.error import ( ) from extensions.ext_database import db from extensions.ext_redis import redis_client -from fields.app_fields import ( - app_detail_fields_with_site, - deleted_tool_fields, - model_config_fields, - site_fields, - tag_fields, -) -from fields.dataset_fields import dataset_fields -from fields.member_fields import simple_account_fields +from fields.base import ResponseModel +from fields.dataset_fields import DatasetDetailResponse from fields.message_fields import SuggestedQuestionsResponse -from fields.workflow_fields import ( - conversation_variable_fields, - pipeline_variable_fields, - workflow_fields, - workflow_partial_fields, -) from graphon.graph_engine.manager import GraphEngineManager from graphon.model_runtime.errors.invoke import InvokeError from libs import helper -from libs.helper import uuid_value +from libs.helper import dump_response, uuid_value from models import Account from models.account import TenantStatus from models.model import AppMode, Site @@ -102,57 +86,42 @@ from services.recommended_app_service import RecommendedAppService logger = logging.getLogger(__name__) -model_config_model = get_or_create_model("TrialAppModelConfig", model_config_fields) -workflow_partial_model = get_or_create_model("TrialWorkflowPartial", workflow_partial_fields) -deleted_tool_model = get_or_create_model("TrialDeletedTool", deleted_tool_fields) -tag_model = get_or_create_model("TrialTag", tag_fields) -site_model = get_or_create_model("TrialSite", site_fields) +class TrialDatasetListItemResponse(DatasetDetailResponse): + pass -app_detail_fields_with_site_copy = app_detail_fields_with_site.copy() -app_detail_fields_with_site_copy["model_config"] = fields.Nested( - model_config_model, attribute="app_model_config", allow_null=True -) -app_detail_fields_with_site_copy["workflow"] = fields.Nested(workflow_partial_model, allow_null=True) -app_detail_fields_with_site_copy["deleted_tools"] = fields.List(fields.Nested(deleted_tool_model)) -app_detail_fields_with_site_copy["tags"] = fields.List(fields.Nested(tag_model)) -app_detail_fields_with_site_copy["site"] = fields.Nested(site_model) -app_detail_with_site_model = get_or_create_model("TrialAppDetailWithSite", app_detail_fields_with_site_copy) -simple_account_model = get_or_create_model("TrialSimpleAccount", simple_account_fields) -conversation_variable_model = get_or_create_model("TrialConversationVariable", conversation_variable_fields) -pipeline_variable_model = get_or_create_model("TrialPipelineVariable", pipeline_variable_fields) +class TrialDatasetListResponse(ResponseModel): + data: list[TrialDatasetListItemResponse] + has_more: bool + limit: int + total: int + page: int -workflow_fields_copy = workflow_fields.copy() -workflow_fields_copy["created_by"] = fields.Nested(simple_account_model, attribute="created_by_account") -workflow_fields_copy["updated_by"] = fields.Nested( - simple_account_model, attribute="updated_by_account", allow_null=True -) -workflow_fields_copy["conversation_variables"] = fields.List(fields.Nested(conversation_variable_model)) -workflow_fields_copy["rag_pipeline_variables"] = fields.List(fields.Nested(pipeline_variable_model)) -workflow_model = get_or_create_model("TrialWorkflow", workflow_fields_copy) -dataset_model = get_or_create_model("TrialDataset", dataset_fields) -dataset_list_model = get_or_create_model( - "TrialDatasetList", - { - "data": fields.List(fields.Nested(dataset_model)), - "has_more": fields.Boolean, - "limit": fields.Integer, - "total": fields.Integer, - "page": fields.Integer, - }, +register_response_schema_models( + console_ns, + ParametersResponse, + AppDetailWithSite, + AudioBinaryResponse, + AudioTranscriptResponse, + SimpleResultResponse, + SiteResponse, + SuggestedQuestionsResponse, + TrialDatasetListItemResponse, + TrialDatasetListResponse, + WorkflowResponse, ) class WorkflowRunRequest(BaseModel): inputs: dict - files: list | None = Field(default=None) + files: list | None = None class ChatRequest(BaseModel): inputs: dict query: str - files: list | None = Field(default=None) + files: list | None = None conversation_id: str | None = None parent_message_id: str | None = None retriever_from: str = "explore_app" @@ -168,7 +137,7 @@ class TextToSpeechRequest(BaseModel): class CompletionRequest(BaseModel): inputs: dict query: str = "" - files: list | None = Field(default=None) + files: list | None = None response_mode: Literal["blocking", "streaming"] | None = None retriever_from: str = "explore_app" @@ -187,23 +156,13 @@ register_schema_models( CompletionRequest, TrialDatasetListQuery, ) -register_response_schema_models( - console_ns, - ParametersResponse, - AudioBinaryResponse, - AudioTranscriptResponse, - GeneratedAppResponse, - SimpleResultResponse, - SiteResponse, - SuggestedQuestionsResponse, -) class TrialAppWorkflowRunApi(TrialAppResource): @trial_feature_enable - @console_ns.expect(console_ns.models[WorkflowRunRequest.__name__]) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) @with_current_user + @console_ns.expect(console_ns.models[WorkflowRunRequest.__name__]) + @console_ns.response(200, "Success") def post(self, current_user: Account, trial_app): """ Run workflow @@ -224,6 +183,7 @@ class TrialAppWorkflowRunApi(TrialAppResource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=True ) RecommendedAppService.add_trial_app_record(db.session, app_id, user_id) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ProviderTokenNotInitError as ex: raise ProviderNotInitializeError(ex.description) @@ -263,12 +223,12 @@ class TrialAppWorkflowTaskStopApi(TrialAppResource): # New graph engine command channel mechanism GraphEngineManager(redis_client).send_stop_command(task_id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") class TrialChatApi(TrialAppResource): @console_ns.expect(console_ns.models[ChatRequest.__name__]) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Success") @trial_feature_enable @with_current_user def post(self, current_user: Account, trial_app): @@ -297,6 +257,7 @@ class TrialChatApi(TrialAppResource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=True ) RecommendedAppService.add_trial_app_record(db.session, app_id, user_id) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -355,7 +316,7 @@ class TrialMessageSuggestedQuestionApi(TrialAppResource): logger.exception("internal server error.") raise InternalServerError() - return {"data": questions} + return dump_response(SuggestedQuestionsResponse, {"data": questions}) class TrialChatAudioApi(TrialAppResource): @@ -374,7 +335,7 @@ class TrialChatAudioApi(TrialAppResource): response = AudioService.transcript_asr(app_model=app_model, file=file, end_user=None) RecommendedAppService.add_trial_app_record(db.session, app_id, user_id) - return response + return dump_response(AudioTranscriptResponse, response) except services.errors.app_model_config.AppModelConfigBrokenError: logger.exception("App model config broken.") raise AppUnavailableError() @@ -427,6 +388,7 @@ class TrialChatTextApi(TrialAppResource): message_id=message_id, ) RecommendedAppService.add_trial_app_record(db.session, app_id, user_id) + # response-contract:ignore binary response return response except services.errors.app_model_config.AppModelConfigBrokenError: logger.exception("App model config broken.") @@ -456,7 +418,7 @@ class TrialChatTextApi(TrialAppResource): class TrialCompletionApi(TrialAppResource): @console_ns.expect(console_ns.models[CompletionRequest.__name__]) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Success") @trial_feature_enable @with_current_user def post(self, current_user: Account, trial_app): @@ -480,6 +442,7 @@ class TrialCompletionApi(TrialAppResource): ) RecommendedAppService.add_trial_app_record(db.session, app_id, user_id) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -557,50 +520,49 @@ class TrialAppParameterApi(Resource): class AppApi(Resource): - @console_ns.response(200, "Success", app_detail_with_site_model) @get_app_model_with_trial(None) - @marshal_with(app_detail_with_site_model) + @console_ns.response(200, "App detail retrieved successfully", console_ns.models[AppDetailWithSite.__name__]) def get(self, app_model): """Get app detail""" app_service = AppService() app_model = app_service.get_app(app_model) - return app_model + return dump_response(AppDetailWithSite, app_model) class AppWorkflowApi(Resource): - @console_ns.response(200, "Success", workflow_model) @get_app_model_with_trial(None) - @marshal_with(workflow_model) + @console_ns.response(200, "Workflow detail retrieved successfully", console_ns.models[WorkflowResponse.__name__]) def get(self, app_model): """Get workflow detail""" if not app_model.workflow_id: raise AppUnavailableError() workflow = db.session.get(Workflow, app_model.workflow_id) - return workflow + return dump_response(WorkflowResponse, workflow) class DatasetListApi(Resource): @console_ns.doc(params=query_params_from_model(TrialDatasetListQuery)) - @console_ns.response(200, "Success", dataset_list_model) + @console_ns.response(200, "Success", console_ns.models[TrialDatasetListResponse.__name__]) @get_app_model_with_trial(None) def get(self, app_model): - page = request.args.get("page", default=1, type=int) - limit = request.args.get("limit", default=20, type=int) - ids = request.args.getlist("ids") + query = query_params_from_request( + TrialDatasetListQuery, + list_fields=("ids",), + use_defaults_for_malformed_ints=True, + ) tenant_id = app_model.tenant_id - if ids: - datasets, total = DatasetService.get_datasets_by_ids(ids, tenant_id) + if query.ids: + datasets, total = DatasetService.get_datasets_by_ids(query.ids, tenant_id) else: raise NeedAddIdsError() - data = cast(list[dict[str, Any]], marshal(datasets, dataset_fields)) - - response = {"data": data, "has_more": len(datasets) == limit, "limit": limit, "total": total, "page": page} - return response + return TrialDatasetListResponse( + data=datasets, has_more=len(datasets) == query.limit, limit=query.limit, total=total or 0, page=query.page + ).model_dump(mode="json") console_ns.add_resource(TrialChatApi, "/trial-apps//chat-messages", endpoint="trial_app_chat_completion") diff --git a/api/controllers/console/explore/workflow.py b/api/controllers/console/explore/workflow.py index f4e9e3cd7ef..ad6e23b24d1 100644 --- a/api/controllers/console/explore/workflow.py +++ b/api/controllers/console/explore/workflow.py @@ -3,7 +3,7 @@ import logging from werkzeug.exceptions import InternalServerError from controllers.common.controller_schemas import WorkflowRunPayload -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import SimpleResultResponse from controllers.common.schema import register_response_schema_models, register_schema_model from controllers.console.app.error import ( CompletionRequestError, @@ -36,13 +36,13 @@ from .. import console_ns logger = logging.getLogger(__name__) register_schema_model(console_ns, WorkflowRunPayload) -register_response_schema_models(console_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(console_ns, SimpleResultResponse) @console_ns.route("/installed-apps//workflows/run") class InstalledAppWorkflowRunApi(InstalledAppResource): @console_ns.expect(console_ns.models[WorkflowRunPayload.__name__]) - @console_ns.response(200, "Success", console_ns.models[GeneratedAppResponse.__name__]) + @console_ns.response(200, "Success") @with_current_user def post(self, current_user: Account, installed_app: InstalledApp): """ @@ -62,6 +62,7 @@ class InstalledAppWorkflowRunApi(InstalledAppResource): app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ProviderTokenNotInitError as ex: raise ProviderNotInitializeError(ex.description) @@ -101,4 +102,4 @@ class InstalledAppWorkflowTaskStopApi(InstalledAppResource): # New graph engine command channel mechanism GraphEngineManager(redis_client).send_stop_command(task_id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") diff --git a/api/controllers/console/snippets/snippet_workflow.py b/api/controllers/console/snippets/snippet_workflow.py index 0b8dc264a68..17416ee8610 100644 --- a/api/controllers/console/snippets/snippet_workflow.py +++ b/api/controllers/console/snippets/snippet_workflow.py @@ -8,20 +8,18 @@ from pydantic import BaseModel, Field from sqlalchemy.orm import Session, sessionmaker from werkzeug.exceptions import BadRequest, InternalServerError, NotFound -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import EventStreamResponse, SimpleResultResponse from controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_models from controllers.console import console_ns from controllers.console.app.error import DraftWorkflowNotExist, DraftWorkflowNotSync from controllers.console.app.workflow import ( RESTORE_SOURCE_WORKFLOW_MUST_BE_PUBLISHED_MESSAGE, - DefaultBlockConfigsResponse, + PublishWorkflowResponse, + SyncDraftWorkflowResponse, WorkflowPaginationResponse, - WorkflowPublishResponse, WorkflowResponse, - WorkflowRestoreResponse, ) from controllers.console.snippets.payloads import ( - PublishWorkflowPayload, SnippetDraftNodeRunPayload, SnippetDraftRunPayload, SnippetDraftSyncPayload, @@ -43,6 +41,7 @@ from core.app.apps.base_app_queue_manager import AppQueueManager from core.app.entities.app_invoke_entities import InvokeFrom from extensions.ext_database import db from extensions.ext_redis import redis_client +from fields.base import ResponseModel from fields.workflow_run_fields import ( WorkflowRunDetailResponse, WorkflowRunNodeExecutionListResponse, @@ -51,7 +50,7 @@ from fields.workflow_run_fields import ( ) from graphon.graph_engine.manager import GraphEngineManager from libs import helper -from libs.helper import TimestampField +from libs.helper import dump_response, to_timestamp from libs.login import current_account_with_tenant, login_required from models import Account from models.snippet import CustomizedSnippet @@ -76,7 +75,7 @@ class SnippetWorkflowResponse(WorkflowResponse): input_fields: list[dict] = Field(default_factory=list) -class SnippetDraftConfigResponse(BaseModel): +class SnippetDraftConfigResponse(ResponseModel): parallel_depth_limit: int @@ -96,19 +95,17 @@ register_schema_models( SnippetLoopNodeRunPayload, SnippetWorkflowListQuery, WorkflowRunQuery, - PublishWorkflowPayload, ) register_response_schema_models( console_ns, - DefaultBlockConfigsResponse, - GeneratedAppResponse, + EventStreamResponse, SimpleResultResponse, SnippetDraftConfigResponse, SnippetWorkflowResponse, SnippetWorkflowPaginationResponse, - WorkflowPublishResponse, + PublishWorkflowResponse, WorkflowPaginationResponse, - WorkflowRestoreResponse, + SyncDraftWorkflowResponse, WorkflowRunPaginationResponse, WorkflowRunDetailResponse, WorkflowRunNodeExecutionListResponse, @@ -175,7 +172,7 @@ class SnippetDraftWorkflowApi(Resource): raise DraftWorkflowNotExist() workflow.conversation_variables = [] - response = SnippetWorkflowResponse.model_validate(workflow, from_attributes=True).model_dump(mode="json") + response = dump_response(SnippetWorkflowResponse, workflow) response["input_fields"] = snippet.input_fields_list return response @@ -184,7 +181,7 @@ class SnippetDraftWorkflowApi(Resource): @console_ns.response( 200, "Draft workflow synced successfully", - console_ns.models[WorkflowRestoreResponse.__name__], + console_ns.models[SyncDraftWorkflowResponse.__name__], ) @console_ns.response(400, "Hash mismatch") @setup_required @@ -214,11 +211,11 @@ class SnippetDraftWorkflowApi(Resource): except ValueError as e: return {"message": str(e)}, 400 - return { - "result": "success", - "hash": workflow.unique_hash, - "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at), - } + return SyncDraftWorkflowResponse( + result="success", + hash=workflow.unique_hash, + updated_at=to_timestamp(workflow.updated_at or workflow.created_at), + ).model_dump(mode="json") @console_ns.route("/snippets//workflows/draft/config") @@ -237,9 +234,7 @@ class SnippetDraftConfigApi(Resource): @rbac_permission_required(RBACResourceScope.WORKSPACE, RBACPermission.SNIPPETS_MANAGE, resource_required=False) def get(self, snippet: CustomizedSnippet): """Get snippet draft workflow configuration limits.""" - return { - "parallel_depth_limit": 3, - } + return SnippetDraftConfigResponse(parallel_depth_limit=3).model_dump(mode="json") @console_ns.route("/snippets//workflows/publish") @@ -268,13 +263,12 @@ class SnippetPublishedWorkflowApi(Resource): if not workflow: return None - response = SnippetWorkflowResponse.model_validate(workflow, from_attributes=True).model_dump(mode="json") + response = dump_response(SnippetWorkflowResponse, workflow) response["input_fields"] = snippet.input_fields_list return response @console_ns.doc("publish_snippet_workflow") - @console_ns.expect(console_ns.models.get(PublishWorkflowPayload.__name__)) - @console_ns.response(200, "Workflow published successfully", console_ns.models[WorkflowPublishResponse.__name__]) + @console_ns.response(200, "Workflow published successfully", console_ns.models[PublishWorkflowResponse.__name__]) @console_ns.response(400, "No draft workflow found") @setup_required @login_required @@ -297,25 +291,18 @@ class SnippetPublishedWorkflowApi(Resource): snippet=snippet, account=current_user, ) - workflow_created_at = TimestampField().format(workflow.created_at) + workflow_created_at = to_timestamp(workflow.created_at) session.commit() except ValueError as e: return {"message": str(e)}, 400 - return { - "result": "success", - "created_at": workflow_created_at, - } + return PublishWorkflowResponse(result="success", created_at=workflow_created_at).model_dump(mode="json") @console_ns.route("/snippets//workflows/default-workflow-block-configs") class SnippetDefaultBlockConfigsApi(Resource): @console_ns.doc("get_snippet_default_block_configs") - @console_ns.response( - 200, - "Default block configs retrieved successfully", - console_ns.models[DefaultBlockConfigsResponse.__name__], - ) + @console_ns.response(200, "Default block configs retrieved successfully") @setup_required @login_required @account_initialization_required @@ -377,7 +364,7 @@ class SnippetDraftWorkflowRestoreApi(Resource): @console_ns.doc("restore_snippet_workflow_to_draft") @console_ns.doc(description="Restore a published snippet workflow version into the draft workflow") @console_ns.doc(params={"snippet_id": "Snippet ID", "workflow_id": "Published workflow ID"}) - @console_ns.response(200, "Workflow restored successfully", console_ns.models[WorkflowRestoreResponse.__name__]) + @console_ns.response(200, "Workflow restored successfully", console_ns.models[SyncDraftWorkflowResponse.__name__]) @console_ns.response(400, "Source workflow must be published") @console_ns.response(404, "Workflow not found") @setup_required @@ -406,11 +393,11 @@ class SnippetDraftWorkflowRestoreApi(Resource): except ValueError as exc: raise BadRequest(str(exc)) from exc - return { - "result": "success", - "hash": workflow.unique_hash, - "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at), - } + return SyncDraftWorkflowResponse( + result="success", + hash=workflow.unique_hash, + updated_at=to_timestamp(workflow.updated_at or workflow.created_at), + ).model_dump(mode="json") @console_ns.route("/snippets//workflow-runs") @@ -442,7 +429,7 @@ class SnippetWorkflowRunsApi(Resource): snippet_service = _snippet_service() result = snippet_service.get_snippet_workflow_runs(snippet=snippet, args=args) - return WorkflowRunPaginationResponse.model_validate(result, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunPaginationResponse, result) @console_ns.route("/snippets//workflow-runs/") @@ -468,7 +455,7 @@ class SnippetWorkflowRunDetailApi(Resource): if not workflow_run: raise NotFound("Workflow run not found") - return WorkflowRunDetailResponse.model_validate(workflow_run, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunDetailResponse, workflow_run) @console_ns.route("/snippets//workflow-runs//node-executions") @@ -493,9 +480,7 @@ class SnippetWorkflowRunNodeExecutionsApi(Resource): run_id=run_id, ) - return WorkflowRunNodeExecutionListResponse.model_validate( - {"data": node_executions}, from_attributes=True - ).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionListResponse, {"data": node_executions}) @console_ns.route("/snippets//workflows/draft/nodes//run") @@ -546,9 +531,7 @@ class SnippetDraftNodeRunApi(Resource): session_maker=_snippet_session_maker(), ) - return WorkflowRunNodeExecutionResponse.model_validate( - workflow_node_execution, from_attributes=True - ).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionResponse, workflow_node_execution) @console_ns.route("/snippets//workflows/draft/nodes//last-run") @@ -584,7 +567,7 @@ class SnippetDraftNodeLastRunApi(Resource): if node_exec is None: raise NotFound("Node last run not found") - return WorkflowRunNodeExecutionResponse.model_validate(node_exec, from_attributes=True).model_dump(mode="json") + return dump_response(WorkflowRunNodeExecutionResponse, node_exec) @console_ns.route("/snippets//workflows/draft/iteration/nodes//run") @@ -596,7 +579,7 @@ class SnippetDraftRunIterationNodeApi(Resource): @console_ns.response( 200, "Iteration node run started successfully (SSE stream)", - console_ns.models[GeneratedAppResponse.__name__], + console_ns.models[EventStreamResponse.__name__], ) @console_ns.response(404, "Snippet or draft workflow not found") @setup_required @@ -627,6 +610,7 @@ class SnippetDraftRunIterationNodeApi(Resource): session_maker=_snippet_session_maker(), ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ValueError as e: raise e @@ -644,7 +628,7 @@ class SnippetDraftRunLoopNodeApi(Resource): @console_ns.response( 200, "Loop node run started successfully (SSE stream)", - console_ns.models[GeneratedAppResponse.__name__], + console_ns.models[EventStreamResponse.__name__], ) @console_ns.response(404, "Snippet or draft workflow not found") @setup_required @@ -675,6 +659,7 @@ class SnippetDraftRunLoopNodeApi(Resource): session_maker=_snippet_session_maker(), ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ValueError as e: raise e @@ -690,7 +675,7 @@ class SnippetDraftWorkflowRunApi(Resource): @console_ns.response( 200, "Draft workflow run started successfully (SSE stream)", - console_ns.models[GeneratedAppResponse.__name__], + console_ns.models[EventStreamResponse.__name__], ) @console_ns.response(404, "Snippet or draft workflow not found") @setup_required @@ -722,6 +707,7 @@ class SnippetDraftWorkflowRunApi(Resource): session_maker=_snippet_session_maker(), ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ValueError as e: raise e @@ -757,4 +743,4 @@ class SnippetWorkflowTaskStopApi(Resource): # New graph engine command channel mechanism GraphEngineManager(redis_client).send_stop_command(task_id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") diff --git a/api/controllers/service_api/app/completion.py b/api/controllers/service_api/app/completion.py index 1468f3d776f..873911ec50e 100644 --- a/api/controllers/service_api/app/completion.py +++ b/api/controllers/service_api/app/completion.py @@ -9,7 +9,7 @@ from pydantic.json_schema import SkipJsonSchema from werkzeug.exceptions import BadRequest, InternalServerError, NotFound import services -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import SimpleResultResponse from controllers.common.schema import register_response_schema_models, register_schema_models from controllers.service_api import service_api_ns from controllers.service_api.app.error import ( @@ -154,7 +154,7 @@ class ChatRequestPayload(BaseModel): register_schema_models(service_api_ns, CompletionRequestPayload, ChatRequestPayload) -register_response_schema_models(service_api_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(service_api_ns, SimpleResultResponse) @service_api_ns.route("/completion-messages") @@ -197,11 +197,7 @@ class CompletionApi(Resource): 500: "Internal server error", } ) - @service_api_ns.response( - 200, - "Completion created successfully", - service_api_ns.models[GeneratedAppResponse.__name__], - ) + @service_api_ns.response(200, "Completion created successfully") @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.JSON, required=True)) def post(self, app_model: App, end_user: EndUser): """Create a completion for the given prompt. @@ -236,6 +232,7 @@ class CompletionApi(Resource): streaming=streaming, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -296,7 +293,7 @@ class CompletionStopApi(Resource): app_mode=AppMode.value_of(app_model.mode), ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 @service_api_ns.route("/chat-messages") @@ -346,11 +343,7 @@ class ChatApi(Resource): 500: "Internal server error", } ) - @service_api_ns.response( - 200, - "Message sent successfully", - service_api_ns.models[GeneratedAppResponse.__name__], - ) + @service_api_ns.response(200, "Message sent successfully") @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.JSON, required=True)) def post(self, app_model: App, end_user: EndUser): """Send a message in a chat conversation. @@ -379,6 +372,7 @@ class ChatApi(Resource): app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.SERVICE_API, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except WorkflowNotFoundError as ex: raise NotFound(str(ex)) @@ -448,4 +442,4 @@ class ChatStopApi(Resource): app_mode=app_mode, ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 diff --git a/api/controllers/service_api/app/workflow.py b/api/controllers/service_api/app/workflow.py index 091b79fefbd..d685172d6d2 100644 --- a/api/controllers/service_api/app/workflow.py +++ b/api/controllers/service_api/app/workflow.py @@ -1,19 +1,24 @@ import logging from collections.abc import Mapping from datetime import datetime -from typing import Literal, override +from typing import Literal from dateutil.parser import isoparse from flask import request -from flask_restx import Resource, fields -from pydantic import BaseModel, Field, field_validator +from flask_restx import Resource +from pydantic import BaseModel, Field, field_validator, model_validator from pydantic.json_schema import SkipJsonSchema from sqlalchemy.orm import sessionmaker from werkzeug.exceptions import BadRequest, InternalServerError, NotFound from controllers.common.controller_schemas import WorkflowRunPayload as WorkflowRunPayloadBase -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse -from controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_models +from controllers.common.fields import SimpleResultResponse +from controllers.common.schema import ( + query_params_from_model, + query_params_from_request, + register_response_schema_models, + register_schema_models, +) from controllers.service_api import service_api_ns from controllers.service_api.app.error import ( CompletionRequestError, @@ -41,14 +46,13 @@ from extensions.ext_database import db from extensions.ext_redis import redis_client from fields.base import ResponseModel from fields.end_user_fields import SimpleEndUser -from fields.member_fields import SimpleAccount +from fields.member_fields import SimpleAccountResponse from graphon.enums import WorkflowExecutionStatus from graphon.graph_engine.manager import GraphEngineManager from graphon.model_runtime.errors.invoke import InvokeError from libs import helper -from libs.helper import to_timestamp +from libs.helper import dump_response, to_timestamp from models.model import App, AppMode, EndUser -from models.workflow import WorkflowRun from repositories.factory import DifyAPIRepositoryFactory from services.app_generate_service import AppGenerateService from services.errors.app import IsDraftWorkflowError, WorkflowIdFormatError, WorkflowNotFoundError @@ -97,36 +101,19 @@ class WorkflowLogQuery(BaseModel): register_schema_models(service_api_ns, WorkflowRunPayload, WorkflowLogQuery) -register_response_schema_models(service_api_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(service_api_ns, SimpleResultResponse) def _enum_value(value): return getattr(value, "value", value) -class WorkflowRunStatusField(fields.Raw): - @override - def output(self, key, obj: WorkflowRun, **kwargs): - return _enum_value(obj.status) - - -class WorkflowRunOutputsField(fields.Raw): - @override - def output(self, key, obj: WorkflowRun, **kwargs): - status = _enum_value(obj.status) - if status == WorkflowExecutionStatus.PAUSED.value: - return {} - - outputs = obj.outputs_dict - return outputs or {} - - class WorkflowRunResponse(ResponseModel): id: str workflow_id: str status: str inputs: dict | list | str | int | float | bool | None = Field(default=None) - outputs: dict = Field(default_factory=dict) + outputs: dict = Field(default_factory=dict, validation_alias="outputs_dict") error: str | None = None total_steps: int | None = None total_tokens: int | None = None @@ -134,11 +121,33 @@ class WorkflowRunResponse(ResponseModel): finished_at: int | None = None elapsed_time: float | int | None = None + @field_validator("status", mode="before") + @classmethod + def _normalize_enum(cls, value): + return _enum_value(value) + + @field_validator("outputs", mode="before") + @classmethod + def _normalize_outputs(cls, value): + if value is None: + return {} + if isinstance(value, dict): + return value + if isinstance(value, Mapping): + return dict(value) + return {} + @field_validator("created_at", "finished_at", mode="before") @classmethod def _normalize_timestamp(cls, value: datetime | int | None) -> int | None: return to_timestamp(value) + @model_validator(mode="after") + def _clear_paused_outputs(self): + if self.status == WorkflowExecutionStatus.PAUSED.value: + self.outputs = {} + return self + class WorkflowRunForLogResponse(ResponseModel): id: str @@ -170,7 +179,7 @@ class WorkflowAppLogPartialResponse(ResponseModel): details: dict | list | str | int | float | bool | None = Field(default=None) created_from: str | None = None created_by_role: str | None = None - created_by_account: SimpleAccount | None = None + created_by_account: SimpleAccountResponse | None = None created_by_end_user: SimpleEndUser | None = None created_at: int | None = None @@ -202,39 +211,6 @@ register_response_schema_models( ) -def _serialize_workflow_run(workflow_run: WorkflowRun) -> dict: - status = _enum_value(workflow_run.status) - raw_outputs = workflow_run.outputs_dict - match raw_outputs: - case _ if status == WorkflowExecutionStatus.PAUSED.value or raw_outputs is None: - outputs: dict = {} - case dict(): - outputs = raw_outputs - case _ if isinstance(raw_outputs, Mapping): - outputs = dict(raw_outputs) - case _: - outputs = {} - return WorkflowRunResponse.model_validate( - { - "id": workflow_run.id, - "workflow_id": workflow_run.workflow_id, - "status": status, - "inputs": workflow_run.inputs, - "outputs": outputs, - "error": workflow_run.error, - "total_steps": workflow_run.total_steps, - "total_tokens": workflow_run.total_tokens, - "created_at": workflow_run.created_at, - "finished_at": workflow_run.finished_at, - "elapsed_time": workflow_run.elapsed_time, - } - ).model_dump(mode="json") - - -def _serialize_workflow_log_pagination(pagination) -> dict: - return WorkflowAppLogPaginationResponse.model_validate(pagination, from_attributes=True).model_dump(mode="json") - - @service_api_ns.route("/workflows/run/") class WorkflowRunDetailApi(Resource): @service_api_ns.doc( @@ -287,7 +263,7 @@ class WorkflowRunDetailApi(Resource): ) if not workflow_run: raise NotFound("Workflow run not found.") - return _serialize_workflow_run(workflow_run) + return dump_response(WorkflowRunResponse, workflow_run) @service_api_ns.route("/workflows/run") @@ -338,7 +314,6 @@ class WorkflowRunApi(Resource): @service_api_ns.response( 200, "Workflow executed successfully", - service_api_ns.models[GeneratedAppResponse.__name__], ) @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.JSON, required=True)) def post(self, app_model: App, end_user: EndUser): @@ -366,6 +341,7 @@ class WorkflowRunApi(Resource): app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.SERVICE_API, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ProviderTokenNotInitError as ex: raise ProviderNotInitializeError(ex.description) @@ -445,7 +421,6 @@ class WorkflowRunByIdApi(Resource): @service_api_ns.response( 200, "Workflow executed successfully", - service_api_ns.models[GeneratedAppResponse.__name__], ) @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.JSON, required=True)) def post(self, app_model: App, end_user: EndUser, workflow_id: str): @@ -476,6 +451,7 @@ class WorkflowRunByIdApi(Resource): app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.SERVICE_API, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except WorkflowNotFoundError as ex: raise NotFound(str(ex)) @@ -541,7 +517,7 @@ class WorkflowTaskStopApi(Resource): # New graph engine command channel mechanism GraphEngineManager(redis_client).send_stop_command(task_id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump() @service_api_ns.route("/workflows/logs") @@ -574,7 +550,7 @@ class WorkflowAppLogApi(Resource): Returns paginated workflow execution logs with filtering options. """ - args = WorkflowLogQuery.model_validate(request.args.to_dict()) + args = query_params_from_request(WorkflowLogQuery) status = WorkflowExecutionStatus(args.status) if args.status else None created_at_before = isoparse(args.created_at__before) if args.created_at__before else None @@ -596,4 +572,4 @@ class WorkflowAppLogApi(Resource): created_by_account=args.created_by_account, ) - return _serialize_workflow_log_pagination(workflow_app_log_pagination) + return dump_response(WorkflowAppLogPaginationResponse, workflow_app_log_pagination) diff --git a/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py b/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py index a6a61262cdc..0b28f4d10c8 100644 --- a/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py +++ b/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py @@ -1,34 +1,30 @@ from collections.abc import Generator +from datetime import datetime from typing import Any from uuid import UUID from flask import request -from pydantic import BaseModel, Field, RootModel +from pydantic import BaseModel, Field, RootModel, field_validator from sqlalchemy import select from werkzeug.exceptions import Forbidden, NotFound import services from controllers.common.errors import FilenameNotExistsError, NoFileUploadedError, TooManyFilesError -from controllers.common.fields import GeneratedAppResponse from controllers.common.schema import ( query_params_from_model, + query_params_from_request, register_response_schema_models, register_schema_model, - register_schema_models, ) from controllers.service_api import service_api_ns from controllers.service_api.dataset.error import PipelineRunError -from controllers.service_api.dataset.rag_pipeline.serializers import serialize_upload_file -from controllers.service_api.schema import ( - event_stream_response, - json_or_event_stream_response, - multipart_file_params, -) +from controllers.service_api.schema import event_stream_response, json_or_event_stream_response, multipart_file_params from controllers.service_api.wraps import DatasetApiResource from core.app.apps.pipeline.pipeline_generator import PipelineGenerator from core.app.entities.app_invoke_entities import InvokeFrom from fields.base import ResponseModel from libs import helper +from libs.helper import dump_response from libs.login import current_user from models import Account from models.dataset import Dataset, Pipeline @@ -82,7 +78,7 @@ class DatasourcePluginResponse(ResponseModel): datasource_type: str | None = None title: str | None = None user_input_variables: list[dict[str, Any]] = Field(default_factory=list) - credentials: list[DatasourceCredentialInfoResponse] + credentials: list[DatasourceCredentialInfoResponse] = Field(default_factory=list) class DatasourcePluginListResponse(RootModel[list[DatasourcePluginResponse]]): @@ -98,14 +94,22 @@ class PipelineUploadFileResponse(ResponseModel): created_by: str created_at: str | None = None + @field_validator("created_at", mode="before") + @classmethod + def _normalize_created_at(cls, value: datetime | str | None) -> str | None: + if isinstance(value, datetime): + return value.isoformat() + return value + register_schema_model(service_api_ns, DatasourceNodeRunPayload) +register_schema_model(service_api_ns, DatasourcePluginsQuery) register_schema_model(service_api_ns, PipelineRunApiEntity) -register_schema_models(service_api_ns, DatasourcePluginsQuery) register_response_schema_models( service_api_ns, + DatasourceCredentialInfoResponse, + DatasourcePluginResponse, DatasourcePluginListResponse, - GeneratedAppResponse, PipelineUploadFileResponse, ) @@ -117,8 +121,8 @@ class DatasourcePluginsApi(DatasetApiResource): @service_api_ns.doc( summary="List Datasource Plugins", description=( - "List the datasource nodes configured in the knowledge pipeline. Each node includes the " - "plugin it uses plus the metadata needed to run it." + "List the datasource nodes configured in the knowledge pipeline. Each node includes the plugin it uses " + "plus the metadata needed to run it." ), tags=["Knowledge Pipeline"], responses={ @@ -150,14 +154,13 @@ class DatasourcePluginsApi(DatasetApiResource): if not dataset: raise NotFound("Dataset not found.") - # Get query parameter to determine published or draft - is_published: bool = request.args.get("is_published", default=True, type=bool) + query = query_params_from_request(DatasourcePluginsQuery) rag_pipeline_service: RagPipelineService = RagPipelineService() datasource_plugins: list[dict[Any, Any]] = rag_pipeline_service.get_datasource_plugins( - tenant_id=tenant_id, dataset_id=dataset_id_str, is_published=is_published + tenant_id=tenant_id, dataset_id=dataset_id_str, is_published=query.is_published ) - return datasource_plugins, 200 + return dump_response(DatasourcePluginListResponse, datasource_plugins), 200 @service_api_ns.route("/datasets//pipeline/datasource/nodes//run") @@ -167,8 +170,8 @@ class DatasourceNodeRunApi(DatasetApiResource): @service_api_ns.doc( summary="Run Datasource Node", description=( - "Execute a single datasource node within the knowledge pipeline. Returns a streaming " - "response with the node execution results." + "Execute a single datasource node within the knowledge pipeline. Returns a streaming response with the " + "node execution results." ), tags=["Knowledge Pipeline"], responses={ @@ -187,11 +190,6 @@ class DatasourceNodeRunApi(DatasetApiResource): } ) @service_api_ns.expect(service_api_ns.models[DatasourceNodeRunPayload.__name__]) - @service_api_ns.response( - 200, - "Datasource node run successfully", - service_api_ns.models[GeneratedAppResponse.__name__], - ) def post(self, tenant_id: str, dataset_id: UUID, node_id: str): """Resource for getting datasource plugins.""" dataset_id_str = str(dataset_id) @@ -208,10 +206,11 @@ class DatasourceNodeRunApi(DatasetApiResource): datasource_node_run_api_entity = DatasourceNodeRunApiEntity.model_validate( { **payload.model_dump(exclude_none=True), - "pipeline_id": str(pipeline.id), + "pipeline_id": pipeline.id, "node_id": node_id, } ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response( PipelineGenerator.convert_to_event_stream( rag_pipeline_service.run_datasource_workflow_node( @@ -234,8 +233,8 @@ class PipelineRunApi(DatasetApiResource): @service_api_ns.doc( summary="Run Pipeline", description=( - "Execute the full knowledge pipeline for a knowledge base. Supports both streaming and " - "blocking response modes." + "Execute the full knowledge pipeline for a knowledge base. Supports both streaming and blocking response " + "modes." ), tags=["Knowledge Pipeline"], responses={ @@ -259,11 +258,6 @@ class PipelineRunApi(DatasetApiResource): } ) @service_api_ns.expect(service_api_ns.models[PipelineRunApiEntity.__name__]) - @service_api_ns.response( - 200, - "Pipeline run successfully", - service_api_ns.models[GeneratedAppResponse.__name__], - ) def post(self, tenant_id: str, dataset_id: UUID): """Resource for running a rag pipeline.""" dataset_id_str = str(dataset_id) @@ -289,6 +283,7 @@ class PipelineRunApi(DatasetApiResource): streaming=payload.response_mode == "streaming", ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except Exception as ex: raise PipelineRunError(description=str(ex)) @@ -364,4 +359,4 @@ class KnowledgebasePipelineFileUploadApi(DatasetApiResource): except services.errors.file.UnsupportedFileTypeError: raise UnsupportedFileTypeError() - return serialize_upload_file(upload_file), 201 + return dump_response(PipelineUploadFileResponse, upload_file), 201 diff --git a/api/controllers/web/completion.py b/api/controllers/web/completion.py index 7871b411c4b..34fd89dec53 100644 --- a/api/controllers/web/completion.py +++ b/api/controllers/web/completion.py @@ -5,7 +5,7 @@ from pydantic import BaseModel, Field, field_validator from werkzeug.exceptions import BadRequest, InternalServerError, NotFound import services -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import SimpleResultResponse from controllers.common.schema import register_response_schema_models, register_schema_models from controllers.web import web_ns from controllers.web.error import ( @@ -87,7 +87,7 @@ class ChatMessagePayload(BaseModel): register_schema_models(web_ns, CompletionMessagePayload, ChatMessagePayload) -register_response_schema_models(web_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(web_ns, SimpleResultResponse) # define completion api for user @@ -106,7 +106,7 @@ class CompletionApi(WebApiResource): 500: "Internal Server Error", } ) - @web_ns.response(200, "Success", web_ns.models[GeneratedAppResponse.__name__]) + @web_ns.response(200, "Success") def post(self, app_model: App, end_user: EndUser): if app_model.mode != AppMode.COMPLETION: raise NotCompletionAppError() @@ -122,6 +122,7 @@ class CompletionApi(WebApiResource): app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.WEB_APP, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -172,7 +173,7 @@ class CompletionStopApi(WebApiResource): app_mode=AppMode.value_of(app_model.mode), ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 @web_ns.route("/chat-messages") @@ -190,7 +191,7 @@ class ChatApi(WebApiResource): 500: "Internal Server Error", } ) - @web_ns.response(200, "Success", web_ns.models[GeneratedAppResponse.__name__]) + @web_ns.response(200, "Success") def post(self, app_model: App, end_user: EndUser): app_mode = AppMode.value_of(app_model.mode) if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT, AppMode.AGENT}: @@ -213,6 +214,7 @@ class ChatApi(WebApiResource): app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.WEB_APP, streaming=streaming ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except services.errors.conversation.ConversationNotExistsError: raise NotFound("Conversation Not Exists.") @@ -266,4 +268,4 @@ class ChatStopApi(WebApiResource): app_mode=app_mode, ) - return {"result": "success"}, 200 + return SimpleResultResponse(result="success").model_dump(mode="json"), 200 diff --git a/api/controllers/web/message.py b/api/controllers/web/message.py index 65ef02471a9..0ecf313660e 100644 --- a/api/controllers/web/message.py +++ b/api/controllers/web/message.py @@ -7,7 +7,6 @@ from pydantic import BaseModel, Field, TypeAdapter from werkzeug.exceptions import InternalServerError, NotFound from controllers.common.controller_schemas import MessageFeedbackPayload, MessageListQuery -from controllers.common.fields import GeneratedAppResponse from controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_models from controllers.web import web_ns from controllers.web.error import ( @@ -51,7 +50,6 @@ class MessageMoreLikeThisQuery(BaseModel): register_schema_models(web_ns, MessageListQuery, MessageFeedbackPayload, MessageMoreLikeThisQuery) register_response_schema_models( web_ns, - GeneratedAppResponse, ResultResponse, SuggestedQuestionsResponse, WebMessageInfiniteScrollPagination, @@ -161,7 +159,7 @@ class MessageMoreLikeThisApi(WebApiResource): 500: "Internal Server Error", } ) - @web_ns.response(200, "Success", web_ns.models[GeneratedAppResponse.__name__]) + @web_ns.response(200, "Success") def get(self, app_model: App, end_user: EndUser, message_id: UUID): if app_model.mode != "completion": raise NotCompletionAppError() @@ -182,6 +180,7 @@ class MessageMoreLikeThisApi(WebApiResource): streaming=streaming, ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except MessageNotExistsError: raise NotFound("Message Not Exists.") diff --git a/api/controllers/web/workflow.py b/api/controllers/web/workflow.py index 06d9c02fedc..b380eccfe5f 100644 --- a/api/controllers/web/workflow.py +++ b/api/controllers/web/workflow.py @@ -3,7 +3,7 @@ import logging from werkzeug.exceptions import InternalServerError from controllers.common.controller_schemas import WorkflowRunPayload -from controllers.common.fields import GeneratedAppResponse, SimpleResultResponse +from controllers.common.fields import SimpleResultResponse from controllers.common.schema import register_response_schema_models, register_schema_models from controllers.web import web_ns from controllers.web.error import ( @@ -33,7 +33,7 @@ from services.errors.llm import InvokeRateLimitError logger = logging.getLogger(__name__) register_schema_models(web_ns, WorkflowRunPayload) -register_response_schema_models(web_ns, GeneratedAppResponse, SimpleResultResponse) +register_response_schema_models(web_ns, SimpleResultResponse) @web_ns.route("/workflows/run") @@ -51,7 +51,7 @@ class WorkflowRunApi(WebApiResource): 500: "Internal Server Error", } ) - @web_ns.response(200, "Success", web_ns.models[GeneratedAppResponse.__name__]) + @web_ns.response(200, "Workflow run stream started") def post(self, app_model: App, end_user: EndUser): """ Run workflow @@ -68,6 +68,7 @@ class WorkflowRunApi(WebApiResource): app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.WEB_APP, streaming=True ) + # response-contract:ignore compact_generate_response return helper.compact_generate_response(response) except ProviderTokenNotInitError as ex: raise ProviderNotInitializeError(ex.description) @@ -121,4 +122,4 @@ class WorkflowTaskStopApi(WebApiResource): # New graph engine command channel mechanism GraphEngineManager(redis_client).send_stop_command(task_id) - return {"result": "success"} + return SimpleResultResponse(result="success").model_dump(mode="json") diff --git a/api/fields/member_fields.py b/api/fields/member_fields.py index 9bbcbef8429..80b93f0a24b 100644 --- a/api/fields/member_fields.py +++ b/api/fields/member_fields.py @@ -15,13 +15,13 @@ simple_account_fields = { } -class SimpleAccount(ResponseModel): +class SimpleAccountResponse(ResponseModel): id: str name: str email: str -class _AccountAvatar(ResponseModel): +class _AccountAvatarResponseMixin(ResponseModel): avatar: str | None = None @computed_field(return_type=str | None) # type: ignore[prop-decorator] @@ -30,7 +30,7 @@ class _AccountAvatar(ResponseModel): return build_avatar_url(self.avatar) -class Account(_AccountAvatar): +class AccountResponse(_AccountAvatarResponseMixin): id: str name: str email: str @@ -48,7 +48,7 @@ class Account(_AccountAvatar): return to_timestamp(value) -class AccountWithRole(_AccountAvatar): +class AccountWithRoleResponse(_AccountAvatarResponseMixin): id: str name: str email: str @@ -65,5 +65,11 @@ class AccountWithRole(_AccountAvatar): return to_timestamp(value) -class AccountWithRoleList(ResponseModel): - accounts: list[AccountWithRole] +class AccountWithRoleListResponse(ResponseModel): + accounts: list[AccountWithRoleResponse] + + +SimpleAccount = SimpleAccountResponse +Account = AccountResponse +AccountWithRole = AccountWithRoleResponse +AccountWithRoleList = AccountWithRoleListResponse diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.md index b3a0b8a6a71..d848d21de6b 100644 --- a/api/openapi/markdown/console-openapi.md +++ b/api/openapi/markdown/console-openapi.md @@ -38,7 +38,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/change-email #### Request Body @@ -77,7 +77,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/change-email/validity #### Request Body @@ -198,7 +198,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/interface-theme #### Request Body @@ -211,7 +211,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/name #### Request Body @@ -224,7 +224,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/password #### Request Body @@ -237,14 +237,14 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [GET] /account/profile #### Responses | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/timezone #### Request Body @@ -257,7 +257,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /activate Activate account with invitation token @@ -1433,7 +1433,7 @@ Get human input form preview for advanced chat workflow | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Human input form preview | **application/json**: [HumanInputFormPreviewResponse](#humaninputformpreviewresponse)
| +| 200 | Human input form preview retrieved | **application/json**: [HumanInputFormPreviewResponse](#humaninputformpreviewresponse)
| ### [POST] /apps/{app_id}/advanced-chat/workflows/draft/human-input/nodes/{node_id}/form/run **Submit human input form preview** @@ -1455,9 +1455,9 @@ Submit human input form preview for advanced chat workflow #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Human input form submission result | **application/json**: [HumanInputFormSubmitResponse](#humaninputformsubmitresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Human input form submitted | ### [POST] /apps/{app_id}/advanced-chat/workflows/draft/iteration/nodes/{node_id}/run **Run draft workflow iteration node** @@ -1479,11 +1479,11 @@ Run draft workflow iteration node for advanced chat #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Iteration node run started successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | -| 404 | Node not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Iteration node run started successfully | +| 403 | Permission denied | +| 404 | Node not found | ### [POST] /apps/{app_id}/advanced-chat/workflows/draft/loop/nodes/{node_id}/run **Run draft workflow loop node** @@ -1505,11 +1505,11 @@ Run draft workflow loop node for advanced chat #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Loop node run started successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | -| 404 | Node not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Loop node run started successfully | +| 403 | Permission denied | +| 404 | Node not found | ### [POST] /apps/{app_id}/advanced-chat/workflows/draft/run **Run draft workflow** @@ -1530,11 +1530,11 @@ Run draft workflow for advanced chat application #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Workflow run started successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | Invalid request parameters | | -| 403 | Permission denied | | +| Code | Description | +| ---- | ----------- | +| 200 | Workflow run started successfully | +| 400 | Invalid request parameters | +| 403 | Permission denied | ### [GET] /apps/{app_id}/agent/drive/files List agent drive entries (read-only inspector; one endpoint for both tabs) @@ -2227,11 +2227,11 @@ Generate completion message for debugging #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Completion generated successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | Invalid request parameters | | -| 404 | App not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Completion generated successfully | +| 400 | Invalid request parameters | +| 404 | App not found | ### [POST] /apps/{app_id}/completion-messages/{task_id}/stop Stop a running completion message generation @@ -3475,9 +3475,9 @@ Get default block configurations for workflow #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Default block configurations retrieved successfully | **application/json**: [DefaultBlockConfigsResponse](#defaultblockconfigsresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Default block configurations retrieved successfully | ### [GET] /apps/{app_id}/workflows/default-workflow-block-configs/{block_type} **Get default block config** @@ -3494,10 +3494,10 @@ Get default block configuration by type #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Default block configuration retrieved successfully | **application/json**: [DefaultBlockConfigResponse](#defaultblockconfigresponse)
| -| 404 | Block type not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Default block configuration retrieved successfully | +| 404 | Block type not found | ### [GET] /apps/{app_id}/workflows/draft **Get draft workflow** @@ -3661,7 +3661,7 @@ Test human input delivery for workflow | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Human input delivery test result | **application/json**: [EmptyObjectResponse](#emptyobjectresponse)
| +| 200 | Human input delivery tested | **application/json**: [HumanInputDeliveryTestResponse](#humaninputdeliverytestresponse)
| ### [POST] /apps/{app_id}/workflows/draft/human-input/nodes/{node_id}/form/preview **Preview human input form content and placeholders** @@ -3685,7 +3685,7 @@ Get human input form preview for workflow | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Human input form preview | **application/json**: [HumanInputFormPreviewResponse](#humaninputformpreviewresponse)
| +| 200 | Human input form preview retrieved | **application/json**: [HumanInputFormPreviewResponse](#humaninputformpreviewresponse)
| ### [POST] /apps/{app_id}/workflows/draft/human-input/nodes/{node_id}/form/run **Submit human input form preview** @@ -3707,9 +3707,9 @@ Submit human input form preview for workflow #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Human input form submission result | **application/json**: [HumanInputFormSubmitResponse](#humaninputformsubmitresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Human input form submitted | ### [POST] /apps/{app_id}/workflows/draft/iteration/nodes/{node_id}/run **Run draft workflow iteration node** @@ -3729,11 +3729,11 @@ Submit human input form preview for workflow #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Workflow iteration node run started successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | -| 404 | Node not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Workflow iteration node run started successfully | +| 403 | Permission denied | +| 404 | Node not found | ### [POST] /apps/{app_id}/workflows/draft/loop/nodes/{node_id}/run **Run draft workflow loop node** @@ -3753,11 +3753,11 @@ Submit human input form preview for workflow #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Workflow loop node run started successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | -| 404 | Node not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Workflow loop node run started successfully | +| 403 | Permission denied | +| 404 | Node not found | ### [GET] /apps/{app_id}/workflows/draft/nodes/{node_id}/agent-composer #### Parameters @@ -3943,7 +3943,7 @@ Get last run result for draft workflow node | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Trigger event received and node executed successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| 200 | Trigger event received and node executed successfully | **application/json**: [WorkflowRunNodeExecutionResponse](#workflowrunnodeexecutionresponse)
| | 403 | Permission denied | | | 500 | Internal server error | | @@ -3996,10 +3996,10 @@ Get variables for a specific node #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Draft workflow run started successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | +| Code | Description | +| ---- | ----------- | +| 200 | Draft workflow run started successfully | +| 403 | Permission denied | ### [GET] /apps/{app_id}/workflows/draft/runs/{run_id}/node-outputs Snapshot of every node's declared outputs for a draft workflow run. @@ -4100,15 +4100,15 @@ Get system variables for workflow | Required | Schema | | -------- | ------ | -| Yes | **application/json**: [DraftWorkflowTriggerRunRequest](#draftworkflowtriggerrunrequest)
| +| Yes | **application/json**: [DraftWorkflowTriggerRunPayload](#draftworkflowtriggerrunpayload)
| #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Trigger event received and workflow executed successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | -| 500 | Internal server error | | +| Code | Description | +| ---- | ----------- | +| 200 | Trigger event received and workflow executed successfully | +| 403 | Permission denied | +| 500 | Internal server error | ### [POST] /apps/{app_id}/workflows/draft/trigger/run-all **Full workflow debug when the start node is a trigger** @@ -4127,11 +4127,11 @@ Get system variables for workflow #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Workflow executed successfully | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 403 | Permission denied | | -| 500 | Internal server error | | +| Code | Description | +| ---- | ----------- | +| 200 | Workflow executed successfully | +| 403 | Permission denied | +| 500 | Internal server error | ### [DELETE] /apps/{app_id}/workflows/draft/variables Delete all draft workflow variables @@ -4278,7 +4278,7 @@ Get published workflow for an application | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Workflow published successfully | **application/json**: [WorkflowPublishResponse](#workflowpublishresponse)
| +| 200 | Workflow published successfully | **application/json**: [PublishWorkflowResponse](#publishworkflowresponse)
| ### [GET] /apps/{app_id}/workflows/published/runs/{run_id}/node-outputs Snapshot of every node's declared outputs for a published workflow run. @@ -4423,7 +4423,7 @@ Restore a published workflow version into the draft workflow | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Workflow restored successfully | **application/json**: [WorkflowRestoreResponse](#workflowrestoreresponse)
| +| 200 | Workflow restored successfully | **application/json**: [SyncDraftWorkflowResponse](#syncdraftworkflowresponse)
| | 400 | Source workflow must be published | | | 404 | Workflow not found | | @@ -6451,9 +6451,9 @@ Request body: #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /installed-apps/{installed_app_id}/chat-messages/{task_id}/stop #### Parameters @@ -6484,9 +6484,9 @@ Request body: #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /installed-apps/{installed_app_id}/completion-messages/{task_id}/stop #### Parameters @@ -6627,9 +6627,9 @@ Request body: #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [GET] /installed-apps/{installed_app_id}/messages/{message_id}/suggested-questions #### Parameters @@ -6759,9 +6759,9 @@ Request body: #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /installed-apps/{installed_app_id}/workflows/tasks/{task_id}/stop **Stop workflow task** @@ -7231,7 +7231,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| 200 | Datasource plugins retrieved successfully | **application/json**: [DatasourcePluginListResponse](#datasourcepluginlistresponse)
| ### [POST] /rag/pipelines/imports #### Request Body @@ -7286,7 +7286,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| 200 | Recommended plugins retrieved successfully | **application/json**: [RagPipelineRecommendedPluginResponse](#ragpipelinerecommendedpluginresponse)
| ### [POST] /rag/pipelines/transform/datasets/{dataset_id} #### Parameters @@ -7299,7 +7299,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| 200 | Dataset transformed successfully | **application/json**: [RagPipelineTransformResponse](#ragpipelinetransformresponse)
| ### [POST] /rag/pipelines/{pipeline_id}/customized/publish #### Parameters @@ -7430,9 +7430,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Default block configs retrieved successfully | **application/json**: [DefaultBlockConfigsResponse](#defaultblockconfigsresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Default workflow block configurations retrieved successfully | ### [GET] /rag/pipelines/{pipeline_id}/workflows/default-workflow-block-configs/{block_type} **Get default block config** @@ -7447,9 +7447,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Default block config retrieved successfully | **application/json**: [DefaultBlockConfigResponse](#defaultblockconfigresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Default workflow block configuration retrieved successfully | ### [GET] /rag/pipelines/{pipeline_id}/workflows/draft **Get draft rag pipeline's workflow** @@ -7506,9 +7506,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /rag/pipelines/{pipeline_id}/workflows/draft/datasource/variables-inspect **Set datasource variables** @@ -7564,9 +7564,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /rag/pipelines/{pipeline_id}/workflows/draft/loop/nodes/{node_id}/run **Run draft workflow loop node** @@ -7586,9 +7586,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [GET] /rag/pipelines/{pipeline_id}/workflows/draft/nodes/{node_id}/last-run #### Parameters @@ -7668,7 +7668,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineStepParametersResponse](#ragpipelinestepparametersresponse)
| +| 200 | First step parameters retrieved successfully | **application/json**: [RagPipelineVariablesResponse](#ragpipelinevariablesresponse)
| ### [GET] /rag/pipelines/{pipeline_id}/workflows/draft/processing/parameters **Get second step parameters of rag pipeline** @@ -7684,7 +7684,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineStepParametersResponse](#ragpipelinestepparametersresponse)
| +| 200 | Second step parameters retrieved successfully | **application/json**: [RagPipelineVariablesResponse](#ragpipelinevariablesresponse)
| ### [POST] /rag/pipelines/{pipeline_id}/workflows/draft/run **Run draft workflow** @@ -7703,9 +7703,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [GET] /rag/pipelines/{pipeline_id}/workflows/draft/system-variables #### Parameters @@ -7883,9 +7883,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [GET] /rag/pipelines/{pipeline_id}/workflows/published/pre-processing/parameters **Get first step parameters of rag pipeline** @@ -7901,7 +7901,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineStepParametersResponse](#ragpipelinestepparametersresponse)
| +| 200 | First step parameters retrieved successfully | **application/json**: [RagPipelineVariablesResponse](#ragpipelinevariablesresponse)
| ### [GET] /rag/pipelines/{pipeline_id}/workflows/published/processing/parameters **Get second step parameters of rag pipeline** @@ -7917,7 +7917,7 @@ Initiate OAuth login process | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineStepParametersResponse](#ragpipelinestepparametersresponse)
| +| 200 | Second step parameters retrieved successfully | **application/json**: [RagPipelineVariablesResponse](#ragpipelinevariablesresponse)
| ### [POST] /rag/pipelines/{pipeline_id}/workflows/published/run **Run published workflow** @@ -7936,9 +7936,9 @@ Initiate OAuth login process #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [RagPipelineOpaqueResponse](#ragpipelineopaqueresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [DELETE] /rag/pipelines/{pipeline_id}/workflows/{workflow_id} **Delete a published workflow version that is not currently active on the pipeline** @@ -8192,9 +8192,9 @@ Get all published workflows for a snippet #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Default block configs retrieved successfully | **application/json**: [DefaultBlockConfigsResponse](#defaultblockconfigsresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Default block configs retrieved successfully | ### [GET] /snippets/{snippet_id}/workflows/draft **Get draft workflow for snippet** @@ -8231,7 +8231,7 @@ Get all published workflows for a snippet | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Draft workflow synced successfully | **application/json**: [WorkflowRestoreResponse](#workflowrestoreresponse)
| +| 200 | Draft workflow synced successfully | **application/json**: [SyncDraftWorkflowResponse](#syncdraftworkflowresponse)
| | 400 | Hash mismatch | | ### [GET] /snippets/{snippet_id}/workflows/draft/config @@ -8304,7 +8304,7 @@ Returns an SSE event stream with iteration progress and results. | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Iteration node run started successfully (SSE stream) | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| 200 | Iteration node run started successfully (SSE stream) | **application/json**: [EventStreamResponse](#eventstreamresponse)
| | 404 | Snippet or draft workflow not found | | ### [POST] /snippets/{snippet_id}/workflows/draft/loop/nodes/{node_id}/run @@ -8331,7 +8331,7 @@ Returns an SSE event stream with loop progress and results. | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Loop node run started successfully (SSE stream) | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| 200 | Loop node run started successfully (SSE stream) | **application/json**: [EventStreamResponse](#eventstreamresponse)
| | 404 | Snippet or draft workflow not found | | ### [GET] /snippets/{snippet_id}/workflows/draft/nodes/{node_id}/last-run @@ -8436,7 +8436,7 @@ and returns an SSE event stream with execution progress and results. | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Draft workflow run started successfully (SSE stream) | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| 200 | Draft workflow run started successfully (SSE stream) | **application/json**: [EventStreamResponse](#eventstreamresponse)
| | 404 | Snippet or draft workflow not found | | ### [GET] /snippets/{snippet_id}/workflows/draft/system-variables @@ -8586,17 +8586,11 @@ Reset a draft workflow variable to its default value (snippet scope) | ---- | ---------- | ----------- | -------- | ------ | | snippet_id | path | | Yes | string (uuid) | -#### Request Body - -| Required | Schema | -| -------- | ------ | -| Yes | **application/json**: [PublishWorkflowPayload](#publishworkflowpayload)
| - #### Responses | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Workflow published successfully | **application/json**: [WorkflowPublishResponse](#workflowpublishresponse)
| +| 200 | Workflow published successfully | **application/json**: [PublishWorkflowResponse](#publishworkflowresponse)
| | 400 | No draft workflow found | | ### [POST] /snippets/{snippet_id}/workflows/{workflow_id}/restore @@ -8613,7 +8607,7 @@ Reset a draft workflow variable to its default value (snippet scope) | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Workflow restored successfully | **application/json**: [WorkflowRestoreResponse](#workflowrestoreresponse)
| +| 200 | Workflow restored successfully | **application/json**: [SyncDraftWorkflowResponse](#syncdraftworkflowresponse)
| | 400 | Source workflow must be published | | | 404 | Workflow not found | | @@ -8760,7 +8754,7 @@ Bedrock retrieval test (internal use only) | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [TrialAppDetailWithSite](#trialappdetailwithsite)
| +| 200 | App detail retrieved successfully | **application/json**: [AppDetailWithSite](#appdetailwithsite)
| ### [POST] /trial-apps/{app_id}/audio-to-text #### Parameters @@ -8790,9 +8784,9 @@ Bedrock retrieval test (internal use only) #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /trial-apps/{app_id}/completion-messages #### Parameters @@ -8809,9 +8803,9 @@ Bedrock retrieval test (internal use only) #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [GET] /trial-apps/{app_id}/datasets #### Parameters @@ -8827,7 +8821,7 @@ Bedrock retrieval test (internal use only) | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [TrialDatasetList](#trialdatasetlist)
| +| 200 | Success | **application/json**: [TrialDatasetListResponse](#trialdatasetlistresponse)
| ### [GET] /trial-apps/{app_id}/messages/{message_id}/suggested-questions #### Parameters @@ -8907,7 +8901,7 @@ Returns the site configuration for the application including theme, icons, and t | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [TrialWorkflow](#trialworkflow)
| +| 200 | Workflow detail retrieved successfully | **application/json**: [WorkflowResponse](#workflowresponse)
| ### [POST] /trial-apps/{app_id}/workflows/run **Run workflow** @@ -8926,9 +8920,9 @@ Returns the site configuration for the application including theme, icons, and t #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| +| Code | Description | +| ---- | ----------- | +| 200 | Success | ### [POST] /trial-apps/{app_id}/workflows/tasks/{task_id}/stop **Stop workflow task** @@ -9268,7 +9262,7 @@ Increment snippet use count by 1 | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [AccountWithRoleList](#accountwithrolelist)
| +| 200 | Success | **application/json**: [AccountWithRoleListResponse](#accountwithrolelistresponse)
| ### [GET] /workspaces/current/default-model #### Parameters @@ -9477,7 +9471,7 @@ Update a plugin endpoint | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [AccountWithRoleList](#accountwithrolelist)
| +| 200 | Success | **application/json**: [AccountWithRoleListResponse](#accountwithrolelistresponse)
| ### [POST] /workspaces/current/members/invite-email #### Request Body @@ -11928,23 +11922,6 @@ Default namespace | role_name | string | | No | | tenant_id | string | | No | -#### Account - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| avatar | string | | No | -| avatar_url | string | | Yes | -| created_at | integer | | No | -| email | string | | Yes | -| id | string | | Yes | -| interface_language | string | | No | -| interface_theme | string | | No | -| is_password_set | boolean | | Yes | -| last_login_at | integer | | No | -| last_login_ip | string | | No | -| name | string | | Yes | -| timezone | string | | No | - #### AccountAvatarPayload | Name | Type | Description | Required | @@ -12020,13 +11997,36 @@ Default namespace | password | string | | No | | repeat_new_password | string | | Yes | +#### AccountResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| avatar | string | | No | +| avatar_url | string | | Yes | +| created_at | integer | | No | +| email | string | | Yes | +| id | string | | Yes | +| interface_language | string | | No | +| interface_theme | string | | No | +| is_password_set | boolean | | Yes | +| last_login_at | integer | | No | +| last_login_ip | string | | No | +| name | string | | Yes | +| timezone | string | | No | + #### AccountTimezonePayload | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | timezone | string | | Yes | -#### AccountWithRole +#### AccountWithRoleListResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| accounts | [ [AccountWithRoleResponse](#accountwithroleresponse) ] | | Yes | + +#### AccountWithRoleResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -12041,12 +12041,6 @@ Default namespace | roles | [ object ] | | No | | status | string | | Yes | -#### AccountWithRoleList - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| accounts | [ [AccountWithRole](#accountwithrole) ] | | Yes | - #### ActivateCheckQuery | Name | Type | Description | Required | @@ -12095,7 +12089,7 @@ Default namespace | ---- | ---- | ----------- | -------- | | conversation_id | string | | No | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | elapsed_time | number | | No | | exceptions_count | integer | | No | | finished_at | integer | | No | @@ -13429,7 +13423,6 @@ Soft lifecycle state for Agent records. | created_at | integer | | No | | files | [ string ] | | Yes | | id | string | | Yes | -| message_chain_id | string | | No | | message_id | string | | Yes | | observation | string | | No | | position | integer | | Yes | @@ -13909,6 +13902,12 @@ AppMCPServer Status Enum | use_icon_as_answer_icon | boolean | | No | | workflow | [WorkflowPartial](#workflowpartial) | | No | +#### AppSelectorScope + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| AppSelectorScope | string | | | + #### AppSiteResponse | Name | Type | Description | Required | @@ -14540,8 +14539,8 @@ Enum class for configurate method of provider model. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | annotation_create_account | [SimpleAccount](#simpleaccount) | | No | +| annotation_id | string | | Yes | | created_at | integer | | No | -| id | string | | Yes | #### ConversationDetail @@ -15411,6 +15410,25 @@ Model class for provider custom model configuration. | ---- | ---- | ----------- | -------- | | id | string | | Yes | +#### DatasourceEntity + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| description | [I18nObject](#i18nobject) | The label of the datasource | Yes | +| identity | [DatasourceIdentity](#datasourceidentity) | | Yes | +| output_schema | object | | No | +| parameters | [ [DatasourceParameter](#datasourceparameter) ] | | No | + +#### DatasourceIdentity + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| author | string | The author of the datasource | Yes | +| icon | string | | No | +| label | [I18nObject](#i18nobject) | The label of the datasource | Yes | +| name | string | The name of the datasource | Yes | +| provider | string | The provider of the datasource | Yes | + #### DatasourceNodeRunPayload | Name | Type | Description | Required | @@ -15434,6 +15452,70 @@ Model class for provider custom model configuration. | error | string | Error message from OAuth provider | No | | state | string | OAuth state parameter | No | +#### DatasourceParameter + +Overrides type + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| auto_generate | [PluginParameterAutoGenerate](#pluginparameterautogenerate) | | No | +| default | number
integer
string
boolean
[ object ]
object | | No | +| description | [I18nObject](#i18nobject) | The description of the parameter | Yes | +| label | [I18nObject](#i18nobject) | The label presented to the user | Yes | +| max | number
integer | | No | +| min | number
integer | | No | +| name | string | The name of the parameter | Yes | +| options | [ [PluginParameterOption](#pluginparameteroption) ] | | No | +| placeholder | [I18nObject](#i18nobject) | The placeholder presented to the user | No | +| precision | integer | | No | +| required | boolean | | No | +| scope | string | | No | +| template | [PluginParameterTemplate](#pluginparametertemplate) | | No | +| type | [DatasourceParameterType](#datasourceparametertype) | The type of the parameter | Yes | + +#### DatasourceParameterType + +removes TOOLS_SELECTOR from PluginParameterType + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| DatasourceParameterType | string | removes TOOLS_SELECTOR from PluginParameterType | | + +#### DatasourcePluginListResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| DatasourcePluginListResponse | array | | | + +#### DatasourceProviderEntityWithPlugin + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| credentials_schema | [ [ProviderConfig](#providerconfig) ] | | No | +| datasources | [ [DatasourceEntity](#datasourceentity) ] | | No | +| identity | [DatasourceProviderIdentity](#datasourceprovideridentity) | | Yes | +| oauth_schema | [OAuthSchema](#oauthschema) | | No | +| provider_type | [DatasourceProviderType](#datasourceprovidertype) | | Yes | + +#### DatasourceProviderIdentity + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| author | string | The author of the tool | Yes | +| description | [I18nObject](#i18nobject) | The description of the tool | Yes | +| icon | string | The icon of the tool | Yes | +| label | [I18nObject](#i18nobject) | The label of the tool | Yes | +| name | string | The name of the tool | Yes | +| tags | [ [ToolLabelEnum](#toollabelenum) ] | The tags of the tool | No | + +#### DatasourceProviderType + +Enum class for datasource provider + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| DatasourceProviderType | string | Enum class for datasource provider | | + #### DatasourceUpdateNamePayload | Name | Type | Description | Required | @@ -15548,18 +15630,6 @@ Per-output retry configuration that mirrors ``graphon.RetryConfig`` shape. | ---- | ---- | ----------- | -------- | | q | string | | No | -#### DefaultBlockConfigResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| DefaultBlockConfigResponse | object | | | - -#### DefaultBlockConfigsResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| DefaultBlockConfigsResponse | array | | | - #### DefaultModelDataResponse | Name | Type | Description | Required | @@ -15768,12 +15838,6 @@ Request payload for bulk downloading documents as a zip archive. | ---- | ---- | ----------- | -------- | | node_id | string | | Yes | -#### DraftWorkflowTriggerRunRequest - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| node_id | string | Node ID | Yes | - #### EducationActivatePayload | Name | Type | Description | Required | @@ -15883,12 +15947,6 @@ Request payload for bulk downloading documents as a zip archive. | email | string | | Yes | | token | string | | Yes | -#### EmptyObjectResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| EmptyObjectResponse | object | | | - #### EndpointCreatePayload | Name | Type | Description | Required | @@ -16359,12 +16417,6 @@ Enum class for form type. | ---- | ---- | ----------- | -------- | | document_list | [ string ] | | Yes | -#### GeneratedAppResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| GeneratedAppResponse | | | | - #### GeneratorResponse | Name | Type | Description | Required | @@ -16488,6 +16540,11 @@ Enum class for form type. | delivery_method_id | string | Delivery method ID | Yes | | inputs | object | Values used to fill missing upstream variables referenced in form_content | No | +#### HumanInputDeliveryTestResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | + #### HumanInputFormDefinition | Name | Type | Description | Required | @@ -16513,12 +16570,13 @@ Enum class for form type. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| actions | [ object ] | | No | -| display_in_ui | boolean | | No | -| expiration_time | integer | | No | +| TYPE | string,
**Default:** human_input_required | | No | +| actions | [ [HumanInputUserActionResponse](#humaninputuseractionresponse) ] | | No | +| display_in_ui | boolean | Always false for draft preview responses. | No | +| expiration_time | integer | Always null for draft preview responses. | No | | form_content | string | | Yes | | form_id | string | | Yes | -| form_token | string | | No | +| form_token | string | Always null for draft preview responses. | No | | inputs | [ object ] | | No | | node_id | string | | Yes | | node_title | string | | Yes | @@ -16543,12 +16601,6 @@ Enum class for form type. | form_inputs | object | Values the user provides for the form's own fields | Yes | | inputs | object | Values used to fill missing upstream variables referenced in form_content | Yes | -#### HumanInputFormSubmitResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| HumanInputFormSubmitResponse | object | | | - #### HumanInputPauseTypeResponse | Name | Type | Description | Required | @@ -16557,6 +16609,14 @@ Enum class for form type. | form_id | string | | Yes | | type | string | | Yes | +#### HumanInputUserActionResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| button_style | string,
**Default:** default | | No | +| id | string | | Yes | +| title | string | | Yes | + #### I18nObject Model class for i18n object. @@ -16782,7 +16842,7 @@ Input field definition for snippet parameters. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| JSONValue | string
integer
number
boolean
object
[ object ] | | | +| JSONValue | | | | #### JSONValueType @@ -17079,6 +17139,7 @@ Enum class for large language model mode. | agent_thoughts | [ [AgentThought](#agentthought) ] | | No | | annotation | [ConversationAnnotation](#conversationannotation) | | No | | annotation_hit_history | [ConversationAnnotationHitHistory](#conversationannotationhithistory) | | No | +| answer | string | | Yes | | answer_tokens | integer | | No | | conversation_id | string | | Yes | | created_at | integer | | No | @@ -17092,12 +17153,11 @@ Enum class for large language model mode. | inputs | object | | Yes | | message | [JSONValue](#jsonvalue) | | No | | message_files | [ [MessageFile](#messagefile) ] | | No | -| message_metadata_dict | [JSONValue](#jsonvalue) | | No | | message_tokens | integer | | No | +| metadata | [JSONValue](#jsonvalue) | | No | | parent_message_id | string | | No | | provider_response_latency | number | | No | | query | string | | Yes | -| re_sign_file_url_answer | string | | Yes | | status | string | | Yes | | workflow_run_id | string | | No | @@ -17181,10 +17241,30 @@ Metadata operation data | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| completion_params | object | | No | -| mode | [LLMMode](#llmmode) | | Yes | -| name | string | | Yes | -| provider | string | | Yes | +| agent_mode | [JSONValue](#jsonvalue) | | No | +| annotation_reply | [JSONValue](#jsonvalue) | | No | +| chat_prompt_config | [JSONValue](#jsonvalue) | | No | +| completion_prompt_config | [JSONValue](#jsonvalue) | | No | +| created_at | integer | | No | +| created_by | string | | No | +| dataset_configs | [JSONValue](#jsonvalue) | | No | +| dataset_query_variable | string | | No | +| external_data_tools | [JSONValue](#jsonvalue) | | No | +| file_upload | [JSONValue](#jsonvalue) | | No | +| model | [JSONValue](#jsonvalue) | | No | +| more_like_this | [JSONValue](#jsonvalue) | | No | +| opening_statement | string | | No | +| pre_prompt | string | | No | +| prompt_type | string | | No | +| retriever_resource | [JSONValue](#jsonvalue) | | No | +| sensitive_word_avoidance | [JSONValue](#jsonvalue) | | No | +| speech_to_text | [JSONValue](#jsonvalue) | | No | +| suggested_questions | [JSONValue](#jsonvalue) | | No | +| suggested_questions_after_answer | [JSONValue](#jsonvalue) | | No | +| text_to_speech | [JSONValue](#jsonvalue) | | No | +| updated_at | integer | | No | +| updated_by | string | | No | +| user_input_form | [JSONValue](#jsonvalue) | | No | #### ModelConfigPartial @@ -17281,6 +17361,12 @@ Enum class for model property key. | ---- | ---- | ----------- | -------- | | payment_link | string | | Yes | +#### ModelSelectorScope + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| ModelSelectorScope | string | | | + #### ModelStatus Enum class for model status. @@ -17571,6 +17657,15 @@ Coarse node-level status used by Inspector to pick a banner. | refresh_token | string | | Yes | | token_type | string | | Yes | +#### OAuthSchema + +OAuth schema + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| client_schema | [ [ProviderConfig](#providerconfig) ] | client schema like client_id, client_secret, etc. | No | +| credentials_schema | [ [ProviderConfig](#providerconfig) ] | credentials schema like access_token, refresh_token, etc. | No | + #### OAuthTokenRequest | Name | Type | Description | Required | @@ -17588,6 +17683,13 @@ Coarse node-level status used by Inspector to pick a banner. | ---- | ---- | ----------- | -------- | | OpaqueObjectResponse | object | | | +#### Option + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| label | [I18nObject](#i18nobject) | The label of the option | Yes | +| value | string | The value of the option | Yes | + #### OutputErrorStrategy Per-output failure handling strategy. @@ -18239,6 +18341,16 @@ Shared permission levels for resources (datasets, credentials, etc.) | ---- | ---- | ----------- | -------- | | PluginDaemonOperationResponse | | | | +#### PluginDatasourceProviderEntity + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| declaration | [DatasourceProviderEntityWithPlugin](#datasourceproviderentitywithplugin) | | Yes | +| is_authorized | boolean | | No | +| plugin_id | string | | Yes | +| plugin_unique_identifier | string | | Yes | +| provider | string | | Yes | + #### PluginDebuggingKeyResponse | Name | Type | Description | Required | @@ -18350,6 +18462,26 @@ Shared permission levels for resources (datasets, credentials, etc.) | message | string | | No | | success | boolean | | Yes | +#### PluginParameterAutoGenerate + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| type | [core__plugin__entities__parameters__PluginParameterAutoGenerate__Type](#core__plugin__entities__parameters__pluginparameterautogenerate__type) | | Yes | + +#### PluginParameterOption + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| icon | string | The icon of the option, can be a url or a base64 encoded image | No | +| label | [I18nObject](#i18nobject) | The label of the option | Yes | +| value | string | The value of the option | Yes | + +#### PluginParameterTemplate + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| enabled | boolean | Whether the parameter is jinja enabled | No | + #### PluginPermissionResponse | Name | Type | Description | Required | @@ -18429,6 +18561,24 @@ Dataset Process Rule Mode | ---- | ---- | ----------- | -------- | | ProcessRuleMode | string | Dataset Process Rule Mode | | +#### ProviderConfig + +Model class for common provider settings like credentials + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| default | integer
string
number
boolean | | No | +| help | [I18nObject](#i18nobject) | | No | +| label | [I18nObject](#i18nobject) | | No | +| multiple | boolean | | No | +| name | string | The name of the credentials | Yes | +| options | [ [Option](#option) ] | | No | +| placeholder | [I18nObject](#i18nobject) | | No | +| required | boolean | | No | +| scope | [AppSelectorScope](#appselectorscope)
[ModelSelectorScope](#modelselectorscope)
[ToolSelectorScope](#toolselectorscope) | | No | +| type | [core__entities__provider_entities__BasicProviderConfig__Type](#core__entities__provider_entities__basicproviderconfig__type) | The type of the credentials | Yes | +| url | string | | No | + #### ProviderCredentialResponse | Name | Type | Description | Required | @@ -18559,11 +18709,17 @@ Model class for provider with models response. #### PublishWorkflowPayload -Payload for publishing snippet workflow. +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| marked_comment | string | | No | +| marked_name | string | | No | + +#### PublishWorkflowResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| knowledge_base_setting | object | | No | +| created_at | integer | | Yes | +| result | string | | Yes | #### PublishedWorkflowRunPayload @@ -18672,19 +18828,28 @@ Model class for provider quota configuration. | pipeline_id | string | | No | | status | [ImportStatus](#importstatus) | | Yes | -#### RagPipelineOpaqueResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| RagPipelineOpaqueResponse | | | | - #### RagPipelineRecommendedPluginQuery | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | type | string,
**Default:** all | | No | -#### RagPipelineStepParametersResponse +#### RagPipelineRecommendedPluginResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| installed_recommended_plugins | [ object ] | Installed tool provider payloads. Shape follows the tool provider serializer. | Yes | +| uninstalled_recommended_plugins | [ object ] | Marketplace plugin manifest payloads returned by the marketplace service. | Yes | + +#### RagPipelineTransformResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| dataset_id | string | | Yes | +| pipeline_id | string | | Yes | +| status | string | | Yes | + +#### RagPipelineVariablesResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -19151,6 +19316,14 @@ Model class for provider quota configuration. | id | string | | Yes | | name | string | | Yes | +#### SimpleAccountResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| email | string | | Yes | +| id | string | | Yes | +| name | string | | Yes | + #### SimpleConversation | Name | Type | Description | Required | @@ -19458,7 +19631,7 @@ Query parameters for listing snippet published workflows. | ---- | ---- | ----------- | -------- | | conversation_variables | [ [WorkflowConversationVariableResponse](#workflowconversationvariableresponse) ] | | Yes | | created_at | integer | | Yes | -| created_by | [SimpleAccount](#simpleaccount) | | No | +| created_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | environment_variables | [ [WorkflowEnvironmentVariableResponse](#workflowenvironmentvariableresponse) ] | | Yes | | features | object | | Yes | | graph | object | | Yes | @@ -19470,7 +19643,7 @@ Query parameters for listing snippet published workflows. | rag_pipeline_variables | [ [PipelineVariableResponse](#pipelinevariableresponse) ] | | Yes | | tool_published | boolean | | Yes | | updated_at | integer | | Yes | -| updated_by | [SimpleAccount](#simpleaccount) | | No | +| updated_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | version | string | | Yes | #### StarredAppListQuery @@ -19579,9 +19752,9 @@ Default configuration for form inputs. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| hash | string | | No | -| result | string | | No | -| updated_at | string | | No | +| hash | string | | Yes | +| result | string | | Yes | +| updated_at | integer | | Yes | #### SystemConfigurationResponse @@ -19796,6 +19969,12 @@ Tag type | ---- | ---- | ----------- | -------- | | data | [ [TokensPerSecondStatisticItem](#tokenspersecondstatisticitem) ] | | Yes | +#### ToolLabelEnum + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| ToolLabelEnum | string | | | + #### ToolOAuthClientSchemaResponse | Name | Type | Description | Required | @@ -19841,6 +20020,12 @@ Enum class for tool provider | ---- | ---- | ----------- | -------- | | ToolProviderType | string | Enum class for tool provider | | +#### ToolSelectorScope + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| ToolSelectorScope | string | | | + #### TraceAppConfigResponse | Name | Type | Description | Required | @@ -19869,97 +20054,47 @@ Enum class for tool provider | ---- | ---- | ----------- | -------- | | tracing_provider | string | Tracing provider name | Yes | -#### TrialAppDetailWithSite +#### TrialDatasetListItemResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| access_mode | string | | No | -| api_base_url | string | | No | -| created_at | long | | No | -| created_by | string | | No | -| deleted_tools | [ [TrialDeletedTool](#trialdeletedtool) ] | | No | -| description | string | | No | -| enable_api | boolean | | No | -| enable_site | boolean | | No | -| icon | string | | No | -| icon_background | string | | No | -| icon_type | string | | No | -| icon_url | string | | No | -| id | string | | No | -| max_active_requests | integer | | No | -| mode | string | | No | -| model_config | [TrialAppModelConfig](#trialappmodelconfig) | | No | -| name | string | | No | +| app_count | integer | | Yes | +| author_name | string | | Yes | +| built_in_field_enabled | boolean | | Yes | +| chunk_structure | string | | Yes | +| created_at | integer | | Yes | +| created_by | string | | Yes | +| data_source_type | string | | Yes | +| description | string | | Yes | +| doc_form | string | | Yes | +| doc_metadata | [ [DatasetDocMetadataResponse](#datasetdocmetadataresponse) ] | | Yes | +| document_count | integer | | Yes | +| embedding_available | boolean | | No | +| embedding_model | string | | Yes | +| embedding_model_provider | string | | Yes | +| enable_api | boolean | | Yes | +| external_knowledge_info | [DatasetExternalKnowledgeInfoResponse](#datasetexternalknowledgeinforesponse) | | No | +| external_retrieval_model | [DatasetExternalRetrievalModelResponse](#datasetexternalretrievalmodelresponse) | | Yes | +| icon_info | [DatasetIconInfoResponse](#dataseticoninforesponse) | | No | +| id | string | | Yes | +| indexing_technique | string | | Yes | +| is_multimodal | boolean | | Yes | +| is_published | boolean | | Yes | +| maintainer | string | | No | +| name | string | | Yes | +| permission | string | | Yes | | permission_keys | [ string ] | | No | -| site | [TrialSite](#trialsite) | | No | -| tags | [ [TrialTag](#trialtag) ] | | No | -| updated_at | long | | No | -| updated_by | string | | No | -| use_icon_as_answer_icon | boolean | | No | -| workflow | [TrialWorkflowPartial](#trialworkflowpartial) | | No | - -#### TrialAppModelConfig - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| agent_mode | object | | No | -| annotation_reply | object | | No | -| chat_prompt_config | object | | No | -| completion_prompt_config | object | | No | -| created_at | long | | No | -| created_by | string | | No | -| dataset_configs | object | | No | -| dataset_query_variable | string | | No | -| external_data_tools | [ object ] | | No | -| file_upload | object | | No | -| model | object | | No | -| more_like_this | object | | No | -| opening_statement | string | | No | -| pre_prompt | string | | No | -| prompt_type | string | | No | -| retriever_resource | object | | No | -| sensitive_word_avoidance | object | | No | -| speech_to_text | object | | No | -| suggested_questions | [ string ] | | No | -| suggested_questions_after_answer | object | | No | -| text_to_speech | object | | No | -| updated_at | long | | No | -| updated_by | string | | No | -| user_input_form | [ object ] | | No | - -#### TrialConversationVariable - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| description | string | | No | -| id | string | | No | -| name | string | | No | -| value | string
integer
number
boolean
object
[ object ] | | No | -| value_type | string | | No | - -#### TrialDataset - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| created_at | long | | No | -| created_by | string | | No | -| data_source_type | string | | No | -| description | string | | No | -| id | string | | No | -| indexing_technique | string | | No | -| name | string | | No | -| permission | string | | No | -| permission_keys | [ string ] | | No | - -#### TrialDatasetList - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| data | [ [TrialDataset](#trialdataset) ] | | No | -| has_more | boolean | | No | -| limit | integer | | No | -| page | integer | | No | -| total | integer | | No | +| pipeline_id | string | | Yes | +| provider | string | | Yes | +| retrieval_model_dict | [DatasetRetrievalModelResponse](#datasetretrievalmodelresponse) | | Yes | +| runtime_mode | string | | Yes | +| summary_index_setting | [DatasetSummaryIndexSettingResponse](#datasetsummaryindexsettingresponse) | | No | +| tags | [ [DatasetTagResponse](#datasettagresponse) ] | | Yes | +| total_available_documents | integer | | Yes | +| total_documents | integer | | Yes | +| updated_at | integer | | Yes | +| updated_by | string | | Yes | +| word_count | integer | | Yes | #### TrialDatasetListQuery @@ -19969,13 +20104,15 @@ Enum class for tool provider | limit | integer,
**Default:** 20 | Number of items per page | No | | page | integer,
**Default:** 1 | Page number | No | -#### TrialDeletedTool +#### TrialDatasetListResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| provider_id | string | | No | -| tool_name | string | | No | -| type | string | | No | +| data | [ [TrialDatasetListItemResponse](#trialdatasetlistitemresponse) ] | | Yes | +| has_more | boolean | | Yes | +| limit | integer | | Yes | +| page | integer | | Yes | +| total | integer | | Yes | #### TrialModelsResponse @@ -19983,99 +20120,19 @@ Enum class for tool provider | ---- | ---- | ----------- | -------- | | trial_models | [ string ] | | Yes | -#### TrialPipelineVariable +#### TriggerDebugErrorResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| allow_file_extension | [ string ] | | No | -| allow_file_upload_methods | [ string ] | | No | -| allowed_file_types | [ string ] | | No | -| belong_to_node_id | string | | No | -| default_value | string
integer
number
boolean
object
[ object ] | | No | -| label | string | | No | -| max_length | integer | | No | -| options | [ string ] | | No | -| placeholder | string | | No | -| required | boolean | | No | -| tooltips | string | | No | -| type | string | | No | -| unit | string | | No | -| variable | string | | No | +| error | string | | No | +| status | string | | Yes | -#### TrialSimpleAccount +#### TriggerDebugWaitingResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| email | string | | No | -| id | string | | No | -| name | string | | No | - -#### TrialSite - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| access_token | string | | No | -| app_base_url | string | | No | -| chat_color_theme | string | | No | -| chat_color_theme_inverted | boolean | | No | -| code | string | | No | -| copyright | string | | No | -| created_at | long | | No | -| created_by | string | | No | -| custom_disclaimer | string | | No | -| customize_domain | string | | No | -| customize_token_strategy | string | | No | -| default_language | string | | No | -| description | string | | No | -| icon | string | | No | -| icon_background | string | | No | -| icon_type | string | | No | -| icon_url | string | | No | -| privacy_policy | string | | No | -| prompt_public | boolean | | No | -| show_workflow_steps | boolean | | No | -| title | string | | No | -| updated_at | long | | No | -| updated_by | string | | No | -| use_icon_as_answer_icon | boolean | | No | - -#### TrialTag - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| id | string | | No | -| name | string | | No | -| type | string | | No | - -#### TrialWorkflow - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| conversation_variables | [ [TrialConversationVariable](#trialconversationvariable) ] | | No | -| created_at | long | | No | -| created_by | [TrialSimpleAccount](#trialsimpleaccount) | | No | -| environment_variables | [ object ] | | No | -| features | object | | No | -| graph | object | | No | -| hash | string | | No | -| id | string | | No | -| marked_comment | string | | No | -| marked_name | string | | No | -| rag_pipeline_variables | [ [TrialPipelineVariable](#trialpipelinevariable) ] | | No | -| tool_published | boolean | | No | -| updated_at | long | | No | -| updated_by | [TrialSimpleAccount](#trialsimpleaccount) | | No | -| version | string | | No | - -#### TrialWorkflowPartial - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| created_at | long | | No | -| created_by | string | | No | -| id | string | | No | -| updated_at | long | | No | -| updated_by | string | | No | +| retry_in | integer | | Yes | +| status | string | | Yes | #### TriggerOAuthAuthorizeResponse @@ -20390,7 +20447,7 @@ How a workflow node is bound to an Agent. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | created_from | string | | No | @@ -20427,7 +20484,7 @@ How a workflow node is bound to an Agent. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | id | string | | Yes | | trigger_metadata | | | No | @@ -20528,7 +20585,7 @@ How a workflow node is bound to an Agent. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| users | [ [AccountWithRole](#accountwithrole) ] | | Yes | +| users | [ [AccountWithRoleResponse](#accountwithroleresponse) ] | | Yes | #### WorkflowCommentReply @@ -20864,20 +20921,13 @@ can reuse its existing handler. | variable | string | | No | | variable_selector | [ string
integer
number
boolean ] | | No | -#### WorkflowPublishResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| created_at | integer | | Yes | -| result | string | | Yes | - #### WorkflowResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | conversation_variables | [ [WorkflowConversationVariableResponse](#workflowconversationvariableresponse) ] | | Yes | | created_at | integer | | Yes | -| created_by | [SimpleAccount](#simpleaccount) | | No | +| created_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | environment_variables | [ [WorkflowEnvironmentVariableResponse](#workflowenvironmentvariableresponse) ] | | Yes | | features | object | | Yes | | graph | object | | Yes | @@ -20888,17 +20938,9 @@ can reuse its existing handler. | rag_pipeline_variables | [ [PipelineVariableResponse](#pipelinevariableresponse) ] | | Yes | | tool_published | boolean | | Yes | | updated_at | integer | | Yes | -| updated_by | [SimpleAccount](#simpleaccount) | | No | +| updated_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | version | string | | Yes | -#### WorkflowRestoreResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| hash | string | | Yes | -| result | string | | Yes | -| updated_at | integer | | Yes | - #### WorkflowRunCountQuery | Name | Type | Description | Required | @@ -20923,7 +20965,7 @@ can reuse its existing handler. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | elapsed_time | number | | No | @@ -20962,7 +21004,7 @@ can reuse its existing handler. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | elapsed_time | number | | No | | exceptions_count | integer | | No | | finished_at | integer | | No | @@ -21009,7 +21051,7 @@ can reuse its existing handler. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | elapsed_time | number | | No | @@ -21311,6 +21353,18 @@ Workflow tool configuration | data | [ [RBACRole](#rbacrole) ] | | No | | pagination | [Pagination](#pagination) | | No | +#### core__entities__provider_entities__BasicProviderConfig__Type + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| core__entities__provider_entities__BasicProviderConfig__Type | string | | | + +#### core__plugin__entities__parameters__PluginParameterAutoGenerate__Type + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| core__plugin__entities__parameters__PluginParameterAutoGenerate__Type | string | | | + #### core__tools__entities__common_entities__I18nObject Model class for i18n object. diff --git a/api/openapi/markdown/service-openapi.md b/api/openapi/markdown/service-openapi.md index 8fc5e75e3cf..bf841562cae 100644 --- a/api/openapi/markdown/service-openapi.md +++ b/api/openapi/markdown/service-openapi.md @@ -392,15 +392,15 @@ Send a request to the chat application. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of Server-Sent Events. | **application/json**: [GeneratedAppResponse](#generatedappresponse)
**text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | - `app_unavailable` : App unavailable or misconfigured. - `not_chat_app` : App mode does not match the API route. - `conversation_completed` : The conversation has ended. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Text generation failed. | | -| 401 | Unauthorized - invalid API token | | -| 403 | Forbidden - token scope, app, dataset, or workspace access denied | | -| 404 | `not_found` : Conversation does not exist. | | -| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | | -| 500 | `internal_server_error` : Internal server error. | | +| Code | Description | +| ---- | ----------- | +| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of Server-Sent Events. | +| 400 | - `app_unavailable` : App unavailable or misconfigured. - `not_chat_app` : App mode does not match the API route. - `conversation_completed` : The conversation has ended. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Text generation failed. | +| 401 | Unauthorized - invalid API token | +| 403 | Forbidden - token scope, app, dataset, or workspace access denied | +| 404 | `not_found` : Conversation does not exist. | +| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | +| 500 | `internal_server_error` : Internal server error. | ### [POST] /chat-messages/{task_id}/stop **Stop Chat Message Generation** @@ -539,15 +539,15 @@ Send a request to the chat application. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of Server-Sent Events. | **application/json**: [GeneratedAppResponse](#generatedappresponse)
**text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | - `app_unavailable` : App unavailable or misconfigured. - `not_chat_app` : App mode does not match the API route. - `conversation_completed` : The conversation has ended. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Text generation failed. | | -| 401 | Unauthorized - invalid API token | | -| 403 | Forbidden - token scope, app, dataset, or workspace access denied | | -| 404 | `not_found` : Conversation does not exist. | | -| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | | -| 500 | `internal_server_error` : Internal server error. | | +| Code | Description | +| ---- | ----------- | +| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of Server-Sent Events. | +| 400 | - `app_unavailable` : App unavailable or misconfigured. - `not_chat_app` : App mode does not match the API route. - `conversation_completed` : The conversation has ended. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Text generation failed. | +| 401 | Unauthorized - invalid API token | +| 403 | Forbidden - token scope, app, dataset, or workspace access denied | +| 404 | `not_found` : Conversation does not exist. | +| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | +| 500 | `internal_server_error` : Internal server error. | ### [POST] /chat-messages/{task_id}/stop **Stop Chat Message Generation** @@ -615,15 +615,15 @@ Send a request to the text generation application. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `CompletionResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkCompletionEvent` objects. | **application/json**: [GeneratedAppResponse](#generatedappresponse)
**text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | - `app_unavailable` : App unavailable or misconfigured. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Text generation failed. | | -| 401 | Unauthorized - invalid API token | | -| 403 | Forbidden - token scope, app, dataset, or workspace access denied | | -| 404 | Conversation not found | | -| 429 | `too_many_requests` : Too many concurrent requests for this app. | | -| 500 | `internal_server_error` : Internal server error. | | +| Code | Description | +| ---- | ----------- | +| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `CompletionResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkCompletionEvent` objects. | +| 400 | - `app_unavailable` : App unavailable or misconfigured. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Text generation failed. | +| 401 | Unauthorized - invalid API token | +| 403 | Forbidden - token scope, app, dataset, or workspace access denied | +| 404 | Conversation not found | +| 429 | `too_many_requests` : Too many concurrent requests for this app. | +| 500 | `internal_server_error` : Internal server error. | ### [POST] /completion-messages/{task_id}/stop **Stop Completion Message Generation** @@ -1046,12 +1046,12 @@ Execute a single datasource node within the knowledge pipeline. Returns a stream #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Streaming response with node execution events. | **text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 401 | Unauthorized - invalid API token | | -| 403 | Forbidden - dataset API access or workspace access denied | | -| 404 | `not_found` : Dataset not found. | | +| Code | Description | +| ---- | ----------- | +| 200 | Streaming response with node execution events. | +| 401 | Unauthorized - invalid API token | +| 403 | Forbidden - dataset API access or workspace access denied | +| 404 | `not_found` : Dataset not found. | ### [POST] /datasets/{dataset_id}/pipeline/run **Run Pipeline** @@ -1072,13 +1072,13 @@ Execute the full knowledge pipeline for a knowledge base. Supports both streamin #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Pipeline execution result. Format depends on `response_mode`: streaming returns a `text/event-stream`, blocking returns a JSON object. | **application/json**: [GeneratedAppResponse](#generatedappresponse)
**text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 401 | Unauthorized - invalid API token | | -| 403 | `forbidden` : Forbidden. | | -| 404 | `not_found` : Dataset not found. | | -| 500 | `pipeline_run_error` : Pipeline execution failed. | | +| Code | Description | +| ---- | ----------- | +| 200 | Pipeline execution result. Format depends on `response_mode`: streaming returns a `text/event-stream`, blocking returns a JSON object. | +| 401 | Unauthorized - invalid API token | +| 403 | `forbidden` : Forbidden. | +| 404 | `not_found` : Dataset not found. | +| 500 | `pipeline_run_error` : Pipeline execution failed. | --- ## default @@ -2220,15 +2220,15 @@ Execute a workflow. Cannot be executed without a published workflow. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `WorkflowBlockingResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkWorkflowEvent` objects. | **application/json**: [GeneratedAppResponse](#generatedappresponse)
**text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | - `not_workflow_app` : App mode does not match the API route. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Workflow execution request failed. - `invalid_param` : Invalid parameter value. | | -| 401 | Unauthorized - invalid API token | | -| 403 | Forbidden - token scope, app, dataset, or workspace access denied | | -| 404 | Workflow not found | | -| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | | -| 500 | `internal_server_error` : Internal server error. | | +| Code | Description | +| ---- | ----------- | +| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `WorkflowBlockingResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkWorkflowEvent` objects. | +| 400 | - `not_workflow_app` : App mode does not match the API route. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Workflow execution request failed. - `invalid_param` : Invalid parameter value. | +| 401 | Unauthorized - invalid API token | +| 403 | Forbidden - token scope, app, dataset, or workspace access denied | +| 404 | Workflow not found | +| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | +| 500 | `internal_server_error` : Internal server error. | ### [GET] /workflows/run/{workflow_run_id} **Get Workflow Run Detail** @@ -2297,15 +2297,15 @@ Execute a specific workflow version identified by its ID. Useful for running a p #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `WorkflowBlockingResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkWorkflowEvent` objects. | **application/json**: [GeneratedAppResponse](#generatedappresponse)
**text/event-stream**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | - `not_workflow_app` : App mode does not match the API route. - `bad_request` : Workflow is a draft or has an invalid ID format. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Workflow execution request failed. - `invalid_param` : Required parameter missing or invalid. | | -| 401 | Unauthorized - invalid API token | | -| 403 | Forbidden - token scope, app, dataset, or workspace access denied | | -| 404 | `not_found` : Workflow not found. | | -| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | | -| 500 | `internal_server_error` : Internal server error. | | +| Code | Description | +| ---- | ----------- | +| 200 | Successful response. The content type and structure depend on the `response_mode` parameter in the request. - If `response_mode` is `blocking`, returns `application/json` with a `WorkflowBlockingResponse` object. - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkWorkflowEvent` objects. | +| 400 | - `not_workflow_app` : App mode does not match the API route. - `bad_request` : Workflow is a draft or has an invalid ID format. - `provider_not_initialize` : No valid model provider credentials found. - `provider_quota_exceeded` : Model provider quota exhausted. - `model_currently_not_support` : Current model unavailable. - `completion_request_error` : Workflow execution request failed. - `invalid_param` : Required parameter missing or invalid. | +| 401 | Unauthorized - invalid API token | +| 403 | Forbidden - token scope, app, dataset, or workspace access denied | +| 404 | `not_found` : Workflow not found. | +| 429 | - `too_many_requests` : Too many concurrent requests for this app. - `rate_limit_error` : The upstream model provider rate limit was exceeded. | +| 500 | `internal_server_error` : Internal server error. | --- ## default @@ -2960,7 +2960,7 @@ Enum class for custom configuration status. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| credentials | [ [DatasourceCredentialInfoResponse](#datasourcecredentialinforesponse) ] | | Yes | +| credentials | [ [DatasourceCredentialInfoResponse](#datasourcecredentialinforesponse) ] | | No | | datasource_type | string | | No | | node_id | string | | No | | plugin_id | string | | No | @@ -3264,12 +3264,6 @@ Enum class for fetch from. | ---- | ---- | ----------- | -------- | | FormInputConfig | [ParagraphInputConfig](#paragraphinputconfig)
[SelectInputConfig](#selectinputconfig)
[FileInputConfig](#fileinputconfig)
[FileListInputConfig](#filelistinputconfig) | | | -#### GeneratedAppResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| GeneratedAppResponse | | | | - #### HitTestingChildChunk | Name | Type | Description | Required | @@ -3454,7 +3448,7 @@ Model class for i18n object. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| JSONValue | string
integer
number
boolean
object
[ object ] | | | +| JSONValue | | | | #### JSONValueType @@ -3937,7 +3931,7 @@ Model class for provider with models response. | output_variable_name | string | | Yes | | type | string | | No | -#### SimpleAccount +#### SimpleAccountResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -4147,7 +4141,7 @@ in form definiton, or a variable while the workflow is running. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | created_from | string | | No | diff --git a/api/openapi/markdown/web-openapi.md b/api/openapi/markdown/web-openapi.md index 0f368895ab6..cb82ea429cd 100644 --- a/api/openapi/markdown/web-openapi.md +++ b/api/openapi/markdown/web-openapi.md @@ -40,14 +40,14 @@ Create a chat message for conversational applications. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | Bad Request | | -| 401 | Unauthorized | | -| 403 | Forbidden | | -| 404 | App Not Found | | -| 500 | Internal Server Error | | +| Code | Description | +| ---- | ----------- | +| 200 | Success | +| 400 | Bad Request | +| 401 | Unauthorized | +| 403 | Forbidden | +| 404 | App Not Found | +| 500 | Internal Server Error | ### [POST] /chat-messages/{task_id}/stop Stop a running chat message task. @@ -80,14 +80,14 @@ Create a completion message for text generation applications. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | Bad Request | | -| 401 | Unauthorized | | -| 403 | Forbidden | | -| 404 | App Not Found | | -| 500 | Internal Server Error | | +| Code | Description | +| ---- | ----------- | +| 200 | Success | +| 400 | Bad Request | +| 401 | Unauthorized | +| 403 | Forbidden | +| 404 | App Not Found | +| 500 | Internal Server Error | ### [POST] /completion-messages/{task_id}/stop Stop a running completion message task. @@ -526,14 +526,14 @@ Generate a new completion similar to an existing message (completion apps only). #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | Bad Request - Not a completion app or feature disabled | | -| 401 | Unauthorized | | -| 403 | Forbidden | | -| 404 | Message Not Found | | -| 500 | Internal Server Error | | +| Code | Description | +| ---- | ----------- | +| 200 | Success | +| 400 | Bad Request - Not a completion app or feature disabled | +| 401 | Unauthorized | +| 403 | Forbidden | +| 404 | Message Not Found | +| 500 | Internal Server Error | ### [GET] /messages/{message_id}/suggested-questions Get suggested follow-up questions after a message (chat apps only). @@ -856,14 +856,14 @@ Execute a workflow with provided inputs and files. #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Success | **application/json**: [GeneratedAppResponse](#generatedappresponse)
| -| 400 | Bad Request | | -| 401 | Unauthorized | | -| 403 | Forbidden | | -| 404 | App Not Found | | -| 500 | Internal Server Error | | +| Code | Description | +| ---- | ----------- | +| 200 | Success | +| 400 | Bad Request | +| 401 | Unauthorized | +| 403 | Forbidden | +| 404 | App Not Found | +| 500 | Internal Server Error | ### [POST] /workflows/tasks/{task_id}/stop **Stop workflow task** @@ -1216,12 +1216,6 @@ Button styles for user actions. | ---- | ---- | ----------- | -------- | | FormInputConfig | [ParagraphInputConfig](#paragraphinputconfig)
[SelectInputConfig](#selectinputconfig)
[FileInputConfig](#fileinputconfig)
[FileListInputConfig](#filelistinputconfig) | | | -#### GeneratedAppResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| GeneratedAppResponse | | | | - #### HumanInputContent | Name | Type | Description | Required | @@ -1306,7 +1300,7 @@ Parsed multipart form fields for HITL uploads. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| JSONValue | string
integer
number
boolean
object
[ object ] | | | +| JSONValue | | | | #### JSONValueType diff --git a/api/tests/test_containers_integration_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_workflow.py b/api/tests/test_containers_integration_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_workflow.py index bdec903ef33..4b8186f3017 100644 --- a/api/tests/test_containers_integration_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_workflow.py +++ b/api/tests/test_containers_integration_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_workflow.py @@ -607,7 +607,11 @@ class TestMiscApis: method = unwrap(api.get) service = MagicMock() - service.get_recommended_plugins.return_value = [{"id": "p1"}] + recommended_plugins = { + "installed_recommended_plugins": [{"id": "p1"}], + "uninstalled_recommended_plugins": [{"id": "p2"}], + } + service.get_recommended_plugins.return_value = recommended_plugins user = make_account() tenant_id = "tenant-1" @@ -619,7 +623,7 @@ class TestMiscApis: ), ): result = method(api, tenant_id, user) - assert result == [{"id": "p1"}] + assert result == recommended_plugins service.get_recommended_plugins.assert_called_once_with("all", user, tenant_id) @@ -826,7 +830,7 @@ class TestRagPipelineByIdApi: result = method(api, pipeline, "old-workflow") workflow_service.delete_workflow.assert_called_once() - assert result == (None, 204) + assert result == ("", 204) def test_delete_active_workflow_rejected(self, app: Flask) -> None: api = RagPipelineByIdApi() diff --git a/api/tests/unit_tests/controllers/console/app/test_workflow_human_input_debug_api.py b/api/tests/unit_tests/controllers/console/app/test_workflow_human_input_debug_api.py index f04ab6d6e7c..9c47f8e5a31 100644 --- a/api/tests/unit_tests/controllers/console/app/test_workflow_human_input_debug_api.py +++ b/api/tests/unit_tests/controllers/console/app/test_workflow_human_input_debug_api.py @@ -77,9 +77,11 @@ def test_human_input_preview_delegates_to_service( preview_payload = { "form_id": "node-42", + "node_id": "node-42", + "node_title": "Human Input", "form_content": "
example
", "inputs": [{"name": "topic"}], - "actions": [{"id": "continue"}], + "actions": [{"id": "continue", "title": "Continue"}], } service_instance = MagicMock() service_instance.get_human_input_form_preview.return_value = preview_payload @@ -88,7 +90,15 @@ def test_human_input_preview_delegates_to_service( with app.test_request_context(case.path, method="POST", json={"inputs": {"topic": "tech"}}): response = case.resource_cls().post(app_id=app_model.id, node_id="node-42") - assert response == preview_payload + assert response == { + **preview_payload, + "TYPE": "human_input_required", + "actions": [{"id": "continue", "title": "Continue", "button_style": "default"}], + "resolved_default_values": {}, + "display_in_ui": False, + "form_token": None, + "expiration_time": None, + } service_instance.get_human_input_form_preview.assert_called_once_with( app_model=app_model, account=account, diff --git a/api/tests/unit_tests/controllers/console/explore/test_trial.py b/api/tests/unit_tests/controllers/console/explore/test_trial.py index be68a3beed6..2ac9fc978d8 100644 --- a/api/tests/unit_tests/controllers/console/explore/test_trial.py +++ b/api/tests/unit_tests/controllers/console/explore/test_trial.py @@ -1,4 +1,4 @@ -from inspect import unwrap as inspect_unwrap +from inspect import unwrap from io import BytesIO from typing import Any from unittest.mock import MagicMock, patch @@ -35,24 +35,16 @@ from models.model import AppMode from services.errors.conversation import ConversationNotExistsError from services.errors.llm import InvokeRateLimitError -unwrap: Any = inspect_unwrap - @pytest.fixture -def account() -> Account: - acc = Account(name="User", email="user@example.com") +def account(): + acc = MagicMock(spec=Account) acc.id = "u1" return acc -def _file_data() -> Any: - file_data: Any = BytesIO(b"fake audio data") - file_data.filename = "test.wav" - return file_data - - @pytest.fixture -def trial_app_chat() -> MagicMock: +def trial_app_chat(): app = MagicMock() app.id = "a-chat" app.mode = AppMode.CHAT @@ -60,7 +52,7 @@ def trial_app_chat() -> MagicMock: @pytest.fixture -def trial_app_completion() -> MagicMock: +def trial_app_completion(): app = MagicMock() app.id = "a-comp" app.mode = AppMode.COMPLETION @@ -68,7 +60,7 @@ def trial_app_completion() -> MagicMock: @pytest.fixture -def trial_app_workflow() -> MagicMock: +def trial_app_workflow(): app = MagicMock() app.id = "a-workflow" app.mode = AppMode.WORKFLOW @@ -76,7 +68,7 @@ def trial_app_workflow() -> MagicMock: @pytest.fixture -def valid_parameters() -> dict[str, object]: +def valid_parameters(): return { "user_input_form": [], "system_parameters": {}, @@ -92,13 +84,54 @@ def valid_parameters() -> dict[str, object]: } -def test_trial_workflow_uses_trial_scoped_simple_account_model() -> None: - assert module.simple_account_model.name == "TrialSimpleAccount" - assert hasattr(module.simple_account_model, "items") +def test_trial_workflow_registers_normalized_simple_account_response_model(): + assert "SimpleAccountResponse" in module.console_ns.models + + +def _response_model_name(entry: object) -> str: + assert isinstance(entry, tuple) + assert len(entry) >= 2 + model = entry[1] + name = getattr(model, "name", None) + assert isinstance(name, str) + return name + + +def test_trial_endpoints_keep_response_and_query_docs(): + untyped_generated_response_views = [ + module.TrialAppWorkflowRunApi.post, + module.TrialChatApi.post, + module.TrialCompletionApi.post, + ] + for view in untyped_generated_response_views: + apidoc = getattr(view, "__apidoc__", {}) + assert apidoc.get("responses", {})["200"] == ("Success", None, {}) + + cases = [ + (module.TrialMessageSuggestedQuestionApi.get, module.SuggestedQuestionsResponse.__name__), + (module.TrialChatAudioApi.post, module.AudioTranscriptResponse.__name__), + (module.TrialChatTextApi.post, module.AudioBinaryResponse.__name__), + (module.TrialSitApi.get, module.SiteResponse.__name__), + (module.TrialAppParameterApi.get, module.ParametersResponse.__name__), + (module.AppApi.get, module.AppDetailWithSite.__name__), + (module.AppWorkflowApi.get, module.WorkflowResponse.__name__), + (module.DatasetListApi.get, module.TrialDatasetListResponse.__name__), + ] + + for view, model_name in cases: + apidoc = getattr(view, "__apidoc__", {}) + responses = apidoc.get("responses", {}) + assert _response_model_name(responses["200"]) == model_name + + dataset_params = module.DatasetListApi.get.__apidoc__["params"] + assert dataset_params["ids"]["in"] == "query" + assert dataset_params["ids"]["type"] == "array" + assert dataset_params["page"]["default"] == 1 + assert dataset_params["limit"]["default"] == 20 class TestTrialAppWorkflowRunApi: - def test_not_workflow_app(self, app: Flask, account: Account) -> None: + def test_not_workflow_app(self, app: Flask, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -106,7 +139,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(NotWorkflowAppError): method(api, account, MagicMock(mode=AppMode.CHAT)) - def test_success(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_success(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -119,7 +152,7 @@ class TestTrialAppWorkflowRunApi: assert result is not None - def test_workflow_provider_not_init(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_provider_not_init(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -134,7 +167,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(ProviderNotInitializeError): method(api, account, trial_app_workflow) - def test_workflow_quota_exceeded(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_quota_exceeded(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -149,7 +182,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(ProviderQuotaExceededError): method(api, account, trial_app_workflow) - def test_workflow_model_not_support(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_model_not_support(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -164,7 +197,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(ProviderModelCurrentlyNotSupportError): method(api, account, trial_app_workflow) - def test_workflow_invoke_error(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_invoke_error(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -179,7 +212,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(CompletionRequestError): method(api, account, trial_app_workflow) - def test_workflow_rate_limit_error(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_rate_limit_error(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -194,7 +227,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(InvokeRateLimitHttpError): method(api, account, trial_app_workflow) - def test_workflow_value_error(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_value_error(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -209,7 +242,7 @@ class TestTrialAppWorkflowRunApi: with pytest.raises(ValueError): method(api, account, trial_app_workflow) - def test_workflow_generic_exception(self, app: Flask, trial_app_workflow: MagicMock, account: Account) -> None: + def test_workflow_generic_exception(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowRunApi() method = unwrap(api.post) @@ -226,7 +259,7 @@ class TestTrialAppWorkflowRunApi: class TestTrialChatApi: - def test_not_chat_app(self, app: Flask, account: Account) -> None: + def test_not_chat_app(self, app: Flask, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -234,7 +267,7 @@ class TestTrialChatApi: with pytest.raises(NotChatAppError): method(api, account, MagicMock(mode="completion")) - def test_success(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_success(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -247,7 +280,7 @@ class TestTrialChatApi: assert result is not None - def test_chat_conversation_not_exists(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_conversation_not_exists(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -262,7 +295,7 @@ class TestTrialChatApi: with pytest.raises(NotFound): method(api, account, trial_app_chat) - def test_chat_conversation_completed(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_conversation_completed(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -277,7 +310,7 @@ class TestTrialChatApi: with pytest.raises(ConversationCompletedError): method(api, account, trial_app_chat) - def test_chat_app_config_broken(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_app_config_broken(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -292,7 +325,7 @@ class TestTrialChatApi: with pytest.raises(AppUnavailableError): method(api, account, trial_app_chat) - def test_chat_provider_not_init(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_provider_not_init(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -307,7 +340,7 @@ class TestTrialChatApi: with pytest.raises(ProviderNotInitializeError): method(api, account, trial_app_chat) - def test_chat_quota_exceeded(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_quota_exceeded(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -322,7 +355,7 @@ class TestTrialChatApi: with pytest.raises(ProviderQuotaExceededError): method(api, account, trial_app_chat) - def test_chat_model_not_support(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_model_not_support(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -337,7 +370,7 @@ class TestTrialChatApi: with pytest.raises(ProviderModelCurrentlyNotSupportError): method(api, account, trial_app_chat) - def test_chat_invoke_error(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_invoke_error(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -352,7 +385,7 @@ class TestTrialChatApi: with pytest.raises(CompletionRequestError): method(api, account, trial_app_chat) - def test_chat_rate_limit_error(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_rate_limit_error(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -367,7 +400,7 @@ class TestTrialChatApi: with pytest.raises(InvokeRateLimitHttpError): method(api, account, trial_app_chat) - def test_chat_value_error(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_value_error(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -382,7 +415,7 @@ class TestTrialChatApi: with pytest.raises(ValueError): method(api, account, trial_app_chat) - def test_chat_generic_exception(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_chat_generic_exception(self, app: Flask, trial_app_chat, account): api = module.TrialChatApi() method = unwrap(api.post) @@ -399,7 +432,7 @@ class TestTrialChatApi: class TestTrialCompletionApi: - def test_not_completion_app(self, app: Flask, account: Account) -> None: + def test_not_completion_app(self, app: Flask, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -407,7 +440,7 @@ class TestTrialCompletionApi: with pytest.raises(NotCompletionAppError): method(api, account, MagicMock(mode=AppMode.CHAT)) - def test_success(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_success(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -420,7 +453,7 @@ class TestTrialCompletionApi: assert result is not None - def test_completion_app_config_broken(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_app_config_broken(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -435,7 +468,7 @@ class TestTrialCompletionApi: with pytest.raises(AppUnavailableError): method(api, account, trial_app_completion) - def test_completion_provider_not_init(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_provider_not_init(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -450,7 +483,7 @@ class TestTrialCompletionApi: with pytest.raises(ProviderNotInitializeError): method(api, account, trial_app_completion) - def test_completion_quota_exceeded(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_quota_exceeded(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -465,7 +498,7 @@ class TestTrialCompletionApi: with pytest.raises(ProviderQuotaExceededError): method(api, account, trial_app_completion) - def test_completion_model_not_support(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_model_not_support(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -480,7 +513,7 @@ class TestTrialCompletionApi: with pytest.raises(ProviderModelCurrentlyNotSupportError): method(api, account, trial_app_completion) - def test_completion_invoke_error(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_invoke_error(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -495,7 +528,7 @@ class TestTrialCompletionApi: with pytest.raises(CompletionRequestError): method(api, account, trial_app_completion) - def test_completion_rate_limit_error(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_rate_limit_error(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -510,7 +543,7 @@ class TestTrialCompletionApi: with pytest.raises(InternalServerError): method(api, account, trial_app_completion) - def test_completion_value_error(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_value_error(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -525,7 +558,7 @@ class TestTrialCompletionApi: with pytest.raises(ValueError): method(api, account, trial_app_completion) - def test_completion_generic_exception(self, app: Flask, trial_app_completion: MagicMock, account: Account) -> None: + def test_completion_generic_exception(self, app: Flask, trial_app_completion, account): api = module.TrialCompletionApi() method = unwrap(api.post) @@ -542,7 +575,7 @@ class TestTrialCompletionApi: class TestTrialMessageSuggestedQuestionApi: - def test_not_chat_app(self, app: Flask, account: Account) -> None: + def test_not_chat_app(self, app: Flask, account): api = module.TrialMessageSuggestedQuestionApi() method = unwrap(api.get) @@ -550,7 +583,7 @@ class TestTrialMessageSuggestedQuestionApi: with pytest.raises(NotChatAppError): method(api, account, MagicMock(mode="completion"), str(uuid4())) - def test_success(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_success(self, app: Flask, trial_app_chat, account): api = module.TrialMessageSuggestedQuestionApi() method = unwrap(api.get) @@ -566,7 +599,7 @@ class TestTrialMessageSuggestedQuestionApi: assert result == {"data": ["q1", "q2"]} - def test_conversation_not_exists(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_conversation_not_exists(self, app: Flask, trial_app_chat, account): api = module.TrialMessageSuggestedQuestionApi() method = unwrap(api.get) @@ -583,14 +616,14 @@ class TestTrialMessageSuggestedQuestionApi: class TestTrialAppParameterApi: - def test_app_unavailable(self) -> None: + def test_app_unavailable(self): api = module.TrialAppParameterApi() method = unwrap(api.get) with pytest.raises(AppUnavailableError): method(api, None) - def test_success_non_workflow(self, valid_parameters: dict[str, object]) -> None: + def test_success_non_workflow(self, valid_parameters): api = module.TrialAppParameterApi() method = unwrap(api.get) @@ -617,11 +650,12 @@ class TestTrialAppParameterApi: class TestTrialChatAudioApi: - def test_success(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_success(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -634,11 +668,12 @@ class TestTrialChatAudioApi: assert result == {"text": "hello"} - def test_app_config_broken(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_app_config_broken(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -653,11 +688,12 @@ class TestTrialChatAudioApi: with pytest.raises(module.AppUnavailableError): method(api, account, trial_app_chat) - def test_no_audio_uploaded(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_no_audio_uploaded(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -672,11 +708,12 @@ class TestTrialChatAudioApi: with pytest.raises(module.NoAudioUploadedError): method(api, account, trial_app_chat) - def test_audio_too_large(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_audio_too_large(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -691,11 +728,12 @@ class TestTrialChatAudioApi: with pytest.raises(module.AudioTooLargeError): method(api, account, trial_app_chat) - def test_unsupported_audio_type(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_unsupported_audio_type(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -710,11 +748,12 @@ class TestTrialChatAudioApi: with pytest.raises(module.UnsupportedAudioTypeError): method(api, account, trial_app_chat) - def test_provider_not_support_tts(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_provider_not_support_tts(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -729,11 +768,12 @@ class TestTrialChatAudioApi: with pytest.raises(module.ProviderNotSupportSpeechToTextError): method(api, account, trial_app_chat) - def test_provider_not_init(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_provider_not_init(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -744,11 +784,12 @@ class TestTrialChatAudioApi: with pytest.raises(ProviderNotInitializeError): method(api, account, trial_app_chat) - def test_quota_exceeded(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_quota_exceeded(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -761,7 +802,7 @@ class TestTrialChatAudioApi: class TestTrialChatTextApi: - def test_success(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_success(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -774,7 +815,7 @@ class TestTrialChatTextApi: assert result == {"audio": "base64_data"} - def test_app_config_broken(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_app_config_broken(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -789,7 +830,7 @@ class TestTrialChatTextApi: with pytest.raises(module.AppUnavailableError): method(api, account, trial_app_chat) - def test_provider_not_support(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_provider_not_support(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -804,7 +845,7 @@ class TestTrialChatTextApi: with pytest.raises(module.ProviderNotSupportSpeechToTextError): method(api, account, trial_app_chat) - def test_audio_too_large(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_audio_too_large(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -819,7 +860,7 @@ class TestTrialChatTextApi: with pytest.raises(module.AudioTooLargeError): method(api, account, trial_app_chat) - def test_no_audio_uploaded(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_no_audio_uploaded(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -834,7 +875,7 @@ class TestTrialChatTextApi: with pytest.raises(module.NoAudioUploadedError): method(api, account, trial_app_chat) - def test_provider_not_init(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_provider_not_init(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -845,7 +886,7 @@ class TestTrialChatTextApi: with pytest.raises(ProviderNotInitializeError): method(api, account, trial_app_chat) - def test_quota_exceeded(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_quota_exceeded(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -856,7 +897,7 @@ class TestTrialChatTextApi: with pytest.raises(ProviderQuotaExceededError): method(api, account, trial_app_chat) - def test_model_not_support(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_model_not_support(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -867,7 +908,7 @@ class TestTrialChatTextApi: with pytest.raises(ProviderModelCurrentlyNotSupportError): method(api, account, trial_app_chat) - def test_invoke_error(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_invoke_error(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -880,7 +921,7 @@ class TestTrialChatTextApi: class TestTrialAppWorkflowTaskStopApi: - def test_not_workflow_app(self, app: Flask, trial_app_chat: MagicMock) -> None: + def test_not_workflow_app(self, app: Flask, trial_app_chat): api = module.TrialAppWorkflowTaskStopApi() method = unwrap(api.post) @@ -888,7 +929,7 @@ class TestTrialAppWorkflowTaskStopApi: with pytest.raises(NotWorkflowAppError): method(api, trial_app_chat, str(uuid4())) - def test_success(self, app: Flask, trial_app_workflow: MagicMock) -> None: + def test_success(self, app: Flask, trial_app_workflow, account): api = module.TrialAppWorkflowTaskStopApi() method = unwrap(api.post) @@ -906,7 +947,7 @@ class TestTrialAppWorkflowTaskStopApi: class TestTrialSitApi: - def test_no_site(self, app: Flask) -> None: + def test_no_site(self, app: Flask): api = module.TrialSitApi() method = unwrap(api.get) app_model = MagicMock() @@ -917,7 +958,7 @@ class TestTrialSitApi: with pytest.raises(Forbidden): method(api, app_model) - def test_archived_tenant(self, app: Flask) -> None: + def test_archived_tenant(self, app: Flask): api = module.TrialSitApi() method = unwrap(api.get) @@ -932,7 +973,7 @@ class TestTrialSitApi: with pytest.raises(Forbidden): method(api, app_model) - def test_success(self, app: Flask) -> None: + def test_success(self, app: Flask): api = module.TrialSitApi() method = unwrap(api.get) @@ -957,11 +998,12 @@ class TestTrialSitApi: class TestTrialChatAudioApiExceptionHandlers: - def test_provider_not_init(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_provider_not_init(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -976,11 +1018,12 @@ class TestTrialChatAudioApiExceptionHandlers: with pytest.raises(ProviderNotInitializeError): method(api, account, trial_app_chat) - def test_quota_exceeded(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_quota_exceeded(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -995,11 +1038,12 @@ class TestTrialChatAudioApiExceptionHandlers: with pytest.raises(ProviderQuotaExceededError): method(api, account, trial_app_chat) - def test_invoke_error(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_invoke_error(self, app: Flask, trial_app_chat, account): api = module.TrialChatAudioApi() method = unwrap(api.post) - file_data = _file_data() + file_data: Any = BytesIO(b"fake audio data") + file_data.filename = "test.wav" with ( app.test_request_context( @@ -1016,7 +1060,7 @@ class TestTrialChatAudioApiExceptionHandlers: class TestTrialChatTextApiExceptionHandlers: - def test_app_config_broken(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_app_config_broken(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) @@ -1031,7 +1075,7 @@ class TestTrialChatTextApiExceptionHandlers: with pytest.raises(module.AppUnavailableError): method(api, account, trial_app_chat) - def test_unsupported_audio_type(self, app: Flask, trial_app_chat: MagicMock, account: Account) -> None: + def test_unsupported_audio_type(self, app: Flask, trial_app_chat, account): api = module.TrialChatTextApi() method = unwrap(api.post) diff --git a/api/tests/unit_tests/controllers/service_api/app/test_workflow_fields.py b/api/tests/unit_tests/controllers/service_api/app/test_workflow_fields.py index eda270258d5..caa6ddc0d93 100644 --- a/api/tests/unit_tests/controllers/service_api/app/test_workflow_fields.py +++ b/api/tests/unit_tests/controllers/service_api/app/test_workflow_fields.py @@ -1,25 +1,36 @@ -from types import SimpleNamespace - -from controllers.service_api.app.workflow import WorkflowRunOutputsField, WorkflowRunStatusField +from controllers.service_api.app.workflow import WorkflowRunResponse from graphon.enums import WorkflowExecutionStatus +from libs.helper import dump_response +from models.workflow import WorkflowRun -def test_workflow_run_status_field_with_enum() -> None: - field = WorkflowRunStatusField() - obj = SimpleNamespace(status=WorkflowExecutionStatus.PAUSED) - - assert field.output("status", obj) == "paused" +def _workflow_run(status: WorkflowExecutionStatus, outputs: str | None = '{"foo": "bar"}') -> WorkflowRun: + return WorkflowRun( + id="run-id", + workflow_id="workflow-id", + status=status, + inputs="{}", + outputs=outputs, + error=None, + total_steps=1, + total_tokens=2, + elapsed_time=3.5, + ) -def test_workflow_run_outputs_field_paused_returns_empty() -> None: - field = WorkflowRunOutputsField() - obj = SimpleNamespace(status=WorkflowExecutionStatus.PAUSED, outputs_dict={"foo": "bar"}) +def test_workflow_run_serializer_normalizes_status_enum() -> None: + response = dump_response(WorkflowRunResponse, _workflow_run(WorkflowExecutionStatus.PAUSED)) - assert field.output("outputs", obj) == {} + assert response["status"] == "paused" -def test_workflow_run_outputs_field_running_returns_outputs() -> None: - field = WorkflowRunOutputsField() - obj = SimpleNamespace(status=WorkflowExecutionStatus.RUNNING, outputs_dict={"foo": "bar"}) +def test_workflow_run_serializer_paused_returns_empty_outputs() -> None: + response = dump_response(WorkflowRunResponse, _workflow_run(WorkflowExecutionStatus.PAUSED)) - assert field.output("outputs", obj) == {"foo": "bar"} + assert response["outputs"] == {} + + +def test_workflow_run_serializer_running_returns_outputs() -> None: + response = dump_response(WorkflowRunResponse, _workflow_run(WorkflowExecutionStatus.RUNNING)) + + assert response["outputs"] == {"foo": "bar"} diff --git a/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py b/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py index 362af883ed2..43cc2450db5 100644 --- a/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py +++ b/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py @@ -325,10 +325,12 @@ class TestPipelineRunApiEntity: def test_entity_missing_required_field(self): """Test entity raises on missing required field.""" with pytest.raises(ValueError): - PipelineRunApiEntity( - inputs={}, - datasource_type="online_document", - # missing datasource_info_list, start_node_id, etc. + PipelineRunApiEntity.model_validate( + { + "inputs": {}, + "datasource_type": "online_document", + # missing datasource_info_list, start_node_id, etc. + } ) @@ -382,8 +384,19 @@ class TestDatasourcePluginsApiGet: mock_dataset = Mock() mock_db.session.scalar.return_value = mock_dataset + datasource_plugins = [ + { + "node_id": "node-datasource-1", + "plugin_id": "plugin-a", + "provider_name": "provider-a", + "datasource_type": "online_document", + "title": "Online Docs", + "user_input_variables": [{"variable": "url", "label": "URL", "type": "text-input", "required": True}], + "credentials": [{"id": "cred-1", "name": "Default credential", "type": "oauth2", "is_default": True}], + } + ] mock_svc_instance = Mock() - mock_svc_instance.get_datasource_plugins.return_value = [{"name": "plugin_a"}] + mock_svc_instance.get_datasource_plugins.return_value = datasource_plugins mock_svc_cls.return_value = mock_svc_instance with app.test_request_context("/datasets/test/pipeline/datasource-plugins?is_published=true"): @@ -391,11 +404,33 @@ class TestDatasourcePluginsApiGet: response, status = api.get(tenant_id=tenant_id, dataset_id=dataset_id) assert status == 200 - assert response == [{"name": "plugin_a"}] + assert response == datasource_plugins mock_svc_instance.get_datasource_plugins.assert_called_once_with( tenant_id=tenant_id, dataset_id=dataset_id, is_published=True ) + @patch("controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.db") + @patch("controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.RagPipelineService") + def test_get_plugins_parses_false_is_published_query(self, mock_svc_cls, mock_db, app: Flask): + """Test false query string is parsed as boolean False.""" + tenant_id = str(uuid.uuid4()) + dataset_id = str(uuid.uuid4()) + + mock_db.session.scalar.return_value = Mock() + mock_svc_instance = Mock() + mock_svc_instance.get_datasource_plugins.return_value = [] + mock_svc_cls.return_value = mock_svc_instance + + with app.test_request_context("/datasets/test/pipeline/datasource-plugins?is_published=false"): + api = DatasourcePluginsApi() + response, status = api.get(tenant_id=tenant_id, dataset_id=dataset_id) + + assert status == 200 + assert response == [] + mock_svc_instance.get_datasource_plugins.assert_called_once_with( + tenant_id=tenant_id, dataset_id=dataset_id, is_published=False + ) + @patch("controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.db") def test_get_plugins_not_found(self, mock_db, app: Flask): """Test NotFound when dataset check fails.""" diff --git a/packages/contracts/generated/api/console/account/types.gen.ts b/packages/contracts/generated/api/console/account/types.gen.ts index cdd45925fb2..1a7d1644f8f 100644 --- a/packages/contracts/generated/api/console/account/types.gen.ts +++ b/packages/contracts/generated/api/console/account/types.gen.ts @@ -12,7 +12,7 @@ export type AccountAvatarPayload = { avatar: string } -export type Account = { +export type AccountResponse = { avatar?: string | null readonly avatar_url: string | null created_at?: number | null @@ -140,7 +140,7 @@ export type AccountIntegrateResponse = { provider: string } -export type AccountWritable = { +export type AccountResponseWritable = { avatar?: string | null created_at?: number | null email: string @@ -177,7 +177,7 @@ export type PostAccountAvatarData = { } export type PostAccountAvatarResponses = { - 200: Account + 200: AccountResponse } export type PostAccountAvatarResponse = PostAccountAvatarResponses[keyof PostAccountAvatarResponses] @@ -218,7 +218,7 @@ export type PostAccountChangeEmailResetData = { } export type PostAccountChangeEmailResetResponses = { - 200: Account + 200: AccountResponse } export type PostAccountChangeEmailResetResponse @@ -374,7 +374,7 @@ export type PostAccountInterfaceLanguageData = { } export type PostAccountInterfaceLanguageResponses = { - 200: Account + 200: AccountResponse } export type PostAccountInterfaceLanguageResponse @@ -388,7 +388,7 @@ export type PostAccountInterfaceThemeData = { } export type PostAccountInterfaceThemeResponses = { - 200: Account + 200: AccountResponse } export type PostAccountInterfaceThemeResponse @@ -402,7 +402,7 @@ export type PostAccountNameData = { } export type PostAccountNameResponses = { - 200: Account + 200: AccountResponse } export type PostAccountNameResponse = PostAccountNameResponses[keyof PostAccountNameResponses] @@ -415,7 +415,7 @@ export type PostAccountPasswordData = { } export type PostAccountPasswordResponses = { - 200: Account + 200: AccountResponse } export type PostAccountPasswordResponse @@ -429,7 +429,7 @@ export type GetAccountProfileData = { } export type GetAccountProfileResponses = { - 200: Account + 200: AccountResponse } export type GetAccountProfileResponse = GetAccountProfileResponses[keyof GetAccountProfileResponses] @@ -442,7 +442,7 @@ export type PostAccountTimezoneData = { } export type PostAccountTimezoneResponses = { - 200: Account + 200: AccountResponse } export type PostAccountTimezoneResponse diff --git a/packages/contracts/generated/api/console/account/zod.gen.ts b/packages/contracts/generated/api/console/account/zod.gen.ts index 9951efc8d9f..cba539b0316 100644 --- a/packages/contracts/generated/api/console/account/zod.gen.ts +++ b/packages/contracts/generated/api/console/account/zod.gen.ts @@ -17,9 +17,9 @@ export const zAccountAvatarPayload = z.object({ }) /** - * Account + * AccountResponse */ -export const zAccount = z.object({ +export const zAccountResponse = z.object({ avatar: z.string().nullish(), avatar_url: z.string().nullable(), created_at: z.int().nullish(), @@ -212,9 +212,9 @@ export const zAccountIntegrateListResponse = z.object({ }) /** - * Account + * AccountResponse */ -export const zAccountWritable = z.object({ +export const zAccountResponseWritable = z.object({ avatar: z.string().nullish(), created_at: z.int().nullish(), email: z.string(), @@ -242,7 +242,7 @@ export const zPostAccountAvatarBody = zAccountAvatarPayload /** * Success */ -export const zPostAccountAvatarResponse = zAccount +export const zPostAccountAvatarResponse = zAccountResponse export const zPostAccountChangeEmailBody = zChangeEmailSendPayload @@ -263,7 +263,7 @@ export const zPostAccountChangeEmailResetBody = zChangeEmailResetPayload /** * Success */ -export const zPostAccountChangeEmailResetResponse = zAccount +export const zPostAccountChangeEmailResetResponse = zAccountResponse export const zPostAccountChangeEmailValidityBody = zChangeEmailValidityPayload @@ -336,37 +336,37 @@ export const zPostAccountInterfaceLanguageBody = zAccountInterfaceLanguagePayloa /** * Success */ -export const zPostAccountInterfaceLanguageResponse = zAccount +export const zPostAccountInterfaceLanguageResponse = zAccountResponse export const zPostAccountInterfaceThemeBody = zAccountInterfaceThemePayload /** * Success */ -export const zPostAccountInterfaceThemeResponse = zAccount +export const zPostAccountInterfaceThemeResponse = zAccountResponse export const zPostAccountNameBody = zAccountNamePayload /** * Success */ -export const zPostAccountNameResponse = zAccount +export const zPostAccountNameResponse = zAccountResponse export const zPostAccountPasswordBody = zAccountPasswordPayload /** * Success */ -export const zPostAccountPasswordResponse = zAccount +export const zPostAccountPasswordResponse = zAccountResponse /** * Success */ -export const zGetAccountProfileResponse = zAccount +export const zGetAccountProfileResponse = zAccountResponse export const zPostAccountTimezoneBody = zAccountTimezonePayload /** * Success */ -export const zPostAccountTimezoneResponse = zAccount +export const zPostAccountTimezoneResponse = zAccountResponse diff --git a/packages/contracts/generated/api/console/agent/types.gen.ts b/packages/contracts/generated/api/console/agent/types.gen.ts index 43119c4f1f4..7c8d3d052ad 100644 --- a/packages/contracts/generated/api/console/agent/types.gen.ts +++ b/packages/contracts/generated/api/console/agent/types.gen.ts @@ -269,6 +269,7 @@ export type MessageDetailResponse = { agent_thoughts?: Array annotation?: ConversationAnnotation | null annotation_hit_history?: ConversationAnnotationHitHistory | null + answer: string answer_tokens?: number | null conversation_id: string created_at?: number | null @@ -284,12 +285,11 @@ export type MessageDetailResponse = { } message?: JsonValue | null message_files?: Array - message_metadata_dict?: JsonValue | null message_tokens?: number | null + metadata?: JsonValue | null parent_message_id?: string | null provider_response_latency?: number | null query: string - re_sign_file_url_answer: string status: string workflow_run_id?: string | null } @@ -405,12 +405,30 @@ export type DeletedTool = { } export type ModelConfig = { - completion_params?: { - [key: string]: unknown - } - mode: LlmMode - name: string - provider: string + agent_mode?: JsonValue | null + annotation_reply?: JsonValue | null + chat_prompt_config?: JsonValue | null + completion_prompt_config?: JsonValue | null + created_at?: number | null + created_by?: string | null + dataset_configs?: JsonValue | null + dataset_query_variable?: string | null + external_data_tools?: JsonValue | null + file_upload?: JsonValue | null + model?: JsonValue | null + more_like_this?: JsonValue | null + opening_statement?: string | null + pre_prompt?: string | null + prompt_type?: string | null + retriever_resource?: JsonValue | null + sensitive_word_avoidance?: JsonValue | null + speech_to_text?: JsonValue | null + suggested_questions?: JsonValue | null + suggested_questions_after_answer?: JsonValue | null + text_to_speech?: JsonValue | null + updated_at?: number | null + updated_by?: string | null + user_input_form?: JsonValue | null } export type Site = { @@ -436,16 +454,7 @@ export type Tag = { type: string } -export type JsonValue - = | string - | number - | number - | boolean - | { - [key: string]: unknown - } - | Array - | null +export type JsonValue = unknown export type WorkflowPartial = { created_at?: number | null @@ -723,7 +732,6 @@ export type AgentThought = { created_at?: number | null files: Array id: string - message_chain_id?: string | null message_id: string observation?: string | null position: number @@ -743,8 +751,8 @@ export type ConversationAnnotation = { export type ConversationAnnotationHitHistory = { annotation_create_account?: SimpleAccount | null + annotation_id: string created_at?: number | null - id: string } export type HumanInputContent = { @@ -879,8 +887,6 @@ export type AgentAppPublishedReferenceResponse = { app_name: string } -export type LlmMode = 'chat' | 'completion' - export type AgentKind = 'dify_agent' export type AgentPublishedReferenceResponse = { diff --git a/packages/contracts/generated/api/console/agent/zod.gen.ts b/packages/contracts/generated/api/console/agent/zod.gen.ts index d7f5681ffc4..e0869366919 100644 --- a/packages/contracts/generated/api/console/agent/zod.gen.ts +++ b/packages/contracts/generated/api/console/agent/zod.gen.ts @@ -218,16 +218,37 @@ export const zTag = z.object({ type: z.string(), }) -export const zJsonValue = z - .union([ - z.string(), - z.int(), - z.number(), - z.boolean(), - z.record(z.string(), z.unknown()), - z.array(z.unknown()), - ]) - .nullable() +export const zJsonValue = z.unknown() + +/** + * ModelConfig + */ +export const zModelConfig = z.object({ + agent_mode: zJsonValue.nullish(), + annotation_reply: zJsonValue.nullish(), + chat_prompt_config: zJsonValue.nullish(), + completion_prompt_config: zJsonValue.nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + dataset_configs: zJsonValue.nullish(), + dataset_query_variable: z.string().nullish(), + external_data_tools: zJsonValue.nullish(), + file_upload: zJsonValue.nullish(), + model: zJsonValue.nullish(), + more_like_this: zJsonValue.nullish(), + opening_statement: z.string().nullish(), + pre_prompt: z.string().nullish(), + prompt_type: z.string().nullish(), + retriever_resource: zJsonValue.nullish(), + sensitive_word_avoidance: zJsonValue.nullish(), + speech_to_text: zJsonValue.nullish(), + suggested_questions: zJsonValue.nullish(), + suggested_questions_after_answer: zJsonValue.nullish(), + text_to_speech: zJsonValue.nullish(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + user_input_form: zJsonValue.nullish(), +}) /** * WorkflowPartial @@ -240,6 +261,43 @@ export const zWorkflowPartial = z.object({ updated_by: z.string().nullish(), }) +/** + * AgentAppDetailWithSite + */ +export const zAgentAppDetailWithSite = z.object({ + access_mode: z.string().nullish(), + active_config_is_published: z.boolean().optional().default(false), + api_base_url: z.string().nullish(), + app_id: z.string().nullish(), + bound_agent_id: z.string().nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + debug_conversation_id: z.string().nullish(), + deleted_tools: z.array(zDeletedTool).optional(), + description: z.string().nullish(), + enable_api: z.boolean(), + enable_site: z.boolean(), + icon: z.string().nullish(), + icon_background: z.string().nullish(), + icon_type: z.string().nullish(), + icon_url: z.string().nullable(), + id: z.string(), + maintainer: z.string().nullish(), + max_active_requests: z.int().nullish(), + mode: z.string(), + model_config: zModelConfig.nullish(), + name: z.string(), + permission_keys: z.array(z.string()).optional(), + role: z.string().nullish(), + site: zSite.nullish(), + tags: z.array(zTag).optional(), + tracing: zJsonValue.nullish(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + use_icon_as_answer_icon: z.boolean().nullish(), + workflow: zWorkflowPartial.nullish(), +}) + /** * AgentConfigSnapshotSummaryResponse */ @@ -570,7 +628,6 @@ export const zAgentThought = z.object({ created_at: z.int().nullish(), files: z.array(z.string()), id: z.string(), - message_chain_id: z.string().nullish(), message_id: z.string(), observation: z.string().nullish(), position: z.int(), @@ -773,60 +830,6 @@ export const zAgentAppPagination = z.object({ total: z.int(), }) -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) - -/** - * ModelConfig - */ -export const zModelConfig = z.object({ - completion_params: z.record(z.string(), z.unknown()).optional(), - mode: zLlmMode, - name: z.string(), - provider: z.string(), -}) - -/** - * AgentAppDetailWithSite - */ -export const zAgentAppDetailWithSite = z.object({ - access_mode: z.string().nullish(), - active_config_is_published: z.boolean().optional().default(false), - api_base_url: z.string().nullish(), - app_id: z.string().nullish(), - bound_agent_id: z.string().nullish(), - created_at: z.int().nullish(), - created_by: z.string().nullish(), - debug_conversation_id: z.string().nullish(), - deleted_tools: z.array(zDeletedTool).optional(), - description: z.string().nullish(), - enable_api: z.boolean(), - enable_site: z.boolean(), - icon: z.string().nullish(), - icon_background: z.string().nullish(), - icon_type: z.string().nullish(), - icon_url: z.string().nullable(), - id: z.string(), - maintainer: z.string().nullish(), - max_active_requests: z.int().nullish(), - mode: z.string(), - model_config: zModelConfig.nullish(), - name: z.string(), - permission_keys: z.array(z.string()).optional(), - role: z.string().nullish(), - site: zSite.nullish(), - tags: z.array(zTag).optional(), - tracing: zJsonValue.nullish(), - updated_at: z.int().nullish(), - updated_by: z.string().nullish(), - use_icon_as_answer_icon: z.boolean().nullish(), - workflow: zWorkflowPartial.nullish(), -}) - /** * AgentKind * @@ -1056,8 +1059,8 @@ export const zConversationAnnotation = z.object({ */ export const zConversationAnnotationHitHistory = z.object({ annotation_create_account: zSimpleAccount.nullish(), + annotation_id: z.string(), created_at: z.int().nullish(), - id: z.string(), }) /** @@ -2035,6 +2038,7 @@ export const zMessageDetailResponse = z.object({ agent_thoughts: z.array(zAgentThought).optional(), annotation: zConversationAnnotation.nullish(), annotation_hit_history: zConversationAnnotationHitHistory.nullish(), + answer: z.string(), answer_tokens: z.int().nullish(), conversation_id: z.string(), created_at: z.int().nullish(), @@ -2048,12 +2052,11 @@ export const zMessageDetailResponse = z.object({ inputs: z.record(z.string(), zJsonValue), message: zJsonValue.nullish(), message_files: z.array(zMessageFile).optional(), - message_metadata_dict: zJsonValue.nullish(), message_tokens: z.int().nullish(), + metadata: zJsonValue.nullish(), parent_message_id: z.string().nullish(), provider_response_latency: z.number().nullish(), query: z.string(), - re_sign_file_url_answer: z.string(), status: z.string(), workflow_run_id: z.string().nullish(), }) diff --git a/packages/contracts/generated/api/console/apps/orpc.gen.ts b/packages/contracts/generated/api/console/apps/orpc.gen.ts index ea72df28458..33d2fbcd7c7 100644 --- a/packages/contracts/generated/api/console/apps/orpc.gen.ts +++ b/packages/contracts/generated/api/console/apps/orpc.gen.ts @@ -173,11 +173,6 @@ import { zGetAppsByAppIdWorkflowRunsPath, zGetAppsByAppIdWorkflowRunsQuery, zGetAppsByAppIdWorkflowRunsResponse, - zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypePath, - zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeQuery, - zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse, - zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsPath, - zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponse, zGetAppsByAppIdWorkflowsDraftConversationVariablesPath, zGetAppsByAppIdWorkflowsDraftConversationVariablesResponse, zGetAppsByAppIdWorkflowsDraftEnvironmentVariablesPath, @@ -258,18 +253,6 @@ import { zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewBody, zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewPath, zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse, - zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunBody, - zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunPath, - zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse, - zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunBody, - zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunPath, - zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponse, - zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunBody, - zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunPath, - zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponse, - zPostAppsByAppIdAdvancedChatWorkflowsDraftRunBody, - zPostAppsByAppIdAdvancedChatWorkflowsDraftRunPath, - zPostAppsByAppIdAdvancedChatWorkflowsDraftRunResponse, zPostAppsByAppIdAgentFilesBody, zPostAppsByAppIdAgentFilesPath, zPostAppsByAppIdAgentFilesQuery, @@ -302,11 +285,8 @@ import { zPostAppsByAppIdAudioToTextResponse, zPostAppsByAppIdChatMessagesByTaskIdStopPath, zPostAppsByAppIdChatMessagesByTaskIdStopResponse, - zPostAppsByAppIdCompletionMessagesBody, zPostAppsByAppIdCompletionMessagesByTaskIdStopPath, zPostAppsByAppIdCompletionMessagesByTaskIdStopResponse, - zPostAppsByAppIdCompletionMessagesPath, - zPostAppsByAppIdCompletionMessagesResponse, zPostAppsByAppIdConvertToWorkflowBody, zPostAppsByAppIdConvertToWorkflowPath, zPostAppsByAppIdConvertToWorkflowResponse, @@ -383,15 +363,6 @@ import { zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewBody, zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewPath, zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse, - zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunBody, - zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunPath, - zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse, - zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunBody, - zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunPath, - zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponse, - zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunBody, - zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunPath, - zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponse, zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerCopyFromRosterBody, zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerCopyFromRosterPath, zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerCopyFromRosterResponse, @@ -411,15 +382,6 @@ import { zPostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunResponse, zPostAppsByAppIdWorkflowsDraftPath, zPostAppsByAppIdWorkflowsDraftResponse, - zPostAppsByAppIdWorkflowsDraftRunBody, - zPostAppsByAppIdWorkflowsDraftRunPath, - zPostAppsByAppIdWorkflowsDraftRunResponse, - zPostAppsByAppIdWorkflowsDraftTriggerRunAllBody, - zPostAppsByAppIdWorkflowsDraftTriggerRunAllPath, - zPostAppsByAppIdWorkflowsDraftTriggerRunAllResponse, - zPostAppsByAppIdWorkflowsDraftTriggerRunBody, - zPostAppsByAppIdWorkflowsDraftTriggerRunPath, - zPostAppsByAppIdWorkflowsDraftTriggerRunResponse, zPostAppsByAppIdWorkflowsPublishBody, zPostAppsByAppIdWorkflowsPublishPath, zPostAppsByAppIdWorkflowsPublishResponse, @@ -630,36 +592,8 @@ export const preview = { post: post4, } -/** - * Submit human input form preview - * - * Submit human input form preview for advanced chat workflow - */ -export const post5 = oc - .route({ - description: 'Submit human input form preview for advanced chat workflow', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRun', - path: '/apps/{app_id}/advanced-chat/workflows/draft/human-input/nodes/{node_id}/form/run', - summary: 'Submit human input form preview', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunBody, - params: zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunPath, - }), - ) - .output(zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse) - -export const run = { - post: post5, -} - export const form = { preview, - run, } export const byNodeId = { @@ -674,116 +608,8 @@ export const humanInput = { nodes, } -/** - * Run draft workflow iteration node - * - * Run draft workflow iteration node for advanced chat - */ -export const post6 = oc - .route({ - description: 'Run draft workflow iteration node for advanced chat', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRun', - path: '/apps/{app_id}/advanced-chat/workflows/draft/iteration/nodes/{node_id}/run', - summary: 'Run draft workflow iteration node', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunBody, - params: zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunPath, - }), - ) - .output(zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponse) - -export const run2 = { - post: post6, -} - -export const byNodeId2 = { - run: run2, -} - -export const nodes2 = { - byNodeId: byNodeId2, -} - -export const iteration = { - nodes: nodes2, -} - -/** - * Run draft workflow loop node - * - * Run draft workflow loop node for advanced chat - */ -export const post7 = oc - .route({ - description: 'Run draft workflow loop node for advanced chat', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRun', - path: '/apps/{app_id}/advanced-chat/workflows/draft/loop/nodes/{node_id}/run', - summary: 'Run draft workflow loop node', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunBody, - params: zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunPath, - }), - ) - .output(zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponse) - -export const run3 = { - post: post7, -} - -export const byNodeId3 = { - run: run3, -} - -export const nodes3 = { - byNodeId: byNodeId3, -} - -export const loop = { - nodes: nodes3, -} - -/** - * Run draft workflow - * - * Run draft workflow for advanced chat application - */ -export const post8 = oc - .route({ - description: 'Run draft workflow for advanced chat application', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdAdvancedChatWorkflowsDraftRun', - path: '/apps/{app_id}/advanced-chat/workflows/draft/run', - summary: 'Run draft workflow', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdAdvancedChatWorkflowsDraftRunBody, - params: zPostAppsByAppIdAdvancedChatWorkflowsDraftRunPath, - }), - ) - .output(zPostAppsByAppIdAdvancedChatWorkflowsDraftRunResponse) - -export const run4 = { - post: post8, -} - export const draft = { humanInput, - iteration, - loop, - run: run4, } export const workflows2 = { @@ -953,7 +779,7 @@ export const delete_ = oc * * Commit an uploaded file into the agent drive under files/ (ENG-625 D3) */ -export const post9 = oc +export const post5 = oc .route({ description: 'Commit an uploaded file into the agent drive under files/ (ENG-625 D3)', inputStructure: 'detailed', @@ -975,7 +801,7 @@ export const post9 = oc export const files2 = { delete: delete_, - post: post9, + post: post5, } /** @@ -1005,7 +831,7 @@ export const logs = { * * Upload + standardize a Skill into the agent drive */ -export const post10 = oc +export const post6 = oc .route({ description: 'Upload + standardize a Skill into the agent drive', inputStructure: 'detailed', @@ -1026,7 +852,7 @@ export const post10 = oc .output(zPostAppsByAppIdAgentSkillsUploadResponse) export const upload = { - post: post10, + post: post6, } /** @@ -1035,7 +861,7 @@ export const upload = { * Infer CLI tool + ENV suggestions from a standardized skill's SKILL.md (draft only, ENG-371) * Saving still goes through composer validation. */ -export const post11 = oc +export const post7 = oc .route({ description: 'Infer CLI tool + ENV suggestions from a standardized skill\'s SKILL.md (draft only, ENG-371)\nSaving still goes through composer validation.', @@ -1055,7 +881,7 @@ export const post11 = oc .output(zPostAppsByAppIdAgentSkillsBySlugInferToolsResponse) export const inferTools = { - post: post11, + post: post7, } /** @@ -1121,7 +947,7 @@ export const status = { /** * Enable or disable annotation reply for an app */ -export const post12 = oc +export const post8 = oc .route({ description: 'Enable or disable annotation reply for an app', inputStructure: 'detailed', @@ -1139,7 +965,7 @@ export const post12 = oc .output(zPostAppsByAppIdAnnotationReplyByActionResponse) export const byAction = { - post: post12, + post: post8, status, } @@ -1169,7 +995,7 @@ export const annotationSetting = { /** * Update annotation settings for an app */ -export const post13 = oc +export const post9 = oc .route({ description: 'Update annotation settings for an app', inputStructure: 'detailed', @@ -1187,7 +1013,7 @@ export const post13 = oc .output(zPostAppsByAppIdAnnotationSettingsByAnnotationSettingIdResponse) export const byAnnotationSettingId = { - post: post13, + post: post9, } export const annotationSettings = { @@ -1197,7 +1023,7 @@ export const annotationSettings = { /** * Batch import annotations from CSV file with rate limiting and security checks */ -export const post14 = oc +export const post10 = oc .route({ description: 'Batch import annotations from CSV file with rate limiting and security checks', inputStructure: 'detailed', @@ -1210,7 +1036,7 @@ export const post14 = oc .output(zPostAppsByAppIdAnnotationsBatchImportResponse) export const batchImport = { - post: post14, + post: post10, } /** @@ -1313,7 +1139,7 @@ export const delete3 = oc /** * Update or delete an annotation */ -export const post15 = oc +export const post11 = oc .route({ description: 'Update or delete an annotation', inputStructure: 'detailed', @@ -1332,7 +1158,7 @@ export const post15 = oc export const byAnnotationId = { delete: delete3, - post: post15, + post: post11, hitHistories, } @@ -1371,7 +1197,7 @@ export const get17 = oc /** * Create a new annotation for an app */ -export const post16 = oc +export const post12 = oc .route({ description: 'Create a new annotation for an app', inputStructure: 'detailed', @@ -1389,7 +1215,7 @@ export const post16 = oc export const annotations = { delete: delete4, get: get17, - post: post16, + post: post12, batchImport, batchImportStatus, count: count2, @@ -1400,7 +1226,7 @@ export const annotations = { /** * Enable or disable app API */ -export const post17 = oc +export const post13 = oc .route({ description: 'Enable or disable app API', inputStructure: 'detailed', @@ -1413,13 +1239,13 @@ export const post17 = oc .output(zPostAppsByAppIdApiEnableResponse) export const apiEnable = { - post: post17, + post: post13, } /** * Transcript audio to text for chat messages */ -export const post18 = oc +export const post14 = oc .route({ description: 'Transcript audio to text for chat messages', inputStructure: 'detailed', @@ -1432,7 +1258,7 @@ export const post18 = oc .output(zPostAppsByAppIdAudioToTextResponse) export const audioToText = { - post: post18, + post: post14, } /** @@ -1522,7 +1348,7 @@ export const byMessageId = { /** * Stop a running chat message generation */ -export const post19 = oc +export const post15 = oc .route({ description: 'Stop a running chat message generation', inputStructure: 'detailed', @@ -1535,7 +1361,7 @@ export const post19 = oc .output(zPostAppsByAppIdChatMessagesByTaskIdStopResponse) export const stop = { - post: post19, + post: post15, } export const byTaskId = { @@ -1629,7 +1455,7 @@ export const completionConversations = { /** * Stop a running completion message generation */ -export const post20 = oc +export const post16 = oc .route({ description: 'Stop a running completion message generation', inputStructure: 'detailed', @@ -1642,35 +1468,14 @@ export const post20 = oc .output(zPostAppsByAppIdCompletionMessagesByTaskIdStopResponse) export const stop2 = { - post: post20, + post: post16, } export const byTaskId2 = { stop: stop2, } -/** - * Generate completion message for debugging - */ -export const post21 = oc - .route({ - description: 'Generate completion message for debugging', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdCompletionMessages', - path: '/apps/{app_id}/completion-messages', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdCompletionMessagesBody, - params: zPostAppsByAppIdCompletionMessagesPath, - }), - ) - .output(zPostAppsByAppIdCompletionMessagesResponse) - export const completionMessages = { - post: post21, byTaskId: byTaskId2, } @@ -1705,7 +1510,7 @@ export const conversationVariables = { * Convert expert mode of chatbot app to workflow mode * Convert Completion App to Workflow App */ -export const post22 = oc +export const post17 = oc .route({ description: 'Convert application to workflow mode\nConvert expert mode of chatbot app to workflow mode\nConvert Completion App to Workflow App', @@ -1725,7 +1530,7 @@ export const post22 = oc .output(zPostAppsByAppIdConvertToWorkflowResponse) export const convertToWorkflow = { - post: post22, + post: post17, } /** @@ -1733,7 +1538,7 @@ export const convertToWorkflow = { * * Create a copy of an existing application */ -export const post23 = oc +export const post18 = oc .route({ description: 'Create a copy of an existing application', inputStructure: 'detailed', @@ -1748,7 +1553,7 @@ export const post23 = oc .output(zPostAppsByAppIdCopyResponse) export const copy = { - post: post23, + post: post18, } /** @@ -1802,7 +1607,7 @@ export const export3 = { /** * Create or update message feedback (like/dislike) */ -export const post24 = oc +export const post19 = oc .route({ description: 'Create or update message feedback (like/dislike)', inputStructure: 'detailed', @@ -1815,14 +1620,14 @@ export const post24 = oc .output(zPostAppsByAppIdFeedbacksResponse) export const feedbacks = { - post: post24, + post: post19, export: export3, } /** * Update application icon */ -export const post25 = oc +export const post20 = oc .route({ description: 'Update application icon', inputStructure: 'detailed', @@ -1835,7 +1640,7 @@ export const post25 = oc .output(zPostAppsByAppIdIconResponse) export const icon = { - post: post25, + post: post20, } /** @@ -1866,7 +1671,7 @@ export const messages = { * * Update application model configuration */ -export const post26 = oc +export const post21 = oc .route({ description: 'Update application model configuration', inputStructure: 'detailed', @@ -1882,13 +1687,13 @@ export const post26 = oc .output(zPostAppsByAppIdModelConfigResponse) export const modelConfig = { - post: post26, + post: post21, } /** * Check if app name is available */ -export const post27 = oc +export const post22 = oc .route({ description: 'Check if app name is available', inputStructure: 'detailed', @@ -1901,13 +1706,13 @@ export const post27 = oc .output(zPostAppsByAppIdNameResponse) export const name = { - post: post27, + post: post22, } /** * Publish app to Creators Platform */ -export const post28 = oc +export const post23 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -1920,7 +1725,7 @@ export const post28 = oc .output(zPostAppsByAppIdPublishToCreatorsPlatformResponse) export const publishToCreatorsPlatform = { - post: post28, + post: post23, } /** @@ -1941,7 +1746,7 @@ export const get28 = oc /** * Create MCP server configuration for an application */ -export const post29 = oc +export const post24 = oc .route({ description: 'Create MCP server configuration for an application', inputStructure: 'detailed', @@ -1971,14 +1776,14 @@ export const put = oc export const server = { get: get28, - post: post29, + post: post24, put, } /** * Reset access token for application site */ -export const post30 = oc +export const post25 = oc .route({ description: 'Reset access token for application site', inputStructure: 'detailed', @@ -1991,13 +1796,13 @@ export const post30 = oc .output(zPostAppsByAppIdSiteAccessTokenResetResponse) export const accessTokenReset = { - post: post30, + post: post25, } /** * Update application site configuration */ -export const post31 = oc +export const post26 = oc .route({ description: 'Update application site configuration', inputStructure: 'detailed', @@ -2010,14 +1815,14 @@ export const post31 = oc .output(zPostAppsByAppIdSiteResponse) export const site = { - post: post31, + post: post26, accessTokenReset, } /** * Enable or disable app site */ -export const post32 = oc +export const post27 = oc .route({ description: 'Enable or disable app site', inputStructure: 'detailed', @@ -2030,7 +1835,7 @@ export const post32 = oc .output(zPostAppsByAppIdSiteEnableResponse) export const siteEnable = { - post: post32, + post: post27, } /** @@ -2051,7 +1856,7 @@ export const delete7 = oc /** * Star an application for the current account */ -export const post33 = oc +export const post28 = oc .route({ description: 'Star an application for the current account', inputStructure: 'detailed', @@ -2065,7 +1870,7 @@ export const post33 = oc export const star = { delete: delete7, - post: post33, + post: post28, } /** @@ -2298,7 +2103,7 @@ export const voices = { /** * Convert text to speech for chat messages */ -export const post34 = oc +export const post29 = oc .route({ description: 'Convert text to speech for chat messages', inputStructure: 'detailed', @@ -2313,7 +2118,7 @@ export const post34 = oc .output(zPostAppsByAppIdTextToAudioResponse) export const textToAudio = { - post: post34, + post: post29, voices, } @@ -2338,7 +2143,7 @@ export const get38 = oc /** * Update app tracing configuration */ -export const post35 = oc +export const post30 = oc .route({ description: 'Update app tracing configuration', inputStructure: 'detailed', @@ -2352,7 +2157,7 @@ export const post35 = oc export const trace = { get: get38, - post: post35, + post: post30, } /** @@ -2421,7 +2226,7 @@ export const patch = oc * * Create a new tracing configuration for an application */ -export const post36 = oc +export const post31 = oc .route({ description: 'Create a new tracing configuration for an application', inputStructure: 'detailed', @@ -2441,13 +2246,13 @@ export const traceConfig = { delete: delete8, get: get39, patch, - post: post36, + post: post31, } /** * Update app trigger (enable/disable) */ -export const post37 = oc +export const post32 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -2465,7 +2270,7 @@ export const post37 = oc .output(zPostAppsByAppIdTriggerEnableResponse) export const triggerEnable = { - post: post37, + post: post32, } /** @@ -2573,7 +2378,7 @@ export const count3 = { * * Stop running workflow task */ -export const post38 = oc +export const post33 = oc .route({ description: 'Stop running workflow task', inputStructure: 'detailed', @@ -2587,7 +2392,7 @@ export const post38 = oc .output(zPostAppsByAppIdWorkflowRunsTasksByTaskIdStopResponse) export const stop3 = { - post: post38, + post: post33, } export const byTaskId3 = { @@ -2690,7 +2495,7 @@ export const read = { /** * Upload one workflow Agent sandbox file as a Dify ToolFile mapping */ -export const post39 = oc +export const post34 = oc .route({ description: 'Upload one workflow Agent sandbox file as a Dify ToolFile mapping', inputStructure: 'detailed', @@ -2708,7 +2513,7 @@ export const post39 = oc .output(zPostAppsByAppIdWorkflowRunsByWorkflowRunIdAgentNodesByNodeIdSandboxFilesUploadResponse) export const upload2 = { - post: post39, + post: post34, } /** @@ -2742,12 +2547,12 @@ export const sandbox = { files: files3, } -export const byNodeId4 = { +export const byNodeId2 = { sandbox, } export const agentNodes = { - byNodeId: byNodeId4, + byNodeId: byNodeId2, } export const byWorkflowRunId = { @@ -2859,7 +2664,7 @@ export const byReplyId = { * * Add a reply to a workflow comment */ -export const post40 = oc +export const post35 = oc .route({ description: 'Add a reply to a workflow comment', inputStructure: 'detailed', @@ -2879,7 +2684,7 @@ export const post40 = oc .output(zPostAppsByAppIdWorkflowCommentsByCommentIdRepliesResponse) export const replies = { - post: post40, + post: post35, byReplyId, } @@ -2888,7 +2693,7 @@ export const replies = { * * Resolve a workflow comment */ -export const post41 = oc +export const post36 = oc .route({ description: 'Resolve a workflow comment', inputStructure: 'detailed', @@ -2902,7 +2707,7 @@ export const post41 = oc .output(zPostAppsByAppIdWorkflowCommentsByCommentIdResolveResponse) export const resolve = { - post: post41, + post: post36, } /** @@ -2996,7 +2801,7 @@ export const get52 = oc * * Create a new workflow comment */ -export const post42 = oc +export const post37 = oc .route({ description: 'Create a new workflow comment', inputStructure: 'detailed', @@ -3017,7 +2822,7 @@ export const post42 = oc export const comments = { get: get52, - post: post42, + post: post37, mentionUsers, byCommentId, } @@ -3130,60 +2935,10 @@ export const workflow = { statistics: statistics2, } -/** - * Get default block config - * - * Get default block configuration by type - */ -export const get57 = oc - .route({ - description: 'Get default block configuration by type', - inputStructure: 'detailed', - method: 'GET', - operationId: 'getAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockType', - path: '/apps/{app_id}/workflows/default-workflow-block-configs/{block_type}', - summary: 'Get default block config', - tags: ['console'], - }) - .input( - z.object({ - params: zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypePath, - query: zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeQuery.optional(), - }), - ) - .output(zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse) - -export const byBlockType = { - get: get57, -} - -/** - * Get default block config - * - * Get default block configurations for workflow - */ -export const get58 = oc - .route({ - description: 'Get default block configurations for workflow', - inputStructure: 'detailed', - method: 'GET', - operationId: 'getAppsByAppIdWorkflowsDefaultWorkflowBlockConfigs', - path: '/apps/{app_id}/workflows/default-workflow-block-configs', - summary: 'Get default block config', - tags: ['console'], - }) - .input(z.object({ params: zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsPath })) - .output(zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponse) - -export const defaultWorkflowBlockConfigs = { - get: get58, - byBlockType, -} - /** * Get conversation variables for workflow */ -export const get59 = oc +export const get57 = oc .route({ description: 'Get conversation variables for workflow', inputStructure: 'detailed', @@ -3198,7 +2953,7 @@ export const get59 = oc /** * Update conversation variables for workflow draft */ -export const post43 = oc +export const post38 = oc .route({ description: 'Update conversation variables for workflow draft', inputStructure: 'detailed', @@ -3216,8 +2971,8 @@ export const post43 = oc .output(zPostAppsByAppIdWorkflowsDraftConversationVariablesResponse) export const conversationVariables2 = { - get: get59, - post: post43, + get: get57, + post: post38, } /** @@ -3225,7 +2980,7 @@ export const conversationVariables2 = { * * Get environment variables for workflow */ -export const get60 = oc +export const get58 = oc .route({ description: 'Get environment variables for workflow', inputStructure: 'detailed', @@ -3241,7 +2996,7 @@ export const get60 = oc /** * Update environment variables for workflow draft */ -export const post44 = oc +export const post39 = oc .route({ description: 'Update environment variables for workflow draft', inputStructure: 'detailed', @@ -3259,14 +3014,14 @@ export const post44 = oc .output(zPostAppsByAppIdWorkflowsDraftEnvironmentVariablesResponse) export const environmentVariables = { - get: get60, - post: post44, + get: get58, + post: post39, } /** * Update draft workflow features */ -export const post45 = oc +export const post40 = oc .route({ description: 'Update draft workflow features', inputStructure: 'detailed', @@ -3284,7 +3039,7 @@ export const post45 = oc .output(zPostAppsByAppIdWorkflowsDraftFeaturesResponse) export const features = { - post: post45, + post: post40, } /** @@ -3292,7 +3047,7 @@ export const features = { * * Test human input delivery for workflow */ -export const post46 = oc +export const post41 = oc .route({ description: 'Test human input delivery for workflow', inputStructure: 'detailed', @@ -3311,7 +3066,7 @@ export const post46 = oc .output(zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdDeliveryTestResponse) export const deliveryTest = { - post: post46, + post: post41, } /** @@ -3319,7 +3074,7 @@ export const deliveryTest = { * * Get human input form preview for workflow */ -export const post47 = oc +export const post42 = oc .route({ description: 'Get human input form preview for workflow', inputStructure: 'detailed', @@ -3338,133 +3093,27 @@ export const post47 = oc .output(zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse) export const preview3 = { - post: post47, -} - -/** - * Submit human input form preview - * - * Submit human input form preview for workflow - */ -export const post48 = oc - .route({ - description: 'Submit human input form preview for workflow', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRun', - path: '/apps/{app_id}/workflows/draft/human-input/nodes/{node_id}/form/run', - summary: 'Submit human input form preview', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunBody, - params: zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunPath, - }), - ) - .output(zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse) - -export const run5 = { - post: post48, + post: post42, } export const form2 = { preview: preview3, - run: run5, } -export const byNodeId5 = { +export const byNodeId3 = { deliveryTest, form: form2, } -export const nodes4 = { - byNodeId: byNodeId5, +export const nodes2 = { + byNodeId: byNodeId3, } export const humanInput2 = { - nodes: nodes4, + nodes: nodes2, } -/** - * Run draft workflow iteration node - * - * Run draft workflow iteration node - */ -export const post49 = oc - .route({ - description: 'Run draft workflow iteration node', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRun', - path: '/apps/{app_id}/workflows/draft/iteration/nodes/{node_id}/run', - summary: 'Run draft workflow iteration node', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunBody, - params: zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunPath, - }), - ) - .output(zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponse) - -export const run6 = { - post: post49, -} - -export const byNodeId6 = { - run: run6, -} - -export const nodes5 = { - byNodeId: byNodeId6, -} - -export const iteration2 = { - nodes: nodes5, -} - -/** - * Run draft workflow loop node - * - * Run draft workflow loop node - */ -export const post50 = oc - .route({ - description: 'Run draft workflow loop node', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRun', - path: '/apps/{app_id}/workflows/draft/loop/nodes/{node_id}/run', - summary: 'Run draft workflow loop node', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunBody, - params: zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunPath, - }), - ) - .output(zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponse) - -export const run7 = { - post: post50, -} - -export const byNodeId7 = { - run: run7, -} - -export const nodes6 = { - byNodeId: byNodeId7, -} - -export const loop2 = { - nodes: nodes6, -} - -export const get61 = oc +export const get59 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3478,10 +3127,10 @@ export const get61 = oc .output(zGetAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerCandidatesResponse) export const candidates = { - get: get61, + get: get59, } -export const post51 = oc +export const post43 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -3498,10 +3147,10 @@ export const post51 = oc .output(zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerCopyFromRosterResponse) export const copyFromRoster = { - post: post51, + post: post43, } -export const post52 = oc +export const post44 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -3518,10 +3167,10 @@ export const post52 = oc .output(zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerImpactResponse) export const impact = { - post: post52, + post: post44, } -export const post53 = oc +export const post45 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -3538,10 +3187,10 @@ export const post53 = oc .output(zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerSaveToRosterResponse) export const saveToRoster = { - post: post53, + post: post45, } -export const post54 = oc +export const post46 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -3558,10 +3207,10 @@ export const post54 = oc .output(zPostAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerValidateResponse) export const validate = { - post: post54, + post: post46, } -export const get62 = oc +export const get60 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3589,7 +3238,7 @@ export const put4 = oc .output(zPutAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerResponse) export const agentComposer = { - get: get62, + get: get60, put: put4, candidates, copyFromRoster, @@ -3601,7 +3250,7 @@ export const agentComposer = { /** * Get last run result for draft workflow node */ -export const get63 = oc +export const get61 = oc .route({ description: 'Get last run result for draft workflow node', inputStructure: 'detailed', @@ -3614,7 +3263,7 @@ export const get63 = oc .output(zGetAppsByAppIdWorkflowsDraftNodesByNodeIdLastRunResponse) export const lastRun = { - get: get63, + get: get61, } /** @@ -3622,7 +3271,7 @@ export const lastRun = { * * Run draft workflow node */ -export const post55 = oc +export const post47 = oc .route({ description: 'Run draft workflow node', inputStructure: 'detailed', @@ -3640,8 +3289,8 @@ export const post55 = oc ) .output(zPostAppsByAppIdWorkflowsDraftNodesByNodeIdRunResponse) -export const run8 = { - post: post55, +export const run = { + post: post47, } /** @@ -3649,7 +3298,7 @@ export const run8 = { * * Poll for trigger events and execute single node when event arrives */ -export const post56 = oc +export const post48 = oc .route({ description: 'Poll for trigger events and execute single node when event arrives', inputStructure: 'detailed', @@ -3662,12 +3311,12 @@ export const post56 = oc .input(z.object({ params: zPostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunPath })) .output(zPostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunResponse) -export const run9 = { - post: post56, +export const run2 = { + post: post48, } export const trigger = { - run: run9, + run: run2, } /** @@ -3689,7 +3338,7 @@ export const delete11 = oc /** * Get variables for a specific node */ -export const get64 = oc +export const get62 = oc .route({ description: 'Get variables for a specific node', inputStructure: 'detailed', @@ -3703,52 +3352,25 @@ export const get64 = oc export const variables = { delete: delete11, - get: get64, + get: get62, } -export const byNodeId8 = { +export const byNodeId4 = { agentComposer, lastRun, - run: run8, + run, trigger, variables, } -export const nodes7 = { - byNodeId: byNodeId8, -} - -/** - * Run draft workflow - * - * Run draft workflow - */ -export const post57 = oc - .route({ - description: 'Run draft workflow', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdWorkflowsDraftRun', - path: '/apps/{app_id}/workflows/draft/run', - summary: 'Run draft workflow', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdWorkflowsDraftRunBody, - params: zPostAppsByAppIdWorkflowsDraftRunPath, - }), - ) - .output(zPostAppsByAppIdWorkflowsDraftRunResponse) - -export const run10 = { - post: post57, +export const nodes3 = { + byNodeId: byNodeId4, } /** * Server-Sent Events stream of inspector deltas for a draft workflow run. */ -export const get65 = oc +export const get63 = oc .route({ description: 'Server-Sent Events stream of inspector deltas for a draft workflow run.', inputStructure: 'detailed', @@ -3761,13 +3383,13 @@ export const get65 = oc .output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsEventsResponse) export const events = { - get: get65, + get: get63, } /** * Full value for one declared output, including signed download URL for files. */ -export const get66 = oc +export const get64 = oc .route({ description: 'Full value for one declared output, including signed download URL for files.', inputStructure: 'detailed', @@ -3784,7 +3406,7 @@ export const get66 = oc .output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsByNodeIdByOutputNamePreviewResponse) export const preview4 = { - get: get66, + get: get64, } export const byOutputName = { @@ -3794,7 +3416,7 @@ export const byOutputName = { /** * One node's declared outputs for a draft workflow run. */ -export const get67 = oc +export const get65 = oc .route({ description: 'One node\'s declared outputs for a draft workflow run.', inputStructure: 'detailed', @@ -3806,15 +3428,15 @@ export const get67 = oc .input(z.object({ params: zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsByNodeIdPath })) .output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsByNodeIdResponse) -export const byNodeId9 = { - get: get67, +export const byNodeId5 = { + get: get65, byOutputName, } /** * Snapshot of every node's declared outputs for a draft workflow run. */ -export const get68 = oc +export const get66 = oc .route({ description: 'Snapshot of every node\'s declared outputs for a draft workflow run.', inputStructure: 'detailed', @@ -3827,9 +3449,9 @@ export const get68 = oc .output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsResponse) export const nodeOutputs = { - get: get68, + get: get66, events, - byNodeId: byNodeId9, + byNodeId: byNodeId5, } export const byRunId2 = { @@ -3843,7 +3465,7 @@ export const runs = { /** * Get system variables for workflow */ -export const get69 = oc +export const get67 = oc .route({ description: 'Get system variables for workflow', inputStructure: 'detailed', @@ -3856,66 +3478,7 @@ export const get69 = oc .output(zGetAppsByAppIdWorkflowsDraftSystemVariablesResponse) export const systemVariables = { - get: get69, -} - -/** - * Poll for trigger events and execute full workflow when event arrives - * - * Poll for trigger events and execute full workflow when event arrives - */ -export const post58 = oc - .route({ - description: 'Poll for trigger events and execute full workflow when event arrives', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdWorkflowsDraftTriggerRun', - path: '/apps/{app_id}/workflows/draft/trigger/run', - summary: 'Poll for trigger events and execute full workflow when event arrives', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdWorkflowsDraftTriggerRunBody, - params: zPostAppsByAppIdWorkflowsDraftTriggerRunPath, - }), - ) - .output(zPostAppsByAppIdWorkflowsDraftTriggerRunResponse) - -export const run11 = { - post: post58, -} - -/** - * Full workflow debug when the start node is a trigger - * - * Full workflow debug when the start node is a trigger - */ -export const post59 = oc - .route({ - description: 'Full workflow debug when the start node is a trigger', - inputStructure: 'detailed', - method: 'POST', - operationId: 'postAppsByAppIdWorkflowsDraftTriggerRunAll', - path: '/apps/{app_id}/workflows/draft/trigger/run-all', - summary: 'Full workflow debug when the start node is a trigger', - tags: ['console'], - }) - .input( - z.object({ - body: zPostAppsByAppIdWorkflowsDraftTriggerRunAllBody, - params: zPostAppsByAppIdWorkflowsDraftTriggerRunAllPath, - }), - ) - .output(zPostAppsByAppIdWorkflowsDraftTriggerRunAllResponse) - -export const runAll = { - post: post59, -} - -export const trigger2 = { - run: run11, - runAll, + get: get67, } /** @@ -3956,7 +3519,7 @@ export const delete12 = oc /** * Get a specific workflow variable */ -export const get70 = oc +export const get68 = oc .route({ description: 'Get a specific workflow variable', inputStructure: 'detailed', @@ -3990,7 +3553,7 @@ export const patch2 = oc export const byVariableId = { delete: delete12, - get: get70, + get: get68, patch: patch2, reset, } @@ -4016,7 +3579,7 @@ export const delete13 = oc * * Get draft workflow variables */ -export const get71 = oc +export const get69 = oc .route({ description: 'Get draft workflow variables', inputStructure: 'detailed', @@ -4036,7 +3599,7 @@ export const get71 = oc export const variables2 = { delete: delete13, - get: get71, + get: get69, byVariableId, } @@ -4045,7 +3608,7 @@ export const variables2 = { * * Get draft workflow for an application */ -export const get72 = oc +export const get70 = oc .route({ description: 'Get draft workflow for an application', inputStructure: 'detailed', @@ -4063,7 +3626,7 @@ export const get72 = oc * * Sync draft workflow configuration */ -export const post60 = oc +export const post49 = oc .route({ description: 'Sync draft workflow configuration', inputStructure: 'detailed', @@ -4082,19 +3645,15 @@ export const post60 = oc .output(zPostAppsByAppIdWorkflowsDraftResponse) export const draft2 = { - get: get72, - post: post60, + get: get70, + post: post49, conversationVariables: conversationVariables2, environmentVariables, features, humanInput: humanInput2, - iteration: iteration2, - loop: loop2, - nodes: nodes7, - run: run10, + nodes: nodes3, runs, systemVariables, - trigger: trigger2, variables: variables2, } @@ -4103,7 +3662,7 @@ export const draft2 = { * * Get published workflow for an application */ -export const get73 = oc +export const get71 = oc .route({ description: 'Get published workflow for an application', inputStructure: 'detailed', @@ -4119,7 +3678,7 @@ export const get73 = oc /** * Publish workflow */ -export const post61 = oc +export const post50 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -4137,14 +3696,14 @@ export const post61 = oc .output(zPostAppsByAppIdWorkflowsPublishResponse) export const publish = { - get: get73, - post: post61, + get: get71, + post: post50, } /** * Server-Sent Events stream of inspector deltas for a published workflow run. */ -export const get74 = oc +export const get72 = oc .route({ description: 'Server-Sent Events stream of inspector deltas for a published workflow run.', inputStructure: 'detailed', @@ -4157,13 +3716,13 @@ export const get74 = oc .output(zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsEventsResponse) export const events2 = { - get: get74, + get: get72, } /** * Full value for one declared output of a published run. */ -export const get75 = oc +export const get73 = oc .route({ description: 'Full value for one declared output of a published run.', inputStructure: 'detailed', @@ -4184,7 +3743,7 @@ export const get75 = oc ) export const preview5 = { - get: get75, + get: get73, } export const byOutputName2 = { @@ -4194,7 +3753,7 @@ export const byOutputName2 = { /** * One node's declared outputs for a published workflow run. */ -export const get76 = oc +export const get74 = oc .route({ description: 'One node\'s declared outputs for a published workflow run.', inputStructure: 'detailed', @@ -4206,15 +3765,15 @@ export const get76 = oc .input(z.object({ params: zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsByNodeIdPath })) .output(zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsByNodeIdResponse) -export const byNodeId10 = { - get: get76, +export const byNodeId6 = { + get: get74, byOutputName: byOutputName2, } /** * Snapshot of every node's declared outputs for a published workflow run. */ -export const get77 = oc +export const get75 = oc .route({ description: 'Snapshot of every node\'s declared outputs for a published workflow run.', inputStructure: 'detailed', @@ -4227,9 +3786,9 @@ export const get77 = oc .output(zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsResponse) export const nodeOutputs2 = { - get: get77, + get: get75, events: events2, - byNodeId: byNodeId10, + byNodeId: byNodeId6, } export const byRunId3 = { @@ -4247,7 +3806,7 @@ export const published = { /** * Get webhook trigger for a node */ -export const get78 = oc +export const get76 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4265,7 +3824,7 @@ export const get78 = oc .output(zGetAppsByAppIdWorkflowsTriggersWebhookResponse) export const webhook = { - get: get78, + get: get76, } export const triggers2 = { @@ -4275,7 +3834,7 @@ export const triggers2 = { /** * Restore a published workflow version into the draft workflow */ -export const post62 = oc +export const post51 = oc .route({ description: 'Restore a published workflow version into the draft workflow', inputStructure: 'detailed', @@ -4288,7 +3847,7 @@ export const post62 = oc .output(zPostAppsByAppIdWorkflowsByWorkflowIdRestoreResponse) export const restore = { - post: post62, + post: post51, } /** @@ -4341,7 +3900,7 @@ export const byWorkflowId = { * * Get all published workflows for an application */ -export const get79 = oc +export const get77 = oc .route({ description: 'Get all published workflows for an application', inputStructure: 'detailed', @@ -4360,8 +3919,7 @@ export const get79 = oc .output(zGetAppsByAppIdWorkflowsResponse) export const workflows3 = { - get: get79, - defaultWorkflowBlockConfigs, + get: get77, draft: draft2, publish, published, @@ -4393,7 +3951,7 @@ export const delete15 = oc * * Get application details */ -export const get80 = oc +export const get78 = oc .route({ description: 'Get application details', inputStructure: 'detailed', @@ -4426,7 +3984,7 @@ export const put6 = oc export const byAppId2 = { delete: delete15, - get: get80, + get: get78, put: put6, advancedChat, agent, @@ -4495,7 +4053,7 @@ export const byApiKeyId = { * * Get all API keys for an app */ -export const get81 = oc +export const get79 = oc .route({ description: 'Get all API keys for an app', inputStructure: 'detailed', @@ -4513,7 +4071,7 @@ export const get81 = oc * * Create a new API key for an app */ -export const post63 = oc +export const post52 = oc .route({ description: 'Create a new API key for an app', inputStructure: 'detailed', @@ -4528,8 +4086,8 @@ export const post63 = oc .output(zPostAppsByResourceIdApiKeysResponse) export const apiKeys = { - get: get81, - post: post63, + get: get79, + post: post52, byApiKeyId, } @@ -4540,7 +4098,7 @@ export const byResourceId = { /** * Refresh MCP server configuration and regenerate server code */ -export const get82 = oc +export const get80 = oc .route({ description: 'Refresh MCP server configuration and regenerate server code', inputStructure: 'detailed', @@ -4553,7 +4111,7 @@ export const get82 = oc .output(zGetAppsByServerIdServerRefreshResponse) export const refresh = { - get: get82, + get: get80, } export const server2 = { @@ -4569,7 +4127,7 @@ export const byServerId = { * * Get list of applications with pagination and filtering */ -export const get83 = oc +export const get81 = oc .route({ description: 'Get list of applications with pagination and filtering', inputStructure: 'detailed', @@ -4587,7 +4145,7 @@ export const get83 = oc * * Create a new application */ -export const post64 = oc +export const post53 = oc .route({ description: 'Create a new application', inputStructure: 'detailed', @@ -4602,8 +4160,8 @@ export const post64 = oc .output(zPostAppsResponse) export const apps = { - get: get83, - post: post64, + get: get81, + post: post53, imports, starred, workflows, diff --git a/packages/contracts/generated/api/console/apps/types.gen.ts b/packages/contracts/generated/api/console/apps/types.gen.ts index 9e79518f3cd..e6c2b304241 100644 --- a/packages/contracts/generated/api/console/apps/types.gen.ts +++ b/packages/contracts/generated/api/console/apps/types.gen.ts @@ -119,10 +119,9 @@ export type HumanInputFormPreviewPayload = { } export type HumanInputFormPreviewResponse = { - actions?: Array<{ - [key: string]: unknown - }> - display_in_ui?: boolean | null + TYPE?: 'human_input_required' + actions?: Array + display_in_ui?: boolean expiration_time?: number | null form_content: string form_id: string @@ -137,46 +136,6 @@ export type HumanInputFormPreviewResponse = { } } -export type HumanInputFormSubmitPayload = { - action: string - form_inputs: { - [key: string]: unknown - } - inputs: { - [key: string]: unknown - } -} - -export type HumanInputFormSubmitResponse = { - [key: string]: unknown -} - -export type IterationNodeRunPayload = { - inputs?: { - [key: string]: unknown - } | null -} - -export type GeneratedAppResponse = JsonValue - -export type LoopNodeRunPayload = { - inputs?: { - [key: string]: unknown - } | null -} - -export type AdvancedChatWorkflowRunPayload = { - conversation_id?: string | null - files?: Array<{ - [key: string]: unknown - }> | null - inputs?: { - [key: string]: unknown - } | null - parent_message_id?: string | null - query?: string -} - export type AgentDriveListResponse = { items?: Array } @@ -409,19 +368,6 @@ export type ConversationMessageDetail = { status: string } -export type CompletionMessagePayload = { - files?: Array | null - inputs: { - [key: string]: unknown - } - model_config?: { - [key: string]: unknown - } - query?: string - response_mode?: 'blocking' | 'streaming' - retriever_from?: string -} - export type PaginatedConversationVariableResponse = { data: Array has_more: boolean @@ -472,6 +418,7 @@ export type MessageDetailResponse = { agent_thoughts?: Array annotation?: ConversationAnnotation | null annotation_hit_history?: ConversationAnnotationHitHistory | null + answer: string answer_tokens?: number | null conversation_id: string created_at?: number | null @@ -487,12 +434,11 @@ export type MessageDetailResponse = { } message?: JsonValue | null message_files?: Array - message_metadata_dict?: JsonValue | null message_tokens?: number | null + metadata?: JsonValue | null parent_message_id?: string | null provider_response_latency?: number | null query: string - re_sign_file_url_answer: string status: string workflow_run_id?: string | null } @@ -731,7 +677,7 @@ export type WorkflowRunPaginationResponse = { export type WorkflowRunDetailResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -799,7 +745,7 @@ export type WorkflowCommentCreate = { } export type WorkflowCommentMentionUsersPayload = { - users: Array + users: Array } export type WorkflowCommentDetail = { @@ -876,18 +822,10 @@ export type WorkflowPaginationResponse = { page: number } -export type DefaultBlockConfigsResponse = Array<{ - [key: string]: unknown -}> - -export type DefaultBlockConfigResponse = { - [key: string]: unknown -} - export type WorkflowResponse = { conversation_variables: Array created_at: number - created_by?: SimpleAccount | null + created_by?: SimpleAccountResponse | null environment_variables: Array features: { [key: string]: unknown @@ -902,7 +840,7 @@ export type WorkflowResponse = { rag_pipeline_variables: Array tool_published: boolean updated_at: number - updated_by?: SimpleAccount | null + updated_by?: SimpleAccountResponse | null version: string } @@ -923,9 +861,9 @@ export type SyncDraftWorkflowPayload = { } export type SyncDraftWorkflowResponse = { - hash?: string - result?: string - updated_at?: string + hash: string + result: string + updated_at: number } export type WorkflowDraftVariableList = { @@ -961,7 +899,7 @@ export type HumanInputDeliveryTestPayload = { } } -export type EmptyObjectResponse = { +export type HumanInputDeliveryTestResponse = { [key: string]: unknown } @@ -1029,7 +967,7 @@ export type AgentComposerValidateResponse = { export type WorkflowRunNodeExecutionResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -1062,17 +1000,6 @@ export type DraftWorkflowNodeRunPayload = { query?: string } -export type DraftWorkflowRunPayload = { - datasource_info_list: Array<{ - [key: string]: unknown - }> - datasource_type: string - inputs: { - [key: string]: unknown - } - start_node_id: string -} - export type WorkflowRunSnapshotView = { node_outputs?: Array workflow_run_id: string @@ -1099,14 +1026,6 @@ export type OutputPreviewView = { value?: unknown } -export type DraftWorkflowTriggerRunRequest = { - node_id: string -} - -export type DraftWorkflowTriggerRunAllPayload = { - node_ids: Array -} - export type WorkflowDraftVariableListWithoutValue = { items?: Array total?: number @@ -1143,12 +1062,11 @@ export type WorkflowDraftVariableUpdatePayload = { } export type PublishWorkflowPayload = { - knowledge_base_setting?: { - [key: string]: unknown - } | null + marked_comment?: string | null + marked_name?: string | null } -export type WorkflowPublishResponse = { +export type PublishWorkflowResponse = { created_at: number result: string } @@ -1167,12 +1085,6 @@ export type WorkflowUpdatePayload = { marked_name?: string | null } -export type WorkflowRestoreResponse = { - hash: string - result: string - updated_at: number -} - export type ApiKeyList = { data: Array } @@ -1223,12 +1135,30 @@ export type DeletedTool = { } export type ModelConfig = { - completion_params?: { - [key: string]: unknown - } - mode: LlmMode - name: string - provider: string + agent_mode?: JsonValue | null + annotation_reply?: JsonValue | null + chat_prompt_config?: JsonValue | null + completion_prompt_config?: JsonValue | null + created_at?: number | null + created_by?: string | null + dataset_configs?: JsonValue | null + dataset_query_variable?: string | null + external_data_tools?: JsonValue | null + file_upload?: JsonValue | null + model?: JsonValue | null + more_like_this?: JsonValue | null + opening_statement?: string | null + pre_prompt?: string | null + prompt_type?: string | null + retriever_resource?: JsonValue | null + sensitive_word_avoidance?: JsonValue | null + speech_to_text?: JsonValue | null + suggested_questions?: JsonValue | null + suggested_questions_after_answer?: JsonValue | null + text_to_speech?: JsonValue | null + updated_at?: number | null + updated_by?: string | null + user_input_form?: JsonValue | null } export type Site = { @@ -1254,16 +1184,7 @@ export type Tag = { type: string } -export type JsonValue - = | string - | number - | number - | boolean - | { - [key: string]: unknown - } - | Array - | null +export type JsonValue = unknown export type WorkflowPartial = { created_at?: number | null @@ -1289,7 +1210,7 @@ export type WorkflowOnlineUsersByApp = { export type AdvancedChatWorkflowRunForListResponse = { conversation_id?: string | null created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -1302,6 +1223,12 @@ export type AdvancedChatWorkflowRunForListResponse = { version?: string | null } +export type HumanInputUserActionResponse = { + button_style?: string + id: string + title: string +} + export type AgentDriveItemResponse = { created_at?: number | null file_kind: string @@ -1498,7 +1425,6 @@ export type AgentThought = { created_at?: number | null files: Array id: string - message_chain_id?: string | null message_id: string observation?: string | null position: number @@ -1518,8 +1444,8 @@ export type ConversationAnnotation = { export type ConversationAnnotationHitHistory = { annotation_create_account?: SimpleAccount | null + annotation_id: string created_at?: number | null - id: string } export type HumanInputContent = { @@ -1596,7 +1522,7 @@ export type UserSatisfactionRateStatisticItem = { export type WorkflowAppLogPartialResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null created_from?: string | null @@ -1607,7 +1533,7 @@ export type WorkflowAppLogPartialResponse = { export type WorkflowArchivedLogPartialResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null id: string trigger_metadata?: unknown @@ -1616,7 +1542,7 @@ export type WorkflowArchivedLogPartialResponse = { export type WorkflowRunForListResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -1628,7 +1554,7 @@ export type WorkflowRunForListResponse = { version?: string | null } -export type SimpleAccount = { +export type SimpleAccountResponse = { email: string id: string name: string @@ -1671,7 +1597,7 @@ export type WorkflowCommentBasic = { updated_at?: number | null } -export type AccountWithRole = { +export type AccountWithRoleResponse = { avatar?: string | null created_at?: number | null email: string @@ -1982,8 +1908,6 @@ export type ModelConfigPartial = { updated_by?: string | null } -export type LlmMode = 'chat' | 'completion' - export type Type = 'github' | 'marketplace' | 'package' export type Github = { @@ -2054,6 +1978,12 @@ export type SimpleMessageDetail = { query: string } +export type SimpleAccount = { + email: string + id: string + name: string +} + export type HumanInputFormDefinition = { actions?: Array display_in_ui?: boolean @@ -2631,8 +2561,6 @@ export type AppDetailWithSiteWritable = { workflow?: WorkflowPartial | null } -export type GeneratedAppResponseWritable = JsonValue - export type WorkflowCommentBasicListWritable = { data: Array } @@ -2654,6 +2582,10 @@ export type WorkflowCommentDetailWritable = { updated_at?: number | null } +export type HumanInputDeliveryTestResponseWritable = { + [key: string]: unknown +} + export type AppPartialWritable = { access_mode?: string | null app_id?: string | null @@ -2999,88 +2931,6 @@ export type PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdForm export type PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse = PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponses[keyof PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponses] -export type PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunData = { - body: HumanInputFormSubmitPayload - path: { - app_id: string - node_id: string - } - query?: never - url: '/apps/{app_id}/advanced-chat/workflows/draft/human-input/nodes/{node_id}/form/run' -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponses = { - 200: HumanInputFormSubmitResponse -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse - = PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponses[keyof PostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponses] - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunData = { - body: IterationNodeRunPayload - path: { - app_id: string - node_id: string - } - query?: never - url: '/apps/{app_id}/advanced-chat/workflows/draft/iteration/nodes/{node_id}/run' -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunErrors = { - 403: unknown - 404: unknown -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponse - = PostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponses[keyof PostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponses] - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunData = { - body: LoopNodeRunPayload - path: { - app_id: string - node_id: string - } - query?: never - url: '/apps/{app_id}/advanced-chat/workflows/draft/loop/nodes/{node_id}/run' -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunErrors = { - 403: unknown - 404: unknown -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponse - = PostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponses[keyof PostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponses] - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftRunData = { - body: AdvancedChatWorkflowRunPayload - path: { - app_id: string - } - query?: never - url: '/apps/{app_id}/advanced-chat/workflows/draft/run' -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftRunErrors = { - 400: unknown - 403: unknown -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdAdvancedChatWorkflowsDraftRunResponse - = PostAppsByAppIdAdvancedChatWorkflowsDraftRunResponses[keyof PostAppsByAppIdAdvancedChatWorkflowsDraftRunResponses] - export type GetAppsByAppIdAgentDriveFilesData = { body?: never path: { @@ -3831,27 +3681,6 @@ export type GetAppsByAppIdCompletionConversationsByConversationIdResponses = { export type GetAppsByAppIdCompletionConversationsByConversationIdResponse = GetAppsByAppIdCompletionConversationsByConversationIdResponses[keyof GetAppsByAppIdCompletionConversationsByConversationIdResponses] -export type PostAppsByAppIdCompletionMessagesData = { - body: CompletionMessagePayload - path: { - app_id: string - } - query?: never - url: '/apps/{app_id}/completion-messages' -} - -export type PostAppsByAppIdCompletionMessagesErrors = { - 400: unknown - 404: unknown -} - -export type PostAppsByAppIdCompletionMessagesResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdCompletionMessagesResponse - = PostAppsByAppIdCompletionMessagesResponses[keyof PostAppsByAppIdCompletionMessagesResponses] - export type PostAppsByAppIdCompletionMessagesByTaskIdStopData = { body?: never path: { @@ -5114,45 +4943,6 @@ export type GetAppsByAppIdWorkflowsResponses = { export type GetAppsByAppIdWorkflowsResponse = GetAppsByAppIdWorkflowsResponses[keyof GetAppsByAppIdWorkflowsResponses] -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsData = { - body?: never - path: { - app_id: string - } - query?: never - url: '/apps/{app_id}/workflows/default-workflow-block-configs' -} - -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponses = { - 200: DefaultBlockConfigsResponse -} - -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponse - = GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponses[keyof GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponses] - -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeData = { - body?: never - path: { - app_id: string - block_type: string - } - query?: { - q?: string - } - url: '/apps/{app_id}/workflows/default-workflow-block-configs/{block_type}' -} - -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeErrors = { - 404: unknown -} - -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponses = { - 200: DefaultBlockConfigResponse -} - -export type GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse - = GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponses[keyof GetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponses] - export type GetAppsByAppIdWorkflowsDraftData = { body?: never path: { @@ -5293,7 +5083,7 @@ export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdDeliveryTestData } export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdDeliveryTestResponses = { - 200: EmptyObjectResponse + 200: HumanInputDeliveryTestResponse } export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdDeliveryTestResponse @@ -5316,67 +5106,6 @@ export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewRespo export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse = PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponses[keyof PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponses] -export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunData = { - body: HumanInputFormSubmitPayload - path: { - app_id: string - node_id: string - } - query?: never - url: '/apps/{app_id}/workflows/draft/human-input/nodes/{node_id}/form/run' -} - -export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponses = { - 200: HumanInputFormSubmitResponse -} - -export type PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse - = PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponses[keyof PostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponses] - -export type PostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunData = { - body: IterationNodeRunPayload - path: { - app_id: string - node_id: string - } - query?: never - url: '/apps/{app_id}/workflows/draft/iteration/nodes/{node_id}/run' -} - -export type PostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunErrors = { - 403: unknown - 404: unknown -} - -export type PostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponse - = PostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponses[keyof PostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponses] - -export type PostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunData = { - body: LoopNodeRunPayload - path: { - app_id: string - node_id: string - } - query?: never - url: '/apps/{app_id}/workflows/draft/loop/nodes/{node_id}/run' -} - -export type PostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunErrors = { - 403: unknown - 404: unknown -} - -export type PostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponse - = PostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponses[keyof PostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponses] - export type GetAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerData = { body?: never path: { @@ -5556,7 +5285,7 @@ export type PostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunErrors = { } export type PostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunResponses = { - 200: GeneratedAppResponse + 200: WorkflowRunNodeExecutionResponse } export type PostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunResponse @@ -5596,26 +5325,6 @@ export type GetAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesResponses = { export type GetAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesResponse = GetAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesResponses[keyof GetAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesResponses] -export type PostAppsByAppIdWorkflowsDraftRunData = { - body: DraftWorkflowRunPayload - path: { - app_id: string - } - query?: never - url: '/apps/{app_id}/workflows/draft/run' -} - -export type PostAppsByAppIdWorkflowsDraftRunErrors = { - 403: unknown -} - -export type PostAppsByAppIdWorkflowsDraftRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdWorkflowsDraftRunResponse - = PostAppsByAppIdWorkflowsDraftRunResponses[keyof PostAppsByAppIdWorkflowsDraftRunResponses] - export type GetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsData = { body?: never path: { @@ -5720,48 +5429,6 @@ export type GetAppsByAppIdWorkflowsDraftSystemVariablesResponses = { export type GetAppsByAppIdWorkflowsDraftSystemVariablesResponse = GetAppsByAppIdWorkflowsDraftSystemVariablesResponses[keyof GetAppsByAppIdWorkflowsDraftSystemVariablesResponses] -export type PostAppsByAppIdWorkflowsDraftTriggerRunData = { - body: DraftWorkflowTriggerRunRequest - path: { - app_id: string - } - query?: never - url: '/apps/{app_id}/workflows/draft/trigger/run' -} - -export type PostAppsByAppIdWorkflowsDraftTriggerRunErrors = { - 403: unknown - 500: unknown -} - -export type PostAppsByAppIdWorkflowsDraftTriggerRunResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdWorkflowsDraftTriggerRunResponse - = PostAppsByAppIdWorkflowsDraftTriggerRunResponses[keyof PostAppsByAppIdWorkflowsDraftTriggerRunResponses] - -export type PostAppsByAppIdWorkflowsDraftTriggerRunAllData = { - body: DraftWorkflowTriggerRunAllPayload - path: { - app_id: string - } - query?: never - url: '/apps/{app_id}/workflows/draft/trigger/run-all' -} - -export type PostAppsByAppIdWorkflowsDraftTriggerRunAllErrors = { - 403: unknown - 500: unknown -} - -export type PostAppsByAppIdWorkflowsDraftTriggerRunAllResponses = { - 200: GeneratedAppResponse -} - -export type PostAppsByAppIdWorkflowsDraftTriggerRunAllResponse - = PostAppsByAppIdWorkflowsDraftTriggerRunAllResponses[keyof PostAppsByAppIdWorkflowsDraftTriggerRunAllResponses] - export type DeleteAppsByAppIdWorkflowsDraftVariablesData = { body?: never path: { @@ -5908,7 +5575,7 @@ export type PostAppsByAppIdWorkflowsPublishData = { } export type PostAppsByAppIdWorkflowsPublishResponses = { - 200: WorkflowPublishResponse + 200: PublishWorkflowResponse } export type PostAppsByAppIdWorkflowsPublishResponse @@ -6077,7 +5744,7 @@ export type PostAppsByAppIdWorkflowsByWorkflowIdRestoreErrors = { } export type PostAppsByAppIdWorkflowsByWorkflowIdRestoreResponses = { - 200: WorkflowRestoreResponse + 200: SyncDraftWorkflowResponse } export type PostAppsByAppIdWorkflowsByWorkflowIdRestoreResponse diff --git a/packages/contracts/generated/api/console/apps/zod.gen.ts b/packages/contracts/generated/api/console/apps/zod.gen.ts index 9b86fda0a62..37910f4a4df 100644 --- a/packages/contracts/generated/api/console/apps/zod.gen.ts +++ b/packages/contracts/generated/api/console/apps/zod.gen.ts @@ -43,61 +43,6 @@ export const zHumanInputFormPreviewPayload = z.object({ inputs: z.record(z.string(), z.unknown()).optional(), }) -/** - * HumanInputFormPreviewResponse - */ -export const zHumanInputFormPreviewResponse = z.object({ - actions: z.array(z.record(z.string(), z.unknown())).optional(), - display_in_ui: z.boolean().nullish(), - expiration_time: z.int().nullish(), - form_content: z.string(), - form_id: z.string(), - form_token: z.string().nullish(), - inputs: z.array(z.record(z.string(), z.unknown())).optional(), - node_id: z.string(), - node_title: z.string(), - resolved_default_values: z.record(z.string(), z.unknown()).optional(), -}) - -/** - * HumanInputFormSubmitPayload - */ -export const zHumanInputFormSubmitPayload = z.object({ - action: z.string(), - form_inputs: z.record(z.string(), z.unknown()), - inputs: z.record(z.string(), z.unknown()), -}) - -/** - * HumanInputFormSubmitResponse - */ -export const zHumanInputFormSubmitResponse = z.record(z.string(), z.unknown()) - -/** - * IterationNodeRunPayload - */ -export const zIterationNodeRunPayload = z.object({ - inputs: z.record(z.string(), z.unknown()).nullish(), -}) - -/** - * LoopNodeRunPayload - */ -export const zLoopNodeRunPayload = z.object({ - inputs: z.record(z.string(), z.unknown()).nullish(), -}) - -/** - * AdvancedChatWorkflowRunPayload - */ -export const zAdvancedChatWorkflowRunPayload = z.object({ - conversation_id: z.string().nullish(), - files: z.array(z.record(z.string(), z.unknown())).nullish(), - inputs: z.record(z.string(), z.unknown()).nullish(), - parent_message_id: z.string().nullish(), - query: z.string().optional().default(''), -}) - /** * AgentDriveDownloadResponse */ @@ -242,18 +187,6 @@ export const zSimpleResultResponse = z.object({ result: z.string(), }) -/** - * CompletionMessagePayload - */ -export const zCompletionMessagePayload = z.object({ - files: z.array(z.unknown()).nullish(), - inputs: z.record(z.string(), z.unknown()), - model_config: z.record(z.string(), z.unknown()).optional(), - query: z.string().optional().default(''), - response_mode: z.enum(['blocking', 'streaming']).optional().default('blocking'), - retriever_from: z.string().optional().default('dev'), -}) - /** * ConvertToWorkflowPayload */ @@ -581,16 +514,6 @@ export const zWorkflowCommentResolve = z.object({ resolved_by: z.string().nullish(), }) -/** - * DefaultBlockConfigsResponse - */ -export const zDefaultBlockConfigsResponse = z.array(z.record(z.string(), z.unknown())) - -/** - * DefaultBlockConfigResponse - */ -export const zDefaultBlockConfigResponse = z.record(z.string(), z.unknown()) - /** * SyncDraftWorkflowPayload */ @@ -602,10 +525,13 @@ export const zSyncDraftWorkflowPayload = z.object({ hash: z.string().nullish(), }) +/** + * SyncDraftWorkflowResponse + */ export const zSyncDraftWorkflowResponse = z.object({ - hash: z.string().optional(), - result: z.string().optional(), - updated_at: z.string().optional(), + hash: z.string(), + result: z.string(), + updated_at: z.int(), }) /** @@ -638,9 +564,9 @@ export const zHumanInputDeliveryTestPayload = z.object({ }) /** - * EmptyObjectResponse + * HumanInputDeliveryTestResponse */ -export const zEmptyObjectResponse = z.record(z.string(), z.unknown()) +export const zHumanInputDeliveryTestResponse = z.record(z.string(), z.unknown()) /** * WorkflowComposerCopyFromRosterPayload @@ -660,32 +586,11 @@ export const zDraftWorkflowNodeRunPayload = z.object({ query: z.string().optional().default(''), }) -/** - * DraftWorkflowRunPayload - */ -export const zDraftWorkflowRunPayload = z.object({ - datasource_info_list: z.array(z.record(z.string(), z.unknown())), - datasource_type: z.string(), - inputs: z.record(z.string(), z.unknown()), - start_node_id: z.string(), -}) - /** * EventStreamResponse */ export const zEventStreamResponse = z.string() -export const zDraftWorkflowTriggerRunRequest = z.object({ - node_id: z.string(), -}) - -/** - * DraftWorkflowTriggerRunAllPayload - */ -export const zDraftWorkflowTriggerRunAllPayload = z.object({ - node_ids: z.array(z.string()), -}) - export const zWorkflowDraftVariable = z.object({ description: z.string().optional(), edited: z.boolean().optional(), @@ -723,17 +628,16 @@ export const zWorkflowDraftVariableUpdatePayload = z.object({ /** * PublishWorkflowPayload - * - * Payload for publishing snippet workflow. */ export const zPublishWorkflowPayload = z.object({ - knowledge_base_setting: z.record(z.string(), z.unknown()).nullish(), + marked_comment: z.string().max(100).nullish(), + marked_name: z.string().max(20).nullish(), }) /** - * WorkflowPublishResponse + * PublishWorkflowResponse */ -export const zWorkflowPublishResponse = z.object({ +export const zPublishWorkflowResponse = z.object({ created_at: z.int(), result: z.string(), }) @@ -758,15 +662,6 @@ export const zWorkflowUpdatePayload = z.object({ marked_name: z.string().max(20).nullish(), }) -/** - * WorkflowRestoreResponse - */ -export const zWorkflowRestoreResponse = z.object({ - hash: z.string(), - result: z.string(), - updated_at: z.int(), -}) - /** * ApiKeyItem */ @@ -873,21 +768,37 @@ export const zTag = z.object({ type: z.string(), }) -export const zJsonValue = z - .union([ - z.string(), - z.int(), - z.number(), - z.boolean(), - z.record(z.string(), z.unknown()), - z.array(z.unknown()), - ]) - .nullable() +export const zJsonValue = z.unknown() /** - * GeneratedAppResponse + * ModelConfig */ -export const zGeneratedAppResponse = zJsonValue +export const zModelConfig = z.object({ + agent_mode: zJsonValue.nullish(), + annotation_reply: zJsonValue.nullish(), + chat_prompt_config: zJsonValue.nullish(), + completion_prompt_config: zJsonValue.nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + dataset_configs: zJsonValue.nullish(), + dataset_query_variable: z.string().nullish(), + external_data_tools: zJsonValue.nullish(), + file_upload: zJsonValue.nullish(), + model: zJsonValue.nullish(), + more_like_this: zJsonValue.nullish(), + opening_statement: z.string().nullish(), + pre_prompt: z.string().nullish(), + prompt_type: z.string().nullish(), + retriever_resource: zJsonValue.nullish(), + sensitive_word_avoidance: zJsonValue.nullish(), + speech_to_text: zJsonValue.nullish(), + suggested_questions: zJsonValue.nullish(), + suggested_questions_after_answer: zJsonValue.nullish(), + text_to_speech: zJsonValue.nullish(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + user_input_form: zJsonValue.nullish(), +}) /** * WorkflowPartial @@ -900,6 +811,66 @@ export const zWorkflowPartial = z.object({ updated_by: z.string().nullish(), }) +/** + * AppDetailWithSite + */ +export const zAppDetailWithSite = z.object({ + access_mode: z.string().nullish(), + api_base_url: z.string().nullish(), + app_id: z.string().nullish(), + bound_agent_id: z.string().nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + deleted_tools: z.array(zDeletedTool).optional(), + description: z.string().nullish(), + enable_api: z.boolean(), + enable_site: z.boolean(), + icon: z.string().nullish(), + icon_background: z.string().nullish(), + icon_type: z.string().nullish(), + icon_url: z.string().nullable(), + id: z.string(), + maintainer: z.string().nullish(), + max_active_requests: z.int().nullish(), + mode: z.string(), + model_config: zModelConfig.nullish(), + name: z.string(), + permission_keys: z.array(z.string()).optional(), + site: zSite.nullish(), + tags: z.array(zTag).optional(), + tracing: zJsonValue.nullish(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + use_icon_as_answer_icon: z.boolean().nullish(), + workflow: zWorkflowPartial.nullish(), +}) + +/** + * AppDetail + */ +export const zAppDetail = z.object({ + access_mode: z.string().nullish(), + app_model_config: zModelConfig.nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + description: z.string().nullish(), + enable_api: z.boolean(), + enable_site: z.boolean(), + icon: z.string().nullish(), + icon_background: z.string().nullish(), + id: z.string(), + maintainer: z.string().nullish(), + mode_compatible_with_agent: z.string(), + name: z.string(), + permission_keys: z.array(z.string()).optional(), + tags: z.array(zTag).optional(), + tracing: zJsonValue.nullish(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + use_icon_as_answer_icon: z.boolean().nullish(), + workflow: zWorkflowPartial.nullish(), +}) + /** * ImportStatus */ @@ -919,6 +890,32 @@ export const zImport = z.object({ status: zImportStatus, }) +/** + * HumanInputUserActionResponse + */ +export const zHumanInputUserActionResponse = z.object({ + button_style: z.string().optional().default('default'), + id: z.string(), + title: z.string(), +}) + +/** + * HumanInputFormPreviewResponse + */ +export const zHumanInputFormPreviewResponse = z.object({ + TYPE: z.literal('human_input_required').optional().default('human_input_required'), + actions: z.array(zHumanInputUserActionResponse).optional(), + display_in_ui: z.boolean().optional().default(false), + expiration_time: z.int().nullish(), + form_content: z.string(), + form_id: z.string(), + form_token: z.string().nullish(), + inputs: z.array(z.record(z.string(), z.unknown())).optional(), + node_id: z.string(), + node_title: z.string(), + resolved_default_values: z.record(z.string(), z.unknown()).optional(), +}) + /** * AgentDriveItemResponse */ @@ -1118,6 +1115,25 @@ export const zFeedbackStat = z.object({ like: z.int(), }) +/** + * ConversationDetail + */ +export const zConversationDetail = z.object({ + admin_feedback_stats: zFeedbackStat.nullish(), + annotated: z.boolean(), + created_at: z.int().nullish(), + from_account_id: z.string().nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + id: z.string(), + introduction: z.string().nullish(), + message_count: z.int(), + model_config: zModelConfig.nullish(), + status: z.string(), + updated_at: z.int().nullish(), + user_feedback_stats: zFeedbackStat.nullish(), +}) + /** * ConversationVariableResponse */ @@ -1150,7 +1166,6 @@ export const zAgentThought = z.object({ created_at: z.int().nullish(), files: z.array(z.string()), id: z.string(), - message_chain_id: z.string().nullish(), message_id: z.string(), observation: z.string().nullish(), position: z.int(), @@ -1319,9 +1334,9 @@ export const zUserSatisfactionRateStatisticResponse = z.object({ }) /** - * SimpleAccount + * SimpleAccountResponse */ -export const zSimpleAccount = z.object({ +export const zSimpleAccountResponse = z.object({ email: z.string(), id: z.string(), name: z.string(), @@ -1333,7 +1348,7 @@ export const zSimpleAccount = z.object({ export const zAdvancedChatWorkflowRunForListResponse = z.object({ conversation_id: z.string().nullish(), created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), elapsed_time: z.number().nullish(), exceptions_count: z.int().nullish(), finished_at: z.int().nullish(), @@ -1355,72 +1370,12 @@ export const zAdvancedChatWorkflowRunPaginationResponse = z.object({ limit: z.int(), }) -/** - * ConversationAnnotation - */ -export const zConversationAnnotation = z.object({ - account: zSimpleAccount.nullish(), - content: z.string(), - created_at: z.int().nullish(), - id: z.string(), - question: z.string().nullish(), -}) - -/** - * ConversationAnnotationHitHistory - */ -export const zConversationAnnotationHitHistory = z.object({ - annotation_create_account: zSimpleAccount.nullish(), - created_at: z.int().nullish(), - id: z.string(), -}) - -/** - * Feedback - */ -export const zFeedback = z.object({ - content: z.string().nullish(), - from_account: zSimpleAccount.nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - rating: z.string(), -}) - -/** - * MessageDetail - */ -export const zMessageDetail = z.object({ - agent_thoughts: z.array(zAgentThought), - annotation: zConversationAnnotation.nullish(), - annotation_hit_history: zConversationAnnotationHitHistory.nullish(), - answer_tokens: z.int(), - conversation_id: z.string(), - created_at: z.int().nullish(), - error: z.string().nullish(), - feedbacks: z.array(zFeedback), - from_account_id: z.string().nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - id: z.string(), - inputs: z.record(z.string(), zJsonValue), - message: zJsonValue, - message_files: z.array(zMessageFile), - message_metadata_dict: zJsonValue, - message_tokens: z.int(), - parent_message_id: z.string().nullish(), - provider_response_latency: z.number(), - query: z.string(), - re_sign_file_url_answer: z.string(), - status: z.string(), - workflow_run_id: z.string().nullish(), -}) - /** * WorkflowRunForListResponse */ export const zWorkflowRunForListResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), elapsed_time: z.number().nullish(), exceptions_count: z.int().nullish(), finished_at: z.int().nullish(), @@ -1456,7 +1411,7 @@ export const zSimpleEndUser = z.object({ */ export const zWorkflowRunDetailResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -1478,7 +1433,7 @@ export const zWorkflowRunDetailResponse = z.object({ */ export const zWorkflowRunNodeExecutionResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -1544,9 +1499,9 @@ export const zSandboxUploadResponse = z.object({ }) /** - * AccountWithRole + * AccountWithRoleResponse */ -export const zAccountWithRole = z.object({ +export const zAccountWithRoleResponse = z.object({ avatar: z.string().nullish(), created_at: z.int().nullish(), email: z.string(), @@ -1563,7 +1518,7 @@ export const zAccountWithRole = z.object({ * WorkflowCommentMentionUsersPayload */ export const zWorkflowCommentMentionUsersPayload = z.object({ - users: z.array(zAccountWithRole), + users: z.array(zAccountWithRoleResponse), }) /** @@ -1752,7 +1707,7 @@ export const zPipelineVariableResponse = z.object({ export const zWorkflowResponse = z.object({ conversation_variables: z.array(zWorkflowConversationVariableResponse), created_at: z.int(), - created_by: zSimpleAccount.nullish(), + created_by: zSimpleAccountResponse.nullish(), environment_variables: z.array(zWorkflowEnvironmentVariableResponse), features: z.record(z.string(), z.unknown()), graph: z.record(z.string(), z.unknown()), @@ -1763,7 +1718,7 @@ export const zWorkflowResponse = z.object({ rag_pipeline_variables: z.array(zPipelineVariableResponse), tool_published: z.boolean(), updated_at: z.int(), - updated_by: zSimpleAccount.nullish(), + updated_by: zSimpleAccountResponse.nullish(), version: z.string(), }) @@ -2056,116 +2011,6 @@ export const zAppPagination = z.object({ total: z.int(), }) -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) - -/** - * ModelConfig - */ -export const zModelConfig = z.object({ - completion_params: z.record(z.string(), z.unknown()).optional(), - mode: zLlmMode, - name: z.string(), - provider: z.string(), -}) - -/** - * AppDetailWithSite - */ -export const zAppDetailWithSite = z.object({ - access_mode: z.string().nullish(), - api_base_url: z.string().nullish(), - app_id: z.string().nullish(), - bound_agent_id: z.string().nullish(), - created_at: z.int().nullish(), - created_by: z.string().nullish(), - deleted_tools: z.array(zDeletedTool).optional(), - description: z.string().nullish(), - enable_api: z.boolean(), - enable_site: z.boolean(), - icon: z.string().nullish(), - icon_background: z.string().nullish(), - icon_type: z.string().nullish(), - icon_url: z.string().nullable(), - id: z.string(), - maintainer: z.string().nullish(), - max_active_requests: z.int().nullish(), - mode: z.string(), - model_config: zModelConfig.nullish(), - name: z.string(), - permission_keys: z.array(z.string()).optional(), - site: zSite.nullish(), - tags: z.array(zTag).optional(), - tracing: zJsonValue.nullish(), - updated_at: z.int().nullish(), - updated_by: z.string().nullish(), - use_icon_as_answer_icon: z.boolean().nullish(), - workflow: zWorkflowPartial.nullish(), -}) - -/** - * AppDetail - */ -export const zAppDetail = z.object({ - access_mode: z.string().nullish(), - app_model_config: zModelConfig.nullish(), - created_at: z.int().nullish(), - created_by: z.string().nullish(), - description: z.string().nullish(), - enable_api: z.boolean(), - enable_site: z.boolean(), - icon: z.string().nullish(), - icon_background: z.string().nullish(), - id: z.string(), - maintainer: z.string().nullish(), - mode_compatible_with_agent: z.string(), - name: z.string(), - permission_keys: z.array(z.string()).optional(), - tags: z.array(zTag).optional(), - tracing: zJsonValue.nullish(), - updated_at: z.int().nullish(), - updated_by: z.string().nullish(), - use_icon_as_answer_icon: z.boolean().nullish(), - workflow: zWorkflowPartial.nullish(), -}) - -/** - * ConversationDetail - */ -export const zConversationDetail = z.object({ - admin_feedback_stats: zFeedbackStat.nullish(), - annotated: z.boolean(), - created_at: z.int().nullish(), - from_account_id: z.string().nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - id: z.string(), - introduction: z.string().nullish(), - message_count: z.int(), - model_config: zModelConfig.nullish(), - status: z.string(), - updated_at: z.int().nullish(), - user_feedback_stats: zFeedbackStat.nullish(), -}) - -/** - * ConversationMessageDetail - */ -export const zConversationMessageDetail = z.object({ - created_at: z.int().nullish(), - first_message: zMessageDetail.nullish(), - from_account_id: z.string().nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - id: z.string(), - model_config: zModelConfig.nullish(), - status: z.string(), -}) - /** * Type */ @@ -2366,6 +2211,26 @@ export const zSimpleMessageDetail = z.object({ query: z.string(), }) +/** + * SimpleAccount + */ +export const zSimpleAccount = z.object({ + email: z.string(), + id: z.string(), + name: z.string(), +}) + +/** + * ConversationAnnotation + */ +export const zConversationAnnotation = z.object({ + account: zSimpleAccount.nullish(), + content: z.string(), + created_at: z.int().nullish(), + id: z.string(), + question: z.string().nullish(), +}) + /** * Conversation */ @@ -2398,6 +2263,69 @@ export const zConversationPagination = z.object({ total: z.int(), }) +/** + * ConversationAnnotationHitHistory + */ +export const zConversationAnnotationHitHistory = z.object({ + annotation_create_account: zSimpleAccount.nullish(), + annotation_id: z.string(), + created_at: z.int().nullish(), +}) + +/** + * Feedback + */ +export const zFeedback = z.object({ + content: z.string().nullish(), + from_account: zSimpleAccount.nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + rating: z.string(), +}) + +/** + * MessageDetail + */ +export const zMessageDetail = z.object({ + agent_thoughts: z.array(zAgentThought), + annotation: zConversationAnnotation.nullish(), + annotation_hit_history: zConversationAnnotationHitHistory.nullish(), + answer_tokens: z.int(), + conversation_id: z.string(), + created_at: z.int().nullish(), + error: z.string().nullish(), + feedbacks: z.array(zFeedback), + from_account_id: z.string().nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + id: z.string(), + inputs: z.record(z.string(), zJsonValue), + message: zJsonValue, + message_files: z.array(zMessageFile), + message_metadata_dict: zJsonValue, + message_tokens: z.int(), + parent_message_id: z.string().nullish(), + provider_response_latency: z.number(), + query: z.string(), + re_sign_file_url_answer: z.string(), + status: z.string(), + workflow_run_id: z.string().nullish(), +}) + +/** + * ConversationMessageDetail + */ +export const zConversationMessageDetail = z.object({ + created_at: z.int().nullish(), + first_message: zMessageDetail.nullish(), + from_account_id: z.string().nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + id: z.string(), + model_config: zModelConfig.nullish(), + status: z.string(), +}) + /** * ExecutionContentType */ @@ -2425,7 +2353,7 @@ export const zWorkflowRunForLogResponse = z.object({ */ export const zWorkflowAppLogPartialResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), created_from: z.string().nullish(), @@ -2461,7 +2389,7 @@ export const zWorkflowRunForArchivedLogResponse = z.object({ */ export const zWorkflowArchivedLogPartialResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), id: z.string(), trigger_metadata: z.unknown().optional(), @@ -3455,6 +3383,7 @@ export const zMessageDetailResponse = z.object({ agent_thoughts: z.array(zAgentThought).optional(), annotation: zConversationAnnotation.nullish(), annotation_hit_history: zConversationAnnotationHitHistory.nullish(), + answer: z.string(), answer_tokens: z.int().nullish(), conversation_id: z.string(), created_at: z.int().nullish(), @@ -3468,12 +3397,11 @@ export const zMessageDetailResponse = z.object({ inputs: z.record(z.string(), zJsonValue), message: zJsonValue.nullish(), message_files: z.array(zMessageFile).optional(), - message_metadata_dict: zJsonValue.nullish(), message_tokens: z.int().nullish(), + metadata: zJsonValue.nullish(), parent_message_id: z.string().nullish(), provider_response_latency: z.number().nullish(), query: z.string(), - re_sign_file_url_answer: z.string(), status: z.string(), workflow_run_id: z.string().nullish(), }) @@ -3488,9 +3416,9 @@ export const zMessageInfiniteScrollPaginationResponse = z.object({ }) /** - * GeneratedAppResponse + * HumanInputDeliveryTestResponse */ -export const zGeneratedAppResponseWritable = zJsonValue +export const zHumanInputDeliveryTestResponseWritable = z.record(z.string(), z.unknown()) /** * AppPartial @@ -3835,65 +3763,11 @@ export const zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFo }) /** - * Human input form preview + * Human input form preview retrieved */ export const zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse = zHumanInputFormPreviewResponse -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunBody - = zHumanInputFormSubmitPayload - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunPath - = z.object({ - app_id: z.uuid(), - node_id: z.string(), - }) - -/** - * Human input form submission result - */ -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse - = zHumanInputFormSubmitResponse - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunBody - = zIterationNodeRunPayload - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunPath = z.object({ - app_id: z.uuid(), - node_id: z.string(), -}) - -/** - * Iteration node run started successfully - */ -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftIterationNodesByNodeIdRunResponse - = zGeneratedAppResponse - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunBody - = zLoopNodeRunPayload - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunPath = z.object({ - app_id: z.uuid(), - node_id: z.string(), -}) - -/** - * Loop node run started successfully - */ -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftLoopNodesByNodeIdRunResponse - = zGeneratedAppResponse - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftRunBody = zAdvancedChatWorkflowRunPayload - -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftRunPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Workflow run started successfully - */ -export const zPostAppsByAppIdAdvancedChatWorkflowsDraftRunResponse = zGeneratedAppResponse - export const zGetAppsByAppIdAgentDriveFilesPath = z.object({ app_id: z.uuid(), }) @@ -4345,17 +4219,6 @@ export const zGetAppsByAppIdCompletionConversationsByConversationIdPath = z.obje export const zGetAppsByAppIdCompletionConversationsByConversationIdResponse = zConversationMessageDetail -export const zPostAppsByAppIdCompletionMessagesBody = zCompletionMessagePayload - -export const zPostAppsByAppIdCompletionMessagesPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Completion generated successfully - */ -export const zPostAppsByAppIdCompletionMessagesResponse = zGeneratedAppResponse - export const zPostAppsByAppIdCompletionMessagesByTaskIdStopPath = z.object({ app_id: z.uuid(), task_id: z.string(), @@ -5163,31 +5026,6 @@ export const zGetAppsByAppIdWorkflowsQuery = z.object({ */ export const zGetAppsByAppIdWorkflowsResponse = zWorkflowPaginationResponse -export const zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Default block configurations retrieved successfully - */ -export const zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponse - = zDefaultBlockConfigsResponse - -export const zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypePath = z.object({ - app_id: z.uuid(), - block_type: z.string(), -}) - -export const zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeQuery = z.object({ - q: z.string().optional(), -}) - -/** - * Default block configuration retrieved successfully - */ -export const zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse - = zDefaultBlockConfigResponse - export const zGetAppsByAppIdWorkflowsDraftPath = z.object({ app_id: z.uuid(), }) @@ -5271,10 +5109,10 @@ export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdDeliveryTestPa }) /** - * Human input delivery test result + * Human input delivery tested */ export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdDeliveryTestResponse - = zEmptyObjectResponse + = zHumanInputDeliveryTestResponse export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewBody = zHumanInputFormPreviewPayload @@ -5285,49 +5123,11 @@ export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewPat }) /** - * Human input form preview + * Human input form preview retrieved */ export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormPreviewResponse = zHumanInputFormPreviewResponse -export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunBody - = zHumanInputFormSubmitPayload - -export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunPath = z.object({ - app_id: z.uuid(), - node_id: z.string(), -}) - -/** - * Human input form submission result - */ -export const zPostAppsByAppIdWorkflowsDraftHumanInputNodesByNodeIdFormRunResponse - = zHumanInputFormSubmitResponse - -export const zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunBody = zIterationNodeRunPayload - -export const zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunPath = z.object({ - app_id: z.uuid(), - node_id: z.string(), -}) - -/** - * Workflow iteration node run started successfully - */ -export const zPostAppsByAppIdWorkflowsDraftIterationNodesByNodeIdRunResponse = zGeneratedAppResponse - -export const zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunBody = zLoopNodeRunPayload - -export const zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunPath = z.object({ - app_id: z.uuid(), - node_id: z.string(), -}) - -/** - * Workflow loop node run started successfully - */ -export const zPostAppsByAppIdWorkflowsDraftLoopNodesByNodeIdRunResponse = zGeneratedAppResponse - export const zGetAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerPath = z.object({ app_id: z.uuid(), node_id: z.string(), @@ -5451,7 +5251,8 @@ export const zPostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunPath = z.objec /** * Trigger event received and node executed successfully */ -export const zPostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunResponse = zGeneratedAppResponse +export const zPostAppsByAppIdWorkflowsDraftNodesByNodeIdTriggerRunResponse + = zWorkflowRunNodeExecutionResponse export const zDeleteAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesPath = z.object({ app_id: z.uuid(), @@ -5474,17 +5275,6 @@ export const zGetAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesPath = z.object( export const zGetAppsByAppIdWorkflowsDraftNodesByNodeIdVariablesResponse = zWorkflowDraftVariableList -export const zPostAppsByAppIdWorkflowsDraftRunBody = zDraftWorkflowRunPayload - -export const zPostAppsByAppIdWorkflowsDraftRunPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Draft workflow run started successfully - */ -export const zPostAppsByAppIdWorkflowsDraftRunResponse = zGeneratedAppResponse - export const zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsPath = z.object({ app_id: z.uuid(), run_id: z.uuid(), @@ -5540,28 +5330,6 @@ export const zGetAppsByAppIdWorkflowsDraftSystemVariablesPath = z.object({ */ export const zGetAppsByAppIdWorkflowsDraftSystemVariablesResponse = zWorkflowDraftVariableList -export const zPostAppsByAppIdWorkflowsDraftTriggerRunBody = zDraftWorkflowTriggerRunRequest - -export const zPostAppsByAppIdWorkflowsDraftTriggerRunPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Trigger event received and workflow executed successfully - */ -export const zPostAppsByAppIdWorkflowsDraftTriggerRunResponse = zGeneratedAppResponse - -export const zPostAppsByAppIdWorkflowsDraftTriggerRunAllBody = zDraftWorkflowTriggerRunAllPayload - -export const zPostAppsByAppIdWorkflowsDraftTriggerRunAllPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Workflow executed successfully - */ -export const zPostAppsByAppIdWorkflowsDraftTriggerRunAllResponse = zGeneratedAppResponse - export const zDeleteAppsByAppIdWorkflowsDraftVariablesPath = z.object({ app_id: z.uuid(), }) @@ -5646,7 +5414,7 @@ export const zPostAppsByAppIdWorkflowsPublishPath = z.object({ /** * Workflow published successfully */ -export const zPostAppsByAppIdWorkflowsPublishResponse = zWorkflowPublishResponse +export const zPostAppsByAppIdWorkflowsPublishResponse = zPublishWorkflowResponse export const zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsPath = z.object({ app_id: z.uuid(), @@ -5739,7 +5507,7 @@ export const zPostAppsByAppIdWorkflowsByWorkflowIdRestorePath = z.object({ /** * Workflow restored successfully */ -export const zPostAppsByAppIdWorkflowsByWorkflowIdRestoreResponse = zWorkflowRestoreResponse +export const zPostAppsByAppIdWorkflowsByWorkflowIdRestoreResponse = zSyncDraftWorkflowResponse export const zGetAppsByResourceIdApiKeysPath = z.object({ resource_id: z.uuid(), diff --git a/packages/contracts/generated/api/console/installed-apps/orpc.gen.ts b/packages/contracts/generated/api/console/installed-apps/orpc.gen.ts index 026f3bdf513..d144c852463 100644 --- a/packages/contracts/generated/api/console/installed-apps/orpc.gen.ts +++ b/packages/contracts/generated/api/console/installed-apps/orpc.gen.ts @@ -13,9 +13,6 @@ import { zGetInstalledAppsByInstalledAppIdConversationsPath, zGetInstalledAppsByInstalledAppIdConversationsQuery, zGetInstalledAppsByInstalledAppIdConversationsResponse, - zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisPath, - zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisQuery, - zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponse, zGetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsPath, zGetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsResponse, zGetInstalledAppsByInstalledAppIdMessagesPath, @@ -40,16 +37,10 @@ import { zPostInstalledAppsBody, zPostInstalledAppsByInstalledAppIdAudioToTextPath, zPostInstalledAppsByInstalledAppIdAudioToTextResponse, - zPostInstalledAppsByInstalledAppIdChatMessagesBody, zPostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopPath, zPostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponse, - zPostInstalledAppsByInstalledAppIdChatMessagesPath, - zPostInstalledAppsByInstalledAppIdChatMessagesResponse, - zPostInstalledAppsByInstalledAppIdCompletionMessagesBody, zPostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopPath, zPostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopResponse, - zPostInstalledAppsByInstalledAppIdCompletionMessagesPath, - zPostInstalledAppsByInstalledAppIdCompletionMessagesResponse, zPostInstalledAppsByInstalledAppIdConversationsByCIdNameBody, zPostInstalledAppsByInstalledAppIdConversationsByCIdNamePath, zPostInstalledAppsByInstalledAppIdConversationsByCIdNameResponse, @@ -62,9 +53,6 @@ import { zPostInstalledAppsByInstalledAppIdTextToAudioBody, zPostInstalledAppsByInstalledAppIdTextToAudioPath, zPostInstalledAppsByInstalledAppIdTextToAudioResponse, - zPostInstalledAppsByInstalledAppIdWorkflowsRunBody, - zPostInstalledAppsByInstalledAppIdWorkflowsRunPath, - zPostInstalledAppsByInstalledAppIdWorkflowsRunResponse, zPostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopPath, zPostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopResponse, zPostInstalledAppsResponse, @@ -104,28 +92,11 @@ export const byTaskId = { stop, } -export const post3 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postInstalledAppsByInstalledAppIdChatMessages', - path: '/installed-apps/{installed_app_id}/chat-messages', - tags: ['console'], - }) - .input( - z.object({ - body: zPostInstalledAppsByInstalledAppIdChatMessagesBody, - params: zPostInstalledAppsByInstalledAppIdChatMessagesPath, - }), - ) - .output(zPostInstalledAppsByInstalledAppIdChatMessagesResponse) - export const chatMessages = { - post: post3, byTaskId, } -export const post4 = oc +export const post3 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -137,35 +108,18 @@ export const post4 = oc .output(zPostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopResponse) export const stop2 = { - post: post4, + post: post3, } export const byTaskId2 = { stop: stop2, } -export const post5 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postInstalledAppsByInstalledAppIdCompletionMessages', - path: '/installed-apps/{installed_app_id}/completion-messages', - tags: ['console'], - }) - .input( - z.object({ - body: zPostInstalledAppsByInstalledAppIdCompletionMessagesBody, - params: zPostInstalledAppsByInstalledAppIdCompletionMessagesPath, - }), - ) - .output(zPostInstalledAppsByInstalledAppIdCompletionMessagesResponse) - export const completionMessages = { - post: post5, byTaskId: byTaskId2, } -export const post6 = oc +export const post4 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -182,7 +136,7 @@ export const post6 = oc .output(zPostInstalledAppsByInstalledAppIdConversationsByCIdNameResponse) export const name = { - post: post6, + post: post4, } export const patch = oc @@ -255,7 +209,7 @@ export const conversations = { byCId, } -export const post7 = oc +export const post5 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -272,30 +226,10 @@ export const post7 = oc .output(zPostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponse) export const feedbacks = { - post: post7, + post: post5, } export const get2 = oc - .route({ - inputStructure: 'detailed', - method: 'GET', - operationId: 'getInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThis', - path: '/installed-apps/{installed_app_id}/messages/{message_id}/more-like-this', - tags: ['console'], - }) - .input( - z.object({ - params: zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisPath, - query: zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisQuery, - }), - ) - .output(zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponse) - -export const moreLikeThis = { - get: get2, -} - -export const get3 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -311,16 +245,15 @@ export const get3 = oc .output(zGetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsResponse) export const suggestedQuestions = { - get: get3, + get: get2, } export const byMessageId = { feedbacks, - moreLikeThis, suggestedQuestions, } -export const get4 = oc +export const get3 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -337,14 +270,14 @@ export const get4 = oc .output(zGetInstalledAppsByInstalledAppIdMessagesResponse) export const messages = { - get: get4, + get: get3, byMessageId, } /** * Get app meta */ -export const get5 = oc +export const get4 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -357,13 +290,13 @@ export const get5 = oc .output(zGetInstalledAppsByInstalledAppIdMetaResponse) export const meta = { - get: get5, + get: get4, } /** * Retrieve app parameters */ -export const get6 = oc +export const get5 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -376,7 +309,7 @@ export const get6 = oc .output(zGetInstalledAppsByInstalledAppIdParametersResponse) export const parameters = { - get: get6, + get: get5, } export const delete2 = oc @@ -395,7 +328,7 @@ export const byMessageId2 = { delete: delete2, } -export const get7 = oc +export const get6 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -411,7 +344,7 @@ export const get7 = oc ) .output(zGetInstalledAppsByInstalledAppIdSavedMessagesResponse) -export const post8 = oc +export const post6 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -428,12 +361,12 @@ export const post8 = oc .output(zPostInstalledAppsByInstalledAppIdSavedMessagesResponse) export const savedMessages = { - get: get7, - post: post8, + get: get6, + post: post6, byMessageId: byMessageId2, } -export const post9 = oc +export const post7 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -450,37 +383,13 @@ export const post9 = oc .output(zPostInstalledAppsByInstalledAppIdTextToAudioResponse) export const textToAudio = { - post: post9, -} - -/** - * Run workflow - */ -export const post10 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postInstalledAppsByInstalledAppIdWorkflowsRun', - path: '/installed-apps/{installed_app_id}/workflows/run', - summary: 'Run workflow', - tags: ['console'], - }) - .input( - z.object({ - body: zPostInstalledAppsByInstalledAppIdWorkflowsRunBody, - params: zPostInstalledAppsByInstalledAppIdWorkflowsRunPath, - }), - ) - .output(zPostInstalledAppsByInstalledAppIdWorkflowsRunResponse) - -export const run = { - post: post10, + post: post7, } /** * Stop workflow task */ -export const post11 = oc +export const post8 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -493,7 +402,7 @@ export const post11 = oc .output(zPostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopResponse) export const stop3 = { - post: post11, + post: post8, } export const byTaskId3 = { @@ -505,7 +414,6 @@ export const tasks = { } export const workflows = { - run, tasks, } @@ -552,7 +460,7 @@ export const byInstalledAppId = { workflows, } -export const get8 = oc +export const get7 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -563,7 +471,7 @@ export const get8 = oc .input(z.object({ query: zGetInstalledAppsQuery.optional() })) .output(zGetInstalledAppsResponse) -export const post12 = oc +export const post9 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -575,8 +483,8 @@ export const post12 = oc .output(zPostInstalledAppsResponse) export const installedApps = { - get: get8, - post: post12, + get: get7, + post: post9, byInstalledAppId, } diff --git a/packages/contracts/generated/api/console/installed-apps/types.gen.ts b/packages/contracts/generated/api/console/installed-apps/types.gen.ts index f9a5eb01edc..a36b802a959 100644 --- a/packages/contracts/generated/api/console/installed-apps/types.gen.ts +++ b/packages/contracts/generated/api/console/installed-apps/types.gen.ts @@ -29,39 +29,10 @@ export type AudioTranscriptResponse = { text: string } -export type ChatMessagePayload = { - conversation_id?: string | null - files?: Array | null - inputs: { - [key: string]: unknown - } - model_config?: { - [key: string]: unknown - } - parent_message_id?: string | null - query: string - response_mode?: 'blocking' | 'streaming' - retriever_from?: string -} - -export type GeneratedAppResponse = JsonValue - export type SimpleResultResponse = { result: string } -export type CompletionMessageExplorePayload = { - files?: Array<{ - [key: string]: unknown - }> | null - inputs: { - [key: string]: unknown - } - query?: string - response_mode?: 'blocking' | 'streaming' | null - retriever_from?: string -} - export type ConversationInfiniteScrollPagination = { data: Array has_more: boolean @@ -154,18 +125,6 @@ export type TextToAudioPayload = { export type AudioBinaryResponse = Blob | File -export type WorkflowRunPayload = { - files?: Array<{ - transfer_method: 'local_file' | 'remote_url' - type: 'audio' | 'custom' | 'document' | 'image' | 'video' - upload_file_id?: string - url?: string - }> | null - inputs: { - [key: string]: unknown - } -} - export type InstalledAppResponse = { app: InstalledAppInfoResponse app_owner_tenant_id: string @@ -176,16 +135,7 @@ export type InstalledAppResponse = { uninstallable: boolean } -export type JsonValue - = | string - | number - | number - | boolean - | { - [key: string]: unknown - } - | Array - | null +export type JsonValue = unknown export type ExploreMessageListItem = { agent_thoughts: Array @@ -246,7 +196,6 @@ export type AgentThought = { created_at?: number | null files: Array id: string - message_chain_id?: string | null message_id: string observation?: string | null position: number @@ -477,22 +426,6 @@ export type PostInstalledAppsByInstalledAppIdAudioToTextResponses = { export type PostInstalledAppsByInstalledAppIdAudioToTextResponse = PostInstalledAppsByInstalledAppIdAudioToTextResponses[keyof PostInstalledAppsByInstalledAppIdAudioToTextResponses] -export type PostInstalledAppsByInstalledAppIdChatMessagesData = { - body: ChatMessagePayload - path: { - installed_app_id: string - } - query?: never - url: '/installed-apps/{installed_app_id}/chat-messages' -} - -export type PostInstalledAppsByInstalledAppIdChatMessagesResponses = { - 200: GeneratedAppResponse -} - -export type PostInstalledAppsByInstalledAppIdChatMessagesResponse - = PostInstalledAppsByInstalledAppIdChatMessagesResponses[keyof PostInstalledAppsByInstalledAppIdChatMessagesResponses] - export type PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopData = { body?: never path: { @@ -510,22 +443,6 @@ export type PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponses = export type PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponse = PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponses[keyof PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponses] -export type PostInstalledAppsByInstalledAppIdCompletionMessagesData = { - body: CompletionMessageExplorePayload - path: { - installed_app_id: string - } - query?: never - url: '/installed-apps/{installed_app_id}/completion-messages' -} - -export type PostInstalledAppsByInstalledAppIdCompletionMessagesResponses = { - 200: GeneratedAppResponse -} - -export type PostInstalledAppsByInstalledAppIdCompletionMessagesResponse - = PostInstalledAppsByInstalledAppIdCompletionMessagesResponses[keyof PostInstalledAppsByInstalledAppIdCompletionMessagesResponses] - export type PostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopData = { body?: never path: { @@ -668,25 +585,6 @@ export type PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksRespons export type PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponse = PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponses[keyof PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponses] -export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisData = { - body?: never - path: { - installed_app_id: string - message_id: string - } - query: { - response_mode: 'blocking' | 'streaming' - } - url: '/installed-apps/{installed_app_id}/messages/{message_id}/more-like-this' -} - -export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponses = { - 200: GeneratedAppResponse -} - -export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponse - = GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponses[keyof GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponses] - export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsData = { body?: never path: { @@ -804,22 +702,6 @@ export type PostInstalledAppsByInstalledAppIdTextToAudioResponses = { export type PostInstalledAppsByInstalledAppIdTextToAudioResponse = PostInstalledAppsByInstalledAppIdTextToAudioResponses[keyof PostInstalledAppsByInstalledAppIdTextToAudioResponses] -export type PostInstalledAppsByInstalledAppIdWorkflowsRunData = { - body: WorkflowRunPayload - path: { - installed_app_id: string - } - query?: never - url: '/installed-apps/{installed_app_id}/workflows/run' -} - -export type PostInstalledAppsByInstalledAppIdWorkflowsRunResponses = { - 200: GeneratedAppResponse -} - -export type PostInstalledAppsByInstalledAppIdWorkflowsRunResponse - = PostInstalledAppsByInstalledAppIdWorkflowsRunResponses[keyof PostInstalledAppsByInstalledAppIdWorkflowsRunResponses] - export type PostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopData = { body?: never path: { diff --git a/packages/contracts/generated/api/console/installed-apps/zod.gen.ts b/packages/contracts/generated/api/console/installed-apps/zod.gen.ts index a4556058506..7a8e37e1af8 100644 --- a/packages/contracts/generated/api/console/installed-apps/zod.gen.ts +++ b/packages/contracts/generated/api/console/installed-apps/zod.gen.ts @@ -38,20 +38,6 @@ export const zAudioTranscriptResponse = z.object({ text: z.string(), }) -/** - * ChatMessagePayload - */ -export const zChatMessagePayload = z.object({ - conversation_id: z.string().nullish(), - files: z.array(z.unknown()).nullish(), - inputs: z.record(z.string(), z.unknown()), - model_config: z.record(z.string(), z.unknown()).optional(), - parent_message_id: z.string().nullish(), - query: z.string(), - response_mode: z.enum(['blocking', 'streaming']).optional().default('blocking'), - retriever_from: z.string().optional().default('dev'), -}) - /** * SimpleResultResponse */ @@ -59,17 +45,6 @@ export const zSimpleResultResponse = z.object({ result: z.string(), }) -/** - * CompletionMessageExplorePayload - */ -export const zCompletionMessageExplorePayload = z.object({ - files: z.array(z.record(z.string(), z.unknown())).nullish(), - inputs: z.record(z.string(), z.unknown()), - query: z.string().optional().default(''), - response_mode: z.enum(['blocking', 'streaming']).nullish(), - retriever_from: z.string().optional().default('explore_app'), -}) - export const zConversationRenamePayload = z.intersection( z.union([ z.object({ @@ -139,38 +114,7 @@ export const zTextToAudioPayload = z.object({ */ export const zAudioBinaryResponse = z.custom() -/** - * WorkflowRunPayload - */ -export const zWorkflowRunPayload = z.object({ - files: z - .array( - z.object({ - transfer_method: z.enum(['local_file', 'remote_url']), - type: z.enum(['audio', 'custom', 'document', 'image', 'video']), - upload_file_id: z.string().optional(), - url: z.string().optional(), - }), - ) - .nullish(), - inputs: z.record(z.string(), z.unknown()), -}) - -export const zJsonValue = z - .union([ - z.string(), - z.int(), - z.number(), - z.boolean(), - z.record(z.string(), z.unknown()), - z.array(z.unknown()), - ]) - .nullable() - -/** - * GeneratedAppResponse - */ -export const zGeneratedAppResponse = zJsonValue +export const zJsonValue = z.unknown() /** * SimpleConversation @@ -266,7 +210,6 @@ export const zAgentThought = z.object({ created_at: z.int().nullish(), files: z.array(z.string()), id: z.string(), - message_chain_id: z.string().nullish(), message_id: z.string(), observation: z.string().nullish(), position: z.int(), @@ -577,17 +520,6 @@ export const zPostInstalledAppsByInstalledAppIdAudioToTextPath = z.object({ */ export const zPostInstalledAppsByInstalledAppIdAudioToTextResponse = zAudioTranscriptResponse -export const zPostInstalledAppsByInstalledAppIdChatMessagesBody = zChatMessagePayload - -export const zPostInstalledAppsByInstalledAppIdChatMessagesPath = z.object({ - installed_app_id: z.uuid(), -}) - -/** - * Success - */ -export const zPostInstalledAppsByInstalledAppIdChatMessagesResponse = zGeneratedAppResponse - export const zPostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopPath = z.object({ installed_app_id: z.uuid(), task_id: z.string(), @@ -599,18 +531,6 @@ export const zPostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopPath = z. export const zPostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponse = zSimpleResultResponse -export const zPostInstalledAppsByInstalledAppIdCompletionMessagesBody - = zCompletionMessageExplorePayload - -export const zPostInstalledAppsByInstalledAppIdCompletionMessagesPath = z.object({ - installed_app_id: z.uuid(), -}) - -/** - * Success - */ -export const zPostInstalledAppsByInstalledAppIdCompletionMessagesResponse = zGeneratedAppResponse - export const zPostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopPath = z.object({ installed_app_id: z.uuid(), task_id: z.string(), @@ -711,21 +631,6 @@ export const zPostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksPath export const zPostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponse = zResultResponse -export const zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisPath = z.object({ - installed_app_id: z.uuid(), - message_id: z.uuid(), -}) - -export const zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisQuery = z.object({ - response_mode: z.enum(['blocking', 'streaming']), -}) - -/** - * Success - */ -export const zGetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponse - = zGeneratedAppResponse - export const zGetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsPath = z.object({ installed_app_id: z.uuid(), message_id: z.uuid(), @@ -802,17 +707,6 @@ export const zPostInstalledAppsByInstalledAppIdTextToAudioPath = z.object({ */ export const zPostInstalledAppsByInstalledAppIdTextToAudioResponse = zAudioBinaryResponse -export const zPostInstalledAppsByInstalledAppIdWorkflowsRunBody = zWorkflowRunPayload - -export const zPostInstalledAppsByInstalledAppIdWorkflowsRunPath = z.object({ - installed_app_id: z.uuid(), -}) - -/** - * Success - */ -export const zPostInstalledAppsByInstalledAppIdWorkflowsRunResponse = zGeneratedAppResponse - export const zPostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopPath = z.object({ installed_app_id: z.uuid(), task_id: z.string(), diff --git a/packages/contracts/generated/api/console/instruction-generate/types.gen.ts b/packages/contracts/generated/api/console/instruction-generate/types.gen.ts index 82a9bee0864..cc08c229421 100644 --- a/packages/contracts/generated/api/console/instruction-generate/types.gen.ts +++ b/packages/contracts/generated/api/console/instruction-generate/types.gen.ts @@ -25,15 +25,33 @@ export type SimpleDataResponse = { } export type ModelConfig = { - completion_params?: { - [key: string]: unknown - } - mode: LlmMode - name: string - provider: string + agent_mode?: JsonValue | null + annotation_reply?: JsonValue | null + chat_prompt_config?: JsonValue | null + completion_prompt_config?: JsonValue | null + created_at?: number | null + created_by?: string | null + dataset_configs?: JsonValue | null + dataset_query_variable?: string | null + external_data_tools?: JsonValue | null + file_upload?: JsonValue | null + model?: JsonValue | null + more_like_this?: JsonValue | null + opening_statement?: string | null + pre_prompt?: string | null + prompt_type?: string | null + retriever_resource?: JsonValue | null + sensitive_word_avoidance?: JsonValue | null + speech_to_text?: JsonValue | null + suggested_questions?: JsonValue | null + suggested_questions_after_answer?: JsonValue | null + text_to_speech?: JsonValue | null + updated_at?: number | null + updated_by?: string | null + user_input_form?: JsonValue | null } -export type LlmMode = 'chat' | 'completion' +export type JsonValue = unknown export type PostInstructionGenerateData = { body: InstructionGeneratePayload diff --git a/packages/contracts/generated/api/console/instruction-generate/zod.gen.ts b/packages/contracts/generated/api/console/instruction-generate/zod.gen.ts index 2d89050e2a0..339f25d605d 100644 --- a/packages/contracts/generated/api/console/instruction-generate/zod.gen.ts +++ b/packages/contracts/generated/api/console/instruction-generate/zod.gen.ts @@ -21,21 +21,36 @@ export const zSimpleDataResponse = z.object({ data: z.string(), }) -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) +export const zJsonValue = z.unknown() /** * ModelConfig */ export const zModelConfig = z.object({ - completion_params: z.record(z.string(), z.unknown()).optional(), - mode: zLlmMode, - name: z.string(), - provider: z.string(), + agent_mode: zJsonValue.nullish(), + annotation_reply: zJsonValue.nullish(), + chat_prompt_config: zJsonValue.nullish(), + completion_prompt_config: zJsonValue.nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + dataset_configs: zJsonValue.nullish(), + dataset_query_variable: z.string().nullish(), + external_data_tools: zJsonValue.nullish(), + file_upload: zJsonValue.nullish(), + model: zJsonValue.nullish(), + more_like_this: zJsonValue.nullish(), + opening_statement: z.string().nullish(), + pre_prompt: z.string().nullish(), + prompt_type: z.string().nullish(), + retriever_resource: zJsonValue.nullish(), + sensitive_word_avoidance: zJsonValue.nullish(), + speech_to_text: zJsonValue.nullish(), + suggested_questions: zJsonValue.nullish(), + suggested_questions_after_answer: zJsonValue.nullish(), + text_to_speech: zJsonValue.nullish(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + user_input_form: zJsonValue.nullish(), }) /** diff --git a/packages/contracts/generated/api/console/rag/orpc.gen.ts b/packages/contracts/generated/api/console/rag/orpc.gen.ts index ea52e39d5f6..8d947e305f5 100644 --- a/packages/contracts/generated/api/console/rag/orpc.gen.ts +++ b/packages/contracts/generated/api/console/rag/orpc.gen.ts @@ -24,11 +24,6 @@ import { zGetRagPipelinesByPipelineIdWorkflowRunsPath, zGetRagPipelinesByPipelineIdWorkflowRunsQuery, zGetRagPipelinesByPipelineIdWorkflowRunsResponse, - zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypePath, - zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeQuery, - zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse, - zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsPath, - zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsResponse, zGetRagPipelinesByPipelineIdWorkflowsDraftEnvironmentVariablesPath, zGetRagPipelinesByPipelineIdWorkflowsDraftEnvironmentVariablesResponse, zGetRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdLastRunPath, @@ -93,35 +88,17 @@ import { zPostRagPipelinesByPipelineIdWorkflowsByWorkflowIdRestorePath, zPostRagPipelinesByPipelineIdWorkflowsByWorkflowIdRestoreResponse, zPostRagPipelinesByPipelineIdWorkflowsDraftBody, - zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRunBody, - zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRunPath, - zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRunResponse, zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceVariablesInspectBody, zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceVariablesInspectPath, zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceVariablesInspectResponse, - zPostRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRunBody, - zPostRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRunPath, - zPostRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRunResponse, - zPostRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRunBody, - zPostRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRunPath, - zPostRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRunResponse, zPostRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdRunBody, zPostRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdRunPath, zPostRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdRunResponse, zPostRagPipelinesByPipelineIdWorkflowsDraftPath, zPostRagPipelinesByPipelineIdWorkflowsDraftResponse, - zPostRagPipelinesByPipelineIdWorkflowsDraftRunBody, - zPostRagPipelinesByPipelineIdWorkflowsDraftRunPath, - zPostRagPipelinesByPipelineIdWorkflowsDraftRunResponse, zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewBody, zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewPath, zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewResponse, - zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunBody, - zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunPath, - zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunResponse, - zPostRagPipelinesByPipelineIdWorkflowsPublishedRunBody, - zPostRagPipelinesByPipelineIdWorkflowsPublishedRunPath, - zPostRagPipelinesByPipelineIdWorkflowsPublishedRunResponse, zPostRagPipelinesByPipelineIdWorkflowsPublishPath, zPostRagPipelinesByPipelineIdWorkflowsPublishResponse, zPostRagPipelinesImportsBody, @@ -506,87 +483,10 @@ export const workflowRuns = { byRunId, } -/** - * Get default block config - */ -export const get10 = oc - .route({ - inputStructure: 'detailed', - method: 'GET', - operationId: 'getRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockType', - path: '/rag/pipelines/{pipeline_id}/workflows/default-workflow-block-configs/{block_type}', - summary: 'Get default block config', - tags: ['console'], - }) - .input( - z.object({ - params: zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypePath, - query: - zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeQuery.optional(), - }), - ) - .output(zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse) - -export const byBlockType = { - get: get10, -} - -/** - * Get default block config - */ -export const get11 = oc - .route({ - inputStructure: 'detailed', - method: 'GET', - operationId: 'getRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigs', - path: '/rag/pipelines/{pipeline_id}/workflows/default-workflow-block-configs', - summary: 'Get default block config', - tags: ['console'], - }) - .input(z.object({ params: zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsPath })) - .output(zGetRagPipelinesByPipelineIdWorkflowsDefaultWorkflowBlockConfigsResponse) - -export const defaultWorkflowBlockConfigs = { - get: get11, - byBlockType, -} - -/** - * Run rag pipeline datasource - */ -export const post9 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRun', - path: '/rag/pipelines/{pipeline_id}/workflows/draft/datasource/nodes/{node_id}/run', - summary: 'Run rag pipeline datasource', - tags: ['console'], - }) - .input( - z.object({ - body: zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRunBody, - params: zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRunPath, - }), - ) - .output(zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceNodesByNodeIdRunResponse) - -export const run = { - post: post9, -} - -export const byNodeId = { - run, -} - -export const nodes = { - byNodeId, -} - /** * Set datasource variables */ -export const post10 = oc +export const post9 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -604,18 +504,17 @@ export const post10 = oc .output(zPostRagPipelinesByPipelineIdWorkflowsDraftDatasourceVariablesInspectResponse) export const variablesInspect = { - post: post10, + post: post9, } export const datasource = { - nodes, variablesInspect, } /** * Get draft workflow */ -export const get12 = oc +export const get10 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -628,82 +527,10 @@ export const get12 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsDraftEnvironmentVariablesResponse) export const environmentVariables = { - get: get12, + get: get10, } -/** - * Run draft workflow iteration node - */ -export const post11 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRun', - path: '/rag/pipelines/{pipeline_id}/workflows/draft/iteration/nodes/{node_id}/run', - summary: 'Run draft workflow iteration node', - tags: ['console'], - }) - .input( - z.object({ - body: zPostRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRunBody, - params: zPostRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRunPath, - }), - ) - .output(zPostRagPipelinesByPipelineIdWorkflowsDraftIterationNodesByNodeIdRunResponse) - -export const run2 = { - post: post11, -} - -export const byNodeId2 = { - run: run2, -} - -export const nodes2 = { - byNodeId: byNodeId2, -} - -export const iteration = { - nodes: nodes2, -} - -/** - * Run draft workflow loop node - */ -export const post12 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRun', - path: '/rag/pipelines/{pipeline_id}/workflows/draft/loop/nodes/{node_id}/run', - summary: 'Run draft workflow loop node', - tags: ['console'], - }) - .input( - z.object({ - body: zPostRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRunBody, - params: zPostRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRunPath, - }), - ) - .output(zPostRagPipelinesByPipelineIdWorkflowsDraftLoopNodesByNodeIdRunResponse) - -export const run3 = { - post: post12, -} - -export const byNodeId3 = { - run: run3, -} - -export const nodes3 = { - byNodeId: byNodeId3, -} - -export const loop = { - nodes: nodes3, -} - -export const get13 = oc +export const get11 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -715,13 +542,13 @@ export const get13 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdLastRunResponse) export const lastRun = { - get: get13, + get: get11, } /** * Run draft workflow node */ -export const post13 = oc +export const post10 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -738,8 +565,8 @@ export const post13 = oc ) .output(zPostRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdRunResponse) -export const run4 = { - post: post13, +export const run = { + post: post10, } export const delete2 = oc @@ -756,7 +583,7 @@ export const delete2 = oc ) .output(zDeleteRagPipelinesByPipelineIdWorkflowsDraftNodesByNodeIdVariablesResponse) -export const get14 = oc +export const get12 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -769,23 +596,23 @@ export const get14 = oc export const variables = { delete: delete2, - get: get14, + get: get12, } -export const byNodeId4 = { +export const byNodeId = { lastRun, - run: run4, + run, variables, } -export const nodes4 = { - byNodeId: byNodeId4, +export const nodes = { + byNodeId, } /** * Get first step parameters of rag pipeline */ -export const get15 = oc +export const get13 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -803,7 +630,7 @@ export const get15 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsDraftPreProcessingParametersResponse) export const parameters = { - get: get15, + get: get13, } export const preProcessing = { @@ -813,7 +640,7 @@ export const preProcessing = { /** * Get second step parameters of rag pipeline */ -export const get16 = oc +export const get14 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -831,38 +658,14 @@ export const get16 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsDraftProcessingParametersResponse) export const parameters2 = { - get: get16, + get: get14, } export const processing = { parameters: parameters2, } -/** - * Run draft workflow - */ -export const post14 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postRagPipelinesByPipelineIdWorkflowsDraftRun', - path: '/rag/pipelines/{pipeline_id}/workflows/draft/run', - summary: 'Run draft workflow', - tags: ['console'], - }) - .input( - z.object({ - body: zPostRagPipelinesByPipelineIdWorkflowsDraftRunBody, - params: zPostRagPipelinesByPipelineIdWorkflowsDraftRunPath, - }), - ) - .output(zPostRagPipelinesByPipelineIdWorkflowsDraftRunResponse) - -export const run5 = { - post: post14, -} - -export const get17 = oc +export const get15 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -874,7 +677,7 @@ export const get17 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsDraftSystemVariablesResponse) export const systemVariables = { - get: get17, + get: get15, } export const put = oc @@ -908,7 +711,7 @@ export const delete3 = oc ) .output(zDeleteRagPipelinesByPipelineIdWorkflowsDraftVariablesByVariableIdResponse) -export const get18 = oc +export const get16 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -937,7 +740,7 @@ export const patch2 = oc export const byVariableId = { delete: delete3, - get: get18, + get: get16, patch: patch2, reset, } @@ -957,7 +760,7 @@ export const delete4 = oc /** * Get draft workflow */ -export const get19 = oc +export const get17 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -976,14 +779,14 @@ export const get19 = oc export const variables2 = { delete: delete4, - get: get19, + get: get17, byVariableId, } /** * Get draft rag pipeline's workflow */ -export const get20 = oc +export const get18 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -998,7 +801,7 @@ export const get20 = oc /** * Sync draft workflow */ -export const post15 = oc +export const post11 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -1016,16 +819,13 @@ export const post15 = oc .output(zPostRagPipelinesByPipelineIdWorkflowsDraftResponse) export const draft = { - get: get20, - post: post15, + get: get18, + post: post11, datasource, environmentVariables, - iteration, - loop, - nodes: nodes4, + nodes, preProcessing, processing, - run: run5, systemVariables, variables: variables2, } @@ -1033,7 +833,7 @@ export const draft = { /** * Get published pipeline */ -export const get21 = oc +export const get19 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1048,7 +848,7 @@ export const get21 = oc /** * Publish workflow */ -export const post16 = oc +export const post12 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -1061,14 +861,14 @@ export const post16 = oc .output(zPostRagPipelinesByPipelineIdWorkflowsPublishResponse) export const publish2 = { - get: get21, - post: post16, + get: get19, + post: post12, } /** * Run datasource content preview */ -export const post17 = oc +export const post13 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -1086,50 +886,25 @@ export const post17 = oc .output(zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewResponse) export const preview = { - post: post17, + post: post13, } -/** - * Run rag pipeline datasource - */ -export const post18 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRun', - path: '/rag/pipelines/{pipeline_id}/workflows/published/datasource/nodes/{node_id}/run', - summary: 'Run rag pipeline datasource', - tags: ['console'], - }) - .input( - z.object({ - body: zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunBody, - params: zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunPath, - }), - ) - .output(zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunResponse) - -export const run6 = { - post: post18, -} - -export const byNodeId5 = { +export const byNodeId2 = { preview, - run: run6, } -export const nodes5 = { - byNodeId: byNodeId5, +export const nodes2 = { + byNodeId: byNodeId2, } export const datasource2 = { - nodes: nodes5, + nodes: nodes2, } /** * Get first step parameters of rag pipeline */ -export const get22 = oc +export const get20 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1147,7 +922,7 @@ export const get22 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsPublishedPreProcessingParametersResponse) export const parameters3 = { - get: get22, + get: get20, } export const preProcessing2 = { @@ -1157,7 +932,7 @@ export const preProcessing2 = { /** * Get second step parameters of rag pipeline */ -export const get23 = oc +export const get21 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1175,45 +950,20 @@ export const get23 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsPublishedProcessingParametersResponse) export const parameters4 = { - get: get23, + get: get21, } export const processing2 = { parameters: parameters4, } -/** - * Run published workflow - */ -export const post19 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postRagPipelinesByPipelineIdWorkflowsPublishedRun', - path: '/rag/pipelines/{pipeline_id}/workflows/published/run', - summary: 'Run published workflow', - tags: ['console'], - }) - .input( - z.object({ - body: zPostRagPipelinesByPipelineIdWorkflowsPublishedRunBody, - params: zPostRagPipelinesByPipelineIdWorkflowsPublishedRunPath, - }), - ) - .output(zPostRagPipelinesByPipelineIdWorkflowsPublishedRunResponse) - -export const run7 = { - post: post19, -} - export const published = { datasource: datasource2, preProcessing: preProcessing2, processing: processing2, - run: run7, } -export const post20 = oc +export const post14 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -1225,7 +975,7 @@ export const post20 = oc .output(zPostRagPipelinesByPipelineIdWorkflowsByWorkflowIdRestoreResponse) export const restore = { - post: post20, + post: post14, } /** @@ -1273,7 +1023,7 @@ export const byWorkflowId = { /** * Get published workflows */ -export const get24 = oc +export const get22 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1291,8 +1041,7 @@ export const get24 = oc .output(zGetRagPipelinesByPipelineIdWorkflowsResponse) export const workflows = { - get: get24, - defaultWorkflowBlockConfigs, + get: get22, draft, publish: publish2, published, diff --git a/packages/contracts/generated/api/console/rag/types.gen.ts b/packages/contracts/generated/api/console/rag/types.gen.ts index b9862a8d1e8..99ffbff6d7f 100644 --- a/packages/contracts/generated/api/console/rag/types.gen.ts +++ b/packages/contracts/generated/api/console/rag/types.gen.ts @@ -89,7 +89,7 @@ export type PipelineTemplateDetailResponse = { name: string } -export type RagPipelineOpaqueResponse = unknown +export type DatasourcePluginListResponse = Array export type RagPipelineImportPayload = { description?: string | null @@ -107,6 +107,21 @@ export type RagPipelineImportCheckDependenciesResponse = { leaked_dependencies?: Array } +export type RagPipelineRecommendedPluginResponse = { + installed_recommended_plugins: Array<{ + [key: string]: unknown + }> + uninstalled_recommended_plugins: Array<{ + [key: string]: unknown + }> +} + +export type RagPipelineTransformResponse = { + dataset_id: string + pipeline_id: string + status: string +} + export type WorkflowRunPaginationResponse = { data: Array has_more: boolean @@ -119,7 +134,7 @@ export type SimpleResultResponse = { export type WorkflowRunDetailResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -147,18 +162,10 @@ export type WorkflowPaginationResponse = { page: number } -export type DefaultBlockConfigsResponse = Array<{ - [key: string]: unknown -}> - -export type DefaultBlockConfigResponse = { - [key: string]: unknown -} - export type WorkflowResponse = { conversation_variables: Array created_at: number - created_by?: SimpleAccount | null + created_by?: SimpleAccountResponse | null environment_variables: Array features: { [key: string]: unknown @@ -173,7 +180,7 @@ export type WorkflowResponse = { rag_pipeline_variables: Array tool_published: boolean updated_at: number - updated_by?: SimpleAccount | null + updated_by?: SimpleAccountResponse | null version: string } @@ -202,14 +209,6 @@ export type RagPipelineWorkflowSyncResponse = { updated_at: number } -export type DatasourceNodeRunPayload = { - credential_id?: string | null - datasource_type: string - inputs: { - [key: string]: unknown - } -} - export type DatasourceVariablesPayload = { datasource_info: { [key: string]: unknown @@ -221,7 +220,7 @@ export type DatasourceVariablesPayload = { export type WorkflowRunNodeExecutionResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -248,12 +247,6 @@ export type EnvironmentVariableListResponse = { items: Array } -export type NodeRunPayload = { - inputs?: { - [key: string]: unknown - } | null -} - export type NodeRunRequiredPayload = { inputs: { [key: string]: unknown @@ -264,21 +257,10 @@ export type WorkflowDraftVariableList = { items?: Array } -export type RagPipelineStepParametersResponse = { +export type RagPipelineVariablesResponse = { variables: unknown } -export type DraftWorkflowRunPayload = { - datasource_info_list: Array<{ - [key: string]: unknown - }> - datasource_type: string - inputs: { - [key: string]: unknown - } - start_node_id: string -} - export type WorkflowDraftVariableListWithoutValue = { items?: Array total?: number @@ -329,20 +311,6 @@ export type Parser = { export type DataSourceContentPreviewResponse = unknown -export type PublishedWorkflowRunPayload = { - datasource_info_list: Array<{ - [key: string]: unknown - }> - datasource_type: string - inputs: { - [key: string]: unknown - } - is_preview?: boolean - original_document_id?: string | null - response_mode?: 'blocking' | 'streaming' - start_node_id: string -} - export type WorkflowUpdatePayload = { marked_comment?: string | null marked_name?: string | null @@ -413,6 +381,14 @@ export type PipelineTemplateItemResponse = { privacy_policy?: string | null } +export type PluginDatasourceProviderEntity = { + declaration: DatasourceProviderEntityWithPlugin + is_authorized?: boolean + plugin_id: string + plugin_unique_identifier: string + provider: string +} + export type PluginDependency = { current_identifier?: string | null type: Type @@ -421,7 +397,7 @@ export type PluginDependency = { export type WorkflowRunForListResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -433,7 +409,7 @@ export type WorkflowRunForListResponse = { version?: string | null } -export type SimpleAccount = { +export type SimpleAccountResponse = { email: string id: string name: string @@ -515,6 +491,14 @@ export type DatasetWeightedScoreResponse = { weight_type?: string | null } +export type DatasourceProviderEntityWithPlugin = { + credentials_schema?: Array + datasources?: Array + identity: DatasourceProviderIdentity + oauth_schema?: OAuthSchema | null + provider_type: DatasourceProviderType +} + export type Type = 'github' | 'marketplace' | 'package' export type Github = { @@ -544,6 +528,162 @@ export type DatasetVectorSettingResponse = { vector_weight?: number | null } +export type ProviderConfig = { + default?: number | string | number | boolean | null + help?: I18nObject | null + label?: I18nObject | null + multiple?: boolean + name: string + options?: Array