From 78cb65fa1fcf06450a05462f169eae6679b62e0f Mon Sep 17 00:00:00 2001 From: chariri Date: Fri, 26 Jun 2026 03:29:59 +0900 Subject: [PATCH] refactor(api): remove member field compatibility --- api/controllers/console/explore/trial.py | 154 ++-- api/controllers/console/workspace/snippets.py | 105 ++- api/fields/app_fields.py | 271 ------- api/fields/member_fields.py | 7 - api/fields/snippet_fields.py | 110 +-- api/fields/workflow_fields.py | 129 ---- api/openapi/markdown/console-openapi.md | 446 ++++-------- .../console/workspace/test_snippets.py | 78 +- .../unit_tests/fields/test_snippet_fields.py | 7 +- .../generated/api/console/agent/types.gen.ts | 32 +- .../generated/api/console/agent/zod.gen.ts | 121 +-- .../generated/api/console/apps/types.gen.ts | 32 +- .../generated/api/console/apps/zod.gen.ts | 205 +++--- .../console/instruction-generate/types.gen.ts | 41 +- .../console/instruction-generate/zod.gen.ts | 44 +- .../console/rule-code-generate/types.gen.ts | 41 +- .../api/console/rule-code-generate/zod.gen.ts | 44 +- .../api/console/rule-generate/types.gen.ts | 41 +- .../api/console/rule-generate/zod.gen.ts | 44 +- .../types.gen.ts | 41 +- .../zod.gen.ts | 44 +- .../api/console/trial-apps/orpc.gen.ts | 84 +-- .../api/console/trial-apps/types.gen.ts | 544 +++++++------- .../api/console/trial-apps/zod.gen.ts | 686 +++++++++--------- .../console/workflow-generate/types.gen.ts | 41 +- .../api/console/workflow-generate/zod.gen.ts | 44 +- .../api/console/workspaces/orpc.gen.ts | 379 +++++----- .../api/console/workspaces/types.gen.ts | 192 ++--- .../api/console/workspaces/zod.gen.ts | 270 +++---- 29 files changed, 1979 insertions(+), 2298 deletions(-) delete mode 100644 api/fields/app_fields.py delete mode 100644 api/fields/workflow_fields.py 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/workspace/snippets.py b/api/controllers/console/workspace/snippets.py index e8f0b228c8b..6e7c79f85ae 100644 --- a/api/controllers/console/workspace/snippets.py +++ b/api/controllers/console/workspace/snippets.py @@ -1,16 +1,13 @@ import logging import re -from typing import Any from urllib.parse import quote from flask import Response, request -from flask_restx import Resource, marshal -from pydantic import RootModel +from flask_restx import Resource from sqlalchemy.orm import Session, sessionmaker from werkzeug.datastructures import MultiDict from werkzeug.exceptions import NotFound -from controllers.common.fields import TextFileResponse 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.snippets.payloads import ( @@ -32,12 +29,13 @@ from controllers.console.wraps import ( ) from extensions.ext_database import db from fields.base import ResponseModel -from fields.snippet_fields import snippet_fields, snippet_list_fields, snippet_pagination_fields +from fields.snippet_fields import SnippetPaginationResponse, SnippetResponse +from libs.helper import dump_response from libs.login import login_required from models import Account from models.snippet import SnippetType from services.app_dsl_service import ImportStatus -from services.snippet_dsl_service import SnippetDslService +from services.snippet_dsl_service import CheckDependenciesResult, SnippetDslService, SnippetImportInfo from services.snippet_service import SnippetService logger = logging.getLogger(__name__) @@ -45,15 +43,7 @@ _TAG_IDS_BRACKET_PATTERN = re.compile(r"^tag_ids\[(\d+)\]$") _CREATOR_IDS_BRACKET_PATTERN = re.compile(r"^creator_ids\[(\d+)\]$") -class SnippetImportResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - -class SnippetDependencyCheckResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - -class SnippetUseCountResponse(ResponseModel): +class SnippetUseCountIncrementResponse(ResponseModel): result: str use_count: int @@ -100,30 +90,22 @@ register_schema_models( IncludeSecretQuery, ) register_response_schema_models( - console_ns, - TextFileResponse, - SnippetImportResponse, - SnippetDependencyCheckResponse, - SnippetUseCountResponse, + console_ns, SnippetResponse, SnippetPaginationResponse, SnippetUseCountIncrementResponse, SnippetImportInfo ) -# Create namespace models for marshaling -snippet_model = console_ns.model("Snippet", snippet_fields) -snippet_list_model = console_ns.model("SnippetList", snippet_list_fields) -snippet_pagination_model = console_ns.model("SnippetPagination", snippet_pagination_fields) - @console_ns.route("/workspaces/current/customized-snippets") class CustomizedSnippetsApi(Resource): @console_ns.doc("list_customized_snippets") @console_ns.doc(params=query_params_from_model(SnippetListQuery)) - @console_ns.response(200, "Snippets retrieved successfully", snippet_pagination_model) + @console_ns.response(200, "Snippets retrieved successfully", console_ns.models[SnippetPaginationResponse.__name__]) @setup_required @login_required @account_initialization_required @with_current_tenant_id def get(self, current_tenant_id: str): """List customized snippets with pagination and search.""" + query = SnippetListQuery.model_validate(_normalize_snippet_list_query_args(request.args)) snippet_service = _snippet_service() @@ -138,17 +120,20 @@ class CustomizedSnippetsApi(Resource): tag_ids=query.tag_ids, ) - return { - "data": marshal(snippets, snippet_list_fields), - "page": query.page, - "limit": query.limit, - "total": total, - "has_more": has_more, - }, 200 + return dump_response( + SnippetPaginationResponse, + { + "data": snippets, + "page": query.page, + "limit": query.limit, + "total": total, + "has_more": has_more, + }, + ), 200 @console_ns.doc("create_customized_snippet") @console_ns.expect(console_ns.models.get(CreateSnippetPayload.__name__)) - @console_ns.response(201, "Snippet created successfully", snippet_model) + @console_ns.response(201, "Snippet created successfully", console_ns.models[SnippetResponse.__name__]) @console_ns.response(400, "Invalid request") @setup_required @login_required @@ -161,6 +146,7 @@ class CustomizedSnippetsApi(Resource): @with_current_tenant_id def post(self, current_tenant_id: str, current_user: Account): """Create a new customized snippet.""" + payload = CreateSnippetPayload.model_validate(console_ns.payload or {}) try: @@ -185,13 +171,13 @@ class CustomizedSnippetsApi(Resource): except ValueError as e: return {"message": str(e)}, 400 - return marshal(snippet, snippet_fields), 201 + return dump_response(SnippetResponse, snippet), 201 @console_ns.route("/workspaces/current/customized-snippets/") class CustomizedSnippetDetailApi(Resource): @console_ns.doc("get_customized_snippet") - @console_ns.response(200, "Snippet retrieved successfully", snippet_model) + @console_ns.response(200, "Snippet retrieved successfully", console_ns.models[SnippetResponse.__name__]) @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -199,20 +185,21 @@ class CustomizedSnippetDetailApi(Resource): @with_current_tenant_id def get(self, current_tenant_id: str, snippet_id: str): """Get customized snippet details.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) if not snippet: raise NotFound("Snippet not found") - return marshal(snippet, snippet_fields), 200 + return dump_response(SnippetResponse, snippet), 200 @console_ns.doc("update_customized_snippet") @console_ns.expect(console_ns.models.get(UpdateSnippetPayload.__name__)) - @console_ns.response(200, "Snippet updated successfully", snippet_model) + @console_ns.response(200, "Snippet updated successfully", console_ns.models[SnippetResponse.__name__]) @console_ns.response(400, "Invalid request") @console_ns.response(404, "Snippet not found") @setup_required @@ -226,9 +213,10 @@ class CustomizedSnippetDetailApi(Resource): @with_current_tenant_id def patch(self, current_tenant_id: str, current_user: Account, snippet_id: str): """Update customized snippet.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -257,7 +245,7 @@ class CustomizedSnippetDetailApi(Resource): except ValueError as e: return {"message": str(e)}, 400 - return marshal(snippet, snippet_fields), 200 + return dump_response(SnippetResponse, snippet), 200 @console_ns.doc("delete_customized_snippet") @console_ns.response(204, "Snippet deleted successfully") @@ -270,9 +258,10 @@ class CustomizedSnippetDetailApi(Resource): @with_current_tenant_id def delete(self, current_tenant_id: str, snippet_id: str): """Delete customized snippet.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -296,7 +285,7 @@ class CustomizedSnippetExportApi(Resource): @console_ns.doc(description="Export snippet configuration as DSL") @console_ns.doc(params={"snippet_id": "Snippet ID to export"}) @console_ns.doc(params=query_params_from_model(IncludeSecretQuery)) - @console_ns.response(200, "Snippet exported successfully", console_ns.models[TextFileResponse.__name__]) + @console_ns.response(200, "Snippet exported successfully") @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -308,9 +297,10 @@ class CustomizedSnippetExportApi(Resource): @with_current_tenant_id def get(self, current_tenant_id: str, snippet_id: str): """Export snippet as DSL.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -343,8 +333,8 @@ class CustomizedSnippetImportApi(Resource): @console_ns.doc("import_customized_snippet") @console_ns.doc(description="Import snippet from DSL") @console_ns.expect(console_ns.models.get(SnippetImportPayload.__name__)) - @console_ns.response(200, "Snippet imported successfully", console_ns.models[SnippetImportResponse.__name__]) - @console_ns.response(202, "Import pending confirmation", console_ns.models[SnippetImportResponse.__name__]) + @console_ns.response(200, "Snippet imported successfully", console_ns.models[SnippetImportInfo.__name__]) + @console_ns.response(202, "Import pending confirmation", console_ns.models[SnippetImportInfo.__name__]) @console_ns.response(400, "Import failed") @setup_required @login_required @@ -385,7 +375,7 @@ class CustomizedSnippetImportConfirmApi(Resource): @console_ns.doc("confirm_snippet_import") @console_ns.doc(description="Confirm a pending snippet import") @console_ns.doc(params={"import_id": "Import ID to confirm"}) - @console_ns.response(200, "Import confirmed successfully", console_ns.models[SnippetImportResponse.__name__]) + @console_ns.response(200, "Import confirmed successfully", console_ns.models[SnippetImportInfo.__name__]) @console_ns.response(400, "Import failed") @setup_required @login_required @@ -412,11 +402,7 @@ class CustomizedSnippetCheckDependenciesApi(Resource): @console_ns.doc("check_snippet_dependencies") @console_ns.doc(description="Check dependencies for a snippet") @console_ns.doc(params={"snippet_id": "Snippet ID"}) - @console_ns.response( - 200, - "Dependencies checked successfully", - console_ns.models[SnippetDependencyCheckResponse.__name__], - ) + @console_ns.response(200, "Dependencies checked successfully", console_ns.models[CheckDependenciesResult.__name__]) @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -430,7 +416,7 @@ class CustomizedSnippetCheckDependenciesApi(Resource): """Check dependencies for a snippet.""" snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -449,7 +435,11 @@ class CustomizedSnippetUseCountIncrementApi(Resource): @console_ns.doc("increment_snippet_use_count") @console_ns.doc(description="Increment snippet use count by 1") @console_ns.doc(params={"snippet_id": "Snippet ID"}) - @console_ns.response(200, "Use count incremented successfully", console_ns.models[SnippetUseCountResponse.__name__]) + @console_ns.response( + 200, + "Use count incremented successfully", + console_ns.models[SnippetUseCountIncrementResponse.__name__], + ) @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -461,9 +451,10 @@ class CustomizedSnippetUseCountIncrementApi(Resource): @with_current_tenant_id def post(self, current_tenant_id: str, snippet_id: str): """Increment snippet use count when it is inserted into a workflow.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -476,4 +467,6 @@ class CustomizedSnippetUseCountIncrementApi(Resource): session.commit() session.refresh(snippet) - return {"result": "success", "use_count": snippet.use_count}, 200 + return SnippetUseCountIncrementResponse(result="success", use_count=snippet.use_count).model_dump( + mode="json" + ), 200 diff --git a/api/fields/app_fields.py b/api/fields/app_fields.py deleted file mode 100644 index 96d8fbdf34c..00000000000 --- a/api/fields/app_fields.py +++ /dev/null @@ -1,271 +0,0 @@ -import json -from typing import override - -from flask_restx import fields - -from fields.workflow_fields import workflow_partial_fields -from libs.helper import AppIconUrlField, TimestampField - - -class JsonStringField(fields.Raw): - @override - def format(self, value): - if isinstance(value, str): - try: - return json.loads(value) - except (json.JSONDecodeError, TypeError): - return value - return value - - -class OpaqueRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "object"} - - -class StringListRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "array", "items": {"type": "string"}} - - -class ObjectListRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "array", "items": {"type": "object"}} - - -app_detail_kernel_fields = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "mode": fields.String(attribute="mode_compatible_with_agent"), - "icon_type": fields.String, - "icon": fields.String, - "icon_background": fields.String, - "icon_url": AppIconUrlField, -} - -related_app_list = { - "data": fields.List(fields.Nested(app_detail_kernel_fields)), - "total": fields.Integer, -} - -model_config_fields = { - "opening_statement": fields.String, - "suggested_questions": StringListRawField(attribute="suggested_questions_list"), - "suggested_questions_after_answer": OpaqueRawField(attribute="suggested_questions_after_answer_dict"), - "speech_to_text": OpaqueRawField(attribute="speech_to_text_dict"), - "text_to_speech": OpaqueRawField(attribute="text_to_speech_dict"), - "retriever_resource": OpaqueRawField(attribute="retriever_resource_dict"), - "annotation_reply": OpaqueRawField(attribute="annotation_reply_dict"), - "more_like_this": OpaqueRawField(attribute="more_like_this_dict"), - "sensitive_word_avoidance": OpaqueRawField(attribute="sensitive_word_avoidance_dict"), - "external_data_tools": ObjectListRawField(attribute="external_data_tools_list"), - "model": OpaqueRawField(attribute="model_dict"), - "user_input_form": ObjectListRawField(attribute="user_input_form_list"), - "dataset_query_variable": fields.String, - "pre_prompt": fields.String, - "agent_mode": OpaqueRawField(attribute="agent_mode_dict"), - "prompt_type": fields.String, - "chat_prompt_config": OpaqueRawField(attribute="chat_prompt_config_dict"), - "completion_prompt_config": OpaqueRawField(attribute="completion_prompt_config_dict"), - "dataset_configs": OpaqueRawField(attribute="dataset_configs_dict"), - "file_upload": OpaqueRawField(attribute="file_upload_dict"), - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, -} - -tag_fields = {"id": fields.String, "name": fields.String, "type": fields.String} - -app_detail_fields = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "mode": fields.String(attribute="mode_compatible_with_agent"), - "icon": fields.String, - "icon_background": fields.String, - "enable_site": fields.Boolean, - "enable_api": fields.Boolean, - "model_config": fields.Nested(model_config_fields, attribute="app_model_config", allow_null=True), - "workflow": fields.Nested(workflow_partial_fields, allow_null=True), - "tracing": OpaqueRawField, - "use_icon_as_answer_icon": fields.Boolean, - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, - "access_mode": fields.String, - "tags": fields.List(fields.Nested(tag_fields)), - "permission_keys": fields.List(fields.String()), -} - -prompt_config_fields = { - "prompt_template": fields.String, -} - -model_config_partial_fields = { - "model": OpaqueRawField(attribute="model_dict"), - "pre_prompt": fields.String, - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, -} - -app_partial_fields = { - "id": fields.String, - "name": fields.String, - "max_active_requests": OpaqueRawField(), - "description": fields.String(attribute="desc_or_prompt"), - "mode": fields.String(attribute="mode_compatible_with_agent"), - "icon_type": fields.String, - "icon": fields.String, - "icon_background": fields.String, - "icon_url": AppIconUrlField, - "model_config": fields.Nested(model_config_partial_fields, attribute="app_model_config", allow_null=True), - "workflow": fields.Nested(workflow_partial_fields, allow_null=True), - "use_icon_as_answer_icon": fields.Boolean, - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, - "tags": fields.List(fields.Nested(tag_fields)), - "access_mode": fields.String, - "create_user_name": fields.String, - "author_name": fields.String, - "has_draft_trigger": fields.Boolean, - "permission_keys": fields.List(fields.String()), -} - - -app_pagination_fields = { - "page": fields.Integer, - "limit": fields.Integer(attribute="per_page"), - "total": fields.Integer, - "has_more": fields.Boolean(attribute="has_next"), - "data": fields.List(fields.Nested(app_partial_fields), attribute="items"), -} - -template_fields = { - "name": fields.String, - "icon": fields.String, - "icon_background": fields.String, - "description": fields.String, - "mode": fields.String, - "model_config": fields.Nested(model_config_fields), -} - -template_list_fields = { - "data": fields.List(fields.Nested(template_fields)), -} - -site_fields = { - "access_token": fields.String(attribute="code"), - "code": fields.String, - "title": fields.String, - "icon_type": fields.String, - "icon": fields.String, - "icon_background": fields.String, - "icon_url": AppIconUrlField, - "description": fields.String, - "default_language": fields.String, - "chat_color_theme": fields.String, - "chat_color_theme_inverted": fields.Boolean, - "customize_domain": fields.String, - "copyright": fields.String, - "privacy_policy": fields.String, - "custom_disclaimer": fields.String, - "customize_token_strategy": fields.String, - "prompt_public": fields.Boolean, - "app_base_url": fields.String, - "show_workflow_steps": fields.Boolean, - "use_icon_as_answer_icon": fields.Boolean, - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, -} - -deleted_tool_fields = { - "type": fields.String, - "tool_name": fields.String, - "provider_id": fields.String, -} - -app_detail_fields_with_site = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "mode": fields.String(attribute="mode_compatible_with_agent"), - "icon_type": fields.String, - "icon": fields.String, - "icon_background": fields.String, - "icon_url": AppIconUrlField, - "enable_site": fields.Boolean, - "enable_api": fields.Boolean, - "model_config": fields.Nested(model_config_fields, attribute="app_model_config", allow_null=True), - "workflow": fields.Nested(workflow_partial_fields, allow_null=True), - "api_base_url": fields.String, - "use_icon_as_answer_icon": fields.Boolean, - "max_active_requests": fields.Integer, - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, - "deleted_tools": fields.List(fields.Nested(deleted_tool_fields)), - "access_mode": fields.String, - "tags": fields.List(fields.Nested(tag_fields)), - "permission_keys": fields.List(fields.String()), - "site": fields.Nested(site_fields), -} - - -app_site_fields = { - "app_id": fields.String, - "access_token": fields.String(attribute="code"), - "code": fields.String, - "title": fields.String, - "icon": fields.String, - "icon_background": fields.String, - "description": fields.String, - "default_language": fields.String, - "customize_domain": fields.String, - "copyright": fields.String, - "privacy_policy": fields.String, - "custom_disclaimer": fields.String, - "customize_token_strategy": fields.String, - "prompt_public": fields.Boolean, - "show_workflow_steps": fields.Boolean, - "use_icon_as_answer_icon": fields.Boolean, -} - -leaked_dependency_fields = {"type": fields.String, "value": OpaqueRawField, "current_identifier": fields.String} - -app_import_fields = { - "id": fields.String, - "status": fields.String, - "app_id": fields.String, - "app_mode": fields.String, - "current_dsl_version": fields.String, - "imported_dsl_version": fields.String, - "error": fields.String, -} - -app_import_check_dependencies_fields = { - "leaked_dependencies": fields.List(fields.Nested(leaked_dependency_fields)), -} - -app_server_fields = { - "id": fields.String, - "name": fields.String, - "server_code": fields.String, - "description": fields.String, - "status": fields.String, - "parameters": JsonStringField, - "created_at": TimestampField, - "updated_at": TimestampField, -} diff --git a/api/fields/member_fields.py b/api/fields/member_fields.py index 80b93f0a24b..5108522af01 100644 --- a/api/fields/member_fields.py +++ b/api/fields/member_fields.py @@ -2,18 +2,11 @@ from __future__ import annotations from datetime import datetime -from flask_restx import fields from pydantic import Field, computed_field, field_validator from fields.base import ResponseModel from libs.helper import build_avatar_url, to_timestamp -simple_account_fields = { - "id": fields.String, - "name": fields.String, - "email": fields.String, -} - class SimpleAccountResponse(ResponseModel): id: str diff --git a/api/fields/snippet_fields.py b/api/fields/snippet_fields.py index 699a3687ac1..9d12b600722 100644 --- a/api/fields/snippet_fields.py +++ b/api/fields/snippet_fields.py @@ -1,61 +1,67 @@ -from typing import override +from datetime import datetime +from typing import Any -from flask_restx import fields +from pydantic import Field, field_validator -from fields.member_fields import simple_account_fields -from libs.helper import TimestampField +from fields.base import ResponseModel +from fields.member_fields import SimpleAccountResponse +from libs.helper import to_timestamp -class OpaqueRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "object"} +class SnippetTagResponse(ResponseModel): + id: str + name: str + type: str -tag_fields = {"id": fields.String, "name": fields.String, "type": fields.String} +class SnippetListItemResponse(ResponseModel): + id: str + name: str + description: str | None = None + type: str + version: int + use_count: int + is_published: bool + icon_info: dict[str, Any] | None = None + tags: list[SnippetTagResponse] = Field(default_factory=list) + created_by: str | None = None + author_name: str | None = None + created_at: int | None = None + updated_by: str | None = None + updated_at: int | None = None -# Snippet list item fields (lightweight for list display) -snippet_list_fields = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "type": fields.String, - "version": fields.Integer, - "use_count": fields.Integer, - "is_published": fields.Boolean, - "icon_info": OpaqueRawField, - "tags": fields.List(fields.Nested(tag_fields)), - "created_by": fields.String, - "author_name": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, -} + @field_validator("created_at", "updated_at", mode="before") + @classmethod + def _normalize_timestamp(cls, value: datetime | int | None) -> int | None: + return to_timestamp(value) -# Full snippet fields (includes creator info and graph data) -snippet_fields = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "type": fields.String, - "version": fields.Integer, - "use_count": fields.Integer, - "is_published": fields.Boolean, - "icon_info": OpaqueRawField, - "graph": OpaqueRawField(attribute="graph_dict"), - "input_fields": OpaqueRawField(attribute="input_fields_list"), - "tags": fields.List(fields.Nested(tag_fields)), - "created_by": fields.Nested(simple_account_fields, attribute="created_by_account", allow_null=True), - "created_at": TimestampField, - "updated_by": fields.Nested(simple_account_fields, attribute="updated_by_account", allow_null=True), - "updated_at": TimestampField, -} -# Pagination response fields -snippet_pagination_fields = { - "data": fields.List(fields.Nested(snippet_list_fields)), - "page": fields.Integer, - "limit": fields.Integer, - "total": fields.Integer, - "has_more": fields.Boolean, -} +class SnippetResponse(ResponseModel): + id: str + name: str + description: str | None = None + type: str + version: int + use_count: int + is_published: bool + icon_info: dict[str, Any] | None = None + graph: dict[str, Any] | None = Field(default=None, validation_alias="graph_dict") + input_fields: list[dict[str, Any]] | None = Field(default=None, validation_alias="input_fields_list") + tags: list[SnippetTagResponse] = Field(default_factory=list) + created_by: SimpleAccountResponse | None = Field(default=None, validation_alias="created_by_account") + created_at: int | None = None + updated_by: SimpleAccountResponse | None = Field(default=None, validation_alias="updated_by_account") + updated_at: int | None = None + + @field_validator("created_at", "updated_at", mode="before") + @classmethod + def _normalize_timestamp(cls, value: datetime | int | None) -> int | None: + return to_timestamp(value) + + +class SnippetPaginationResponse(ResponseModel): + data: list[SnippetListItemResponse] + page: int + limit: int + total: int + has_more: bool diff --git a/api/fields/workflow_fields.py b/api/fields/workflow_fields.py deleted file mode 100644 index 2d0d8f9f546..00000000000 --- a/api/fields/workflow_fields.py +++ /dev/null @@ -1,129 +0,0 @@ -from typing import override - -from flask_restx import fields - -from core.helper import encrypter -from fields.member_fields import simple_account_fields -from graphon.variables import SecretVariable, SegmentType, VariableBase -from libs.helper import TimestampField - -from ._value_type_serializer import serialize_value_type - -ENVIRONMENT_VARIABLE_SUPPORTED_TYPES = (SegmentType.STRING, SegmentType.NUMBER, SegmentType.SECRET) - - -class OpaqueRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "object"} - - -class JsonValueRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return { - "anyOf": [ - {"type": "string"}, - {"type": "integer"}, - {"type": "number"}, - {"type": "boolean"}, - {"type": "object", "additionalProperties": True}, - {"type": "array", "items": {}}, - {"type": "null"}, - ] - } - - -class EnvironmentVariableField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "object"} - - @override - def format(self, value): - # Mask secret variables values in environment_variables - if isinstance(value, SecretVariable): - return { - "id": value.id, - "name": value.name, - "value": encrypter.full_mask_token(), - "value_type": value.value_type.value, - "description": value.description, - } - if isinstance(value, VariableBase): - return { - "id": value.id, - "name": value.name, - "value": value.value, - "value_type": str(value.value_type.exposed_type()), - "description": value.description, - } - if isinstance(value, dict): - value_type_str = value.get("value_type") - if not isinstance(value_type_str, str): - raise TypeError( - f"unexpected type for value_type field, value={value_type_str}, type={type(value_type_str)}" - ) - value_type = SegmentType(value_type_str).exposed_type() - if value_type not in ENVIRONMENT_VARIABLE_SUPPORTED_TYPES: - raise ValueError(f"Unsupported environment variable value type: {value_type}") - return value - - -conversation_variable_fields = { - "id": fields.String, - "name": fields.String, - "value_type": fields.String(attribute=serialize_value_type), - "value": JsonValueRawField, - "description": fields.String, -} - -pipeline_variable_fields = { - "label": fields.String, - "variable": fields.String, - "type": fields.String, - "belong_to_node_id": fields.String, - "max_length": fields.Integer, - "required": fields.Boolean, - "unit": fields.String, - "default_value": JsonValueRawField, - "options": fields.List(fields.String), - "placeholder": fields.String, - "tooltips": fields.String, - "allowed_file_types": fields.List(fields.String), - "allow_file_extension": fields.List(fields.String), - "allow_file_upload_methods": fields.List(fields.String), -} - -workflow_fields = { - "id": fields.String, - "graph": OpaqueRawField(attribute="graph_dict"), - "features": OpaqueRawField(attribute="features_dict"), - "hash": fields.String(attribute="unique_hash"), - "version": fields.String, - "marked_name": fields.String, - "marked_comment": fields.String, - "created_by": fields.Nested(simple_account_fields, attribute="created_by_account"), - "created_at": TimestampField, - "updated_by": fields.Nested(simple_account_fields, attribute="updated_by_account", allow_null=True), - "updated_at": TimestampField, - "tool_published": fields.Boolean, - "environment_variables": fields.List(EnvironmentVariableField()), - "conversation_variables": fields.List(fields.Nested(conversation_variable_fields)), - "rag_pipeline_variables": fields.List(fields.Nested(pipeline_variable_fields)), -} - -workflow_partial_fields = { - "id": fields.String, - "created_by": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, -} - -workflow_pagination_fields = { - "items": fields.List(fields.Nested(workflow_fields), attribute="items"), - "page": fields.Integer, - "limit": fields.Integer(attribute="limit"), - "has_more": fields.Boolean(attribute="has_more"), -} diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.md index 3d8bab63e8b..35d52c61d60 100644 --- a/api/openapi/markdown/console-openapi.md +++ b/api/openapi/markdown/console-openapi.md @@ -8760,7 +8760,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 +8790,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 +8809,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 +8827,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 +8907,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 +8926,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** @@ -9104,7 +9104,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippets retrieved successfully | **application/json**: [SnippetPagination](#snippetpagination)
| +| 200 | Snippets retrieved successfully | **application/json**: [SnippetPaginationResponse](#snippetpaginationresponse)
| ### [POST] /workspaces/current/customized-snippets **Create a new customized snippet** @@ -9119,7 +9119,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 201 | Snippet created successfully | **application/json**: [Snippet](#snippet)
| +| 201 | Snippet created successfully | **application/json**: [SnippetResponse](#snippetresponse)
| | 400 | Invalid request | | ### [POST] /workspaces/current/customized-snippets/imports @@ -9135,8 +9135,8 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippet imported successfully | **application/json**: [SnippetImportResponse](#snippetimportresponse)
| -| 202 | Import pending confirmation | **application/json**: [SnippetImportResponse](#snippetimportresponse)
| +| 200 | Snippet imported successfully | **application/json**: [SnippetImportInfo](#snippetimportinfo)
| +| 202 | Import pending confirmation | **application/json**: [SnippetImportInfo](#snippetimportinfo)
| | 400 | Import failed | | ### [POST] /workspaces/current/customized-snippets/imports/{import_id}/confirm @@ -9152,7 +9152,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Import confirmed successfully | **application/json**: [SnippetImportResponse](#snippetimportresponse)
| +| 200 | Import confirmed successfully | **application/json**: [SnippetImportInfo](#snippetimportinfo)
| | 400 | Import failed | | ### [DELETE] /workspaces/current/customized-snippets/{snippet_id} @@ -9184,7 +9184,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippet retrieved successfully | **application/json**: [Snippet](#snippet)
| +| 200 | Snippet retrieved successfully | **application/json**: [SnippetResponse](#snippetresponse)
| | 404 | Snippet not found | | ### [PATCH] /workspaces/current/customized-snippets/{snippet_id} @@ -9206,7 +9206,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippet updated successfully | **application/json**: [Snippet](#snippet)
| +| 200 | Snippet updated successfully | **application/json**: [SnippetResponse](#snippetresponse)
| | 400 | Invalid request | | | 404 | Snippet not found | | @@ -9223,7 +9223,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Dependencies checked successfully | **application/json**: [SnippetDependencyCheckResponse](#snippetdependencycheckresponse)
| +| 200 | Dependencies checked successfully | **application/json**: [CheckDependenciesResult](#checkdependenciesresult)
| | 404 | Snippet not found | | ### [GET] /workspaces/current/customized-snippets/{snippet_id}/export @@ -9240,10 +9240,10 @@ Export snippet configuration as DSL #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Snippet exported successfully | **application/json**: [TextFileResponse](#textfileresponse)
| -| 404 | Snippet not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Snippet exported successfully | +| 404 | Snippet not found | ### [POST] /workspaces/current/customized-snippets/{snippet_id}/use-count/increment **Increment snippet use count when it is inserted into a workflow** @@ -9260,7 +9260,7 @@ Increment snippet use count by 1 | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Use count incremented successfully | **application/json**: [SnippetUseCountResponse](#snippetusecountresponse)
| +| 200 | Use count incremented successfully | **application/json**: [SnippetUseCountIncrementResponse](#snippetusecountincrementresponse)
| | 404 | Snippet not found | | ### [GET] /workspaces/current/dataset-operators @@ -17200,10 +17200,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 @@ -19340,32 +19360,6 @@ Validated metadata extracted from a Skill package. | inferable | boolean | | Yes | | reason | string | | No | -#### Snippet - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| created_at | long | | No | -| created_by | [_AnonymousInlineModel_b0fd3f86d9d5](#_anonymousinlinemodel_b0fd3f86d9d5) | | No | -| description | string | | No | -| graph | object | | No | -| icon_info | object | | No | -| id | string | | No | -| input_fields | object | | No | -| is_published | boolean | | No | -| name | string | | No | -| tags | [ [_AnonymousInlineModel_7b8b49ca164e](#_anonymousinlinemodel_7b8b49ca164e) ] | | No | -| type | string | | No | -| updated_at | long | | No | -| updated_by | [_AnonymousInlineModel_b0fd3f86d9d5](#_anonymousinlinemodel_b0fd3f86d9d5) | | No | -| use_count | integer | | No | -| version | integer | | No | - -#### SnippetDependencyCheckResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| SnippetDependencyCheckResponse | object | | | - #### SnippetDraftConfigResponse | Name | Type | Description | Required | @@ -19402,6 +19396,17 @@ Payload for syncing snippet draft workflow. | hash | string | | No | | input_fields | [ object ] | | No | +#### SnippetImportInfo + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| current_dsl_version | string,
**Default:** 0.1.0 | | No | +| error | string | | No | +| id | string | | Yes | +| imported_dsl_version | string | | No | +| snippet_id | string | | No | +| status | [ImportStatus](#importstatus) | | Yes | + #### SnippetImportPayload Payload for importing snippet from DSL. @@ -19415,12 +19420,6 @@ Payload for importing snippet from DSL. | yaml_content | string | YAML content (required for yaml-content mode) | No | | yaml_url | string | YAML URL (required for yaml-url mode) | No | -#### SnippetImportResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| SnippetImportResponse | object | | | - #### SnippetIterationNodeRunPayload Payload for running an iteration node in snippet draft workflow. @@ -19429,24 +19428,24 @@ Payload for running an iteration node in snippet draft workflow. | ---- | ---- | ----------- | -------- | | inputs | object | | No | -#### SnippetList +#### SnippetListItemResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | author_name | string | | No | -| created_at | long | | No | +| created_at | integer | | No | | created_by | string | | No | | description | string | | No | | icon_info | object | | No | -| id | string | | No | -| is_published | boolean | | No | -| name | string | | No | -| tags | [ [_AnonymousInlineModel_7b8b49ca164e](#_anonymousinlinemodel_7b8b49ca164e) ] | | No | -| type | string | | No | -| updated_at | long | | No | +| id | string | | Yes | +| is_published | boolean | | Yes | +| name | string | | Yes | +| tags | [ [SnippetTagResponse](#snippettagresponse) ] | | No | +| type | string | | Yes | +| updated_at | integer | | No | | updated_by | string | | No | -| use_count | integer | | No | -| version | integer | | No | +| use_count | integer | | Yes | +| version | integer | | Yes | #### SnippetListQuery @@ -19469,17 +19468,45 @@ Payload for running a loop node in snippet draft workflow. | ---- | ---- | ----------- | -------- | | inputs | object | | No | -#### SnippetPagination +#### SnippetPaginationResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| data | [ [_AnonymousInlineModel_744ff9cc03e6](#_anonymousinlinemodel_744ff9cc03e6) ] | | No | -| has_more | boolean | | No | -| limit | integer | | No | -| page | integer | | No | -| total | integer | | No | +| data | [ [SnippetListItemResponse](#snippetlistitemresponse) ] | | Yes | +| has_more | boolean | | Yes | +| limit | integer | | Yes | +| page | integer | | Yes | +| total | integer | | Yes | -#### SnippetUseCountResponse +#### SnippetResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| created_at | integer | | No | +| created_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | +| description | string | | No | +| graph | object | | No | +| icon_info | object | | No | +| id | string | | Yes | +| input_fields | [ object ] | | No | +| is_published | boolean | | Yes | +| name | string | | Yes | +| tags | [ [SnippetTagResponse](#snippettagresponse) ] | | No | +| type | string | | Yes | +| updated_at | integer | | No | +| updated_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | +| use_count | integer | | Yes | +| version | integer | | Yes | + +#### SnippetTagResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| id | string | | Yes | +| name | string | | Yes | +| type | string | | Yes | + +#### SnippetUseCountIncrementResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -19928,97 +19955,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 @@ -20028,13 +20005,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 @@ -20042,100 +20021,6 @@ Enum class for tool provider | ---- | ---- | ----------- | -------- | | trial_models | [ string ] | | Yes | -#### TrialPipelineVariable - -| 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 | - -#### TrialSimpleAccount - -| 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 | - #### TriggerOAuthAuthorizeResponse | Name | Type | Description | Required | @@ -21305,41 +21190,6 @@ Workflow tool configuration | data | [ [AccessPolicy](#accesspolicy) ] | | No | | pagination | [Pagination](#pagination) | | No | -#### _AnonymousInlineModel_744ff9cc03e6 - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| author_name | string | | No | -| created_at | long | | No | -| created_by | string | | No | -| description | string | | No | -| icon_info | object | | No | -| id | string | | No | -| is_published | boolean | | No | -| name | string | | No | -| tags | [ [_AnonymousInlineModel_7b8b49ca164e](#_anonymousinlinemodel_7b8b49ca164e) ] | | No | -| type | string | | No | -| updated_at | long | | No | -| updated_by | string | | No | -| use_count | integer | | No | -| version | integer | | No | - -#### _AnonymousInlineModel_7b8b49ca164e - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| id | string | | No | -| name | string | | No | -| type | string | | No | - -#### _AnonymousInlineModel_b0fd3f86d9d5 - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| email | string | | No | -| id | string | | No | -| name | string | | No | - #### _AnonymousInlineModel_b1954337d565 | Name | Type | Description | Required | diff --git a/api/tests/unit_tests/controllers/console/workspace/test_snippets.py b/api/tests/unit_tests/controllers/console/workspace/test_snippets.py index e8e005a1b83..55eee935606 100644 --- a/api/tests/unit_tests/controllers/console/workspace/test_snippets.py +++ b/api/tests/unit_tests/controllers/console/workspace/test_snippets.py @@ -1,3 +1,4 @@ +from datetime import datetime from inspect import unwrap from types import SimpleNamespace from unittest.mock import ANY, Mock @@ -46,12 +47,73 @@ def _snippet(**overrides) -> CustomizedSnippet: "name": "Snippet", "description": "Description", "type": snippets_module.SnippetType.NODE, + "version": 3, + "use_count": 7, + "is_published": True, + "icon_info": {"icon": "star", "icon_background": "#101828", "icon_type": "emoji"}, + "input_fields": '[{"label": "Question", "variable": "query", "type": "text-input"}]', "created_by": "account-1", + "created_at": datetime(2024, 1, 2, 3, 4, 5), + "updated_by": None, + "updated_at": datetime(2024, 1, 3, 4, 5, 6), } data.update(overrides) return CustomizedSnippet(**data) +def _patch_snippet_response_properties(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr( + CustomizedSnippet, + "tags", + property(lambda _snippet: [{"id": "tag-1", "name": "Search", "type": "snippet"}]), + ) + monkeypatch.setattr(CustomizedSnippet, "created_by_account", property(lambda _snippet: _account("account-1"))) + monkeypatch.setattr(CustomizedSnippet, "updated_by_account", property(lambda _snippet: None)) + + +def _expected_snippet_list_item(snippet: CustomizedSnippet) -> dict: + return { + "id": snippet.id, + "name": snippet.name, + "description": snippet.description, + "type": snippet.type, + "version": snippet.version, + "use_count": snippet.use_count, + "is_published": snippet.is_published, + "icon_info": snippet.icon_info, + "tags": [{"id": "tag-1", "name": "Search", "type": "snippet"}], + "created_by": snippet.created_by, + "author_name": "Test User", + "created_at": int(snippet.created_at.timestamp()), + "updated_by": snippet.updated_by, + "updated_at": int(snippet.updated_at.timestamp()), + } + + +def _expected_snippet_response(snippet: CustomizedSnippet) -> dict: + return { + "id": snippet.id, + "name": snippet.name, + "description": snippet.description, + "type": snippet.type, + "version": snippet.version, + "use_count": snippet.use_count, + "is_published": snippet.is_published, + "icon_info": snippet.icon_info, + "graph": {}, + "input_fields": [{"label": "Question", "variable": "query", "type": "text-input"}], + "tags": [{"id": "tag-1", "name": "Search", "type": "snippet"}], + "created_by": { + "id": "account-1", + "name": "Test User", + "email": "account-1@example.com", + }, + "created_at": int(snippet.created_at.timestamp()), + "updated_by": None, + "updated_at": int(snippet.updated_at.timestamp()), + } + + def test_normalize_snippet_list_query_args_sorts_indexed_values(): query_args = snippets_module.MultiDict( [ @@ -75,7 +137,7 @@ def test_list_snippets_returns_pagination(app: Flask, monkeypatch: pytest.Monkey tag_id = "11111111-1111-1111-1111-111111111111" get_snippets = Mock(return_value=(snippets, 1, False)) monkeypatch.setattr(snippets_module.SnippetService, "get_snippets", get_snippets) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value=[{"id": "snippet-1"}])) + _patch_snippet_response_properties(monkeypatch) api = snippets_module.CustomizedSnippetsApi() handler = unwrap(api.get) @@ -87,7 +149,7 @@ def test_list_snippets_returns_pagination(app: Flask, monkeypatch: pytest.Monkey assert status_code == 200 assert response == { - "data": [{"id": "snippet-1"}], + "data": [_expected_snippet_list_item(snippets[0])], "page": 2, "limit": 10, "total": 1, @@ -110,6 +172,7 @@ def test_create_snippet_defaults_unknown_type_and_returns_created(app: Flask, mo snippet = _snippet() create_snippet = Mock(return_value=snippet) monkeypatch.setattr(snippets_module.SnippetService, "create_snippet", create_snippet) + _patch_snippet_response_properties(monkeypatch) monkeypatch.setattr( snippets_module.CreateSnippetPayload, "model_validate", @@ -124,7 +187,6 @@ def test_create_snippet_defaults_unknown_type_and_returns_created(app: Flask, mo ) ), ) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value={"id": "snippet-1"})) api = snippets_module.CustomizedSnippetsApi() handler = unwrap(api.post) @@ -137,7 +199,7 @@ def test_create_snippet_defaults_unknown_type_and_returns_created(app: Flask, mo response, status_code = handler(api, "tenant-1", user) assert status_code == 201 - assert response == {"id": "snippet-1"} + assert response == _expected_snippet_response(snippet) assert create_snippet.call_args.kwargs["snippet_type"] == snippets_module.SnippetType.NODE @@ -184,7 +246,7 @@ def test_get_snippet_detail_raises_when_missing(app: Flask, monkeypatch: pytest. def test_get_snippet_detail_returns_snippet(app: Flask, monkeypatch: pytest.MonkeyPatch): snippet = _snippet() monkeypatch.setattr(snippets_module.SnippetService, "get_snippet_by_id", Mock(return_value=snippet)) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value={"id": "snippet-1"})) + _patch_snippet_response_properties(monkeypatch) api = snippets_module.CustomizedSnippetDetailApi() handler = unwrap(api.get) @@ -193,7 +255,7 @@ def test_get_snippet_detail_returns_snippet(app: Flask, monkeypatch: pytest.Monk response, status_code = handler(api, "tenant-1", snippet_id="snippet-1") assert status_code == 200 - assert response == {"id": "snippet-1"} + assert response == _expected_snippet_response(snippet) def test_patch_snippet_returns_400_for_empty_payload(app: Flask, monkeypatch: pytest.MonkeyPatch): @@ -230,7 +292,7 @@ def test_patch_snippet_updates_and_commits(app: Flask, monkeypatch: pytest.Monke monkeypatch.setattr(snippets_module.SnippetService, "update_snippet", update_snippet) monkeypatch.setattr(snippets_module, "Session", SessionContext) monkeypatch.setattr(snippets_module, "db", SimpleNamespace(engine=object())) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value={"id": "snippet-1", "name": "New"})) + _patch_snippet_response_properties(monkeypatch) api = snippets_module.CustomizedSnippetDetailApi() handler = unwrap(api.patch) @@ -243,7 +305,7 @@ def test_patch_snippet_updates_and_commits(app: Flask, monkeypatch: pytest.Monke response, status_code = handler(api, "tenant-1", user, snippet_id="snippet-1") assert status_code == 200 - assert response == {"id": "snippet-1", "name": "New"} + assert response == _expected_snippet_response(updated_snippet) update_snippet.assert_called_once() assert update_snippet.call_args.kwargs["data"] == { "name": "New", diff --git a/api/tests/unit_tests/fields/test_snippet_fields.py b/api/tests/unit_tests/fields/test_snippet_fields.py index ad8ee6e8f0b..233c4e5da90 100644 --- a/api/tests/unit_tests/fields/test_snippet_fields.py +++ b/api/tests/unit_tests/fields/test_snippet_fields.py @@ -1,8 +1,7 @@ from types import SimpleNamespace -from flask_restx import marshal - -from fields.snippet_fields import snippet_list_fields +from fields.snippet_fields import SnippetListItemResponse +from libs.helper import dump_response def test_snippet_list_fields_include_author_name() -> None: @@ -23,6 +22,6 @@ def test_snippet_list_fields_include_author_name() -> None: updated_at=None, ) - result = marshal(snippet, snippet_list_fields) + result = dump_response(SnippetListItemResponse, snippet) assert result["author_name"] == "Alice" diff --git a/packages/contracts/generated/api/console/agent/types.gen.ts b/packages/contracts/generated/api/console/agent/types.gen.ts index 4026c0d35eb..c5ef43f6360 100644 --- a/packages/contracts/generated/api/console/agent/types.gen.ts +++ b/packages/contracts/generated/api/console/agent/types.gen.ts @@ -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 = { @@ -878,8 +896,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 45a68beb8a6..634ab4af2d5 100644 --- a/packages/contracts/generated/api/console/agent/zod.gen.ts +++ b/packages/contracts/generated/api/console/agent/zod.gen.ts @@ -229,6 +229,36 @@ export const zJsonValue = z ]) .nullable() +/** + * 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 +270,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 */ @@ -772,60 +839,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 * diff --git a/packages/contracts/generated/api/console/apps/types.gen.ts b/packages/contracts/generated/api/console/apps/types.gen.ts index 0bf98a2dd61..ed30656edda 100644 --- a/packages/contracts/generated/api/console/apps/types.gen.ts +++ b/packages/contracts/generated/api/console/apps/types.gen.ts @@ -1223,12 +1223,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 = { @@ -1982,8 +2000,6 @@ export type ModelConfigPartial = { updated_by?: string | null } -export type LlmMode = 'chat' | 'completion' - export type Type = | 'app-selector' | 'array[tools]' diff --git a/packages/contracts/generated/api/console/apps/zod.gen.ts b/packages/contracts/generated/api/console/apps/zod.gen.ts index f27f2177bc6..ab8a2081c85 100644 --- a/packages/contracts/generated/api/console/apps/zod.gen.ts +++ b/packages/contracts/generated/api/console/apps/zod.gen.ts @@ -889,6 +889,36 @@ export const zJsonValue = z */ export const zGeneratedAppResponse = zJsonValue +/** + * 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 */ @@ -900,6 +930,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 */ @@ -1118,6 +1208,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 */ @@ -1996,102 +2105,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(), -}) - /** * Type */ 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..08dc7f85248 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,42 @@ 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 + = | string + | number + | number + | boolean + | { + [key: string]: unknown + } + | Array + | null 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..cbffd4478f7 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,45 @@ 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 + .union([ + z.string(), + z.int(), + z.number(), + z.boolean(), + z.record(z.string(), z.unknown()), + z.array(z.unknown()), + ]) + .nullable() /** * 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/rule-code-generate/types.gen.ts b/packages/contracts/generated/api/console/rule-code-generate/types.gen.ts index a1165a4f8a2..4883b92063d 100644 --- a/packages/contracts/generated/api/console/rule-code-generate/types.gen.ts +++ b/packages/contracts/generated/api/console/rule-code-generate/types.gen.ts @@ -14,15 +14,42 @@ export type RuleCodeGeneratePayload = { export type GeneratorResponse = unknown 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 + = | string + | number + | number + | boolean + | { + [key: string]: unknown + } + | Array + | null export type PostRuleCodeGenerateData = { body: RuleCodeGeneratePayload diff --git a/packages/contracts/generated/api/console/rule-code-generate/zod.gen.ts b/packages/contracts/generated/api/console/rule-code-generate/zod.gen.ts index 97e1b816289..0536774a0c9 100644 --- a/packages/contracts/generated/api/console/rule-code-generate/zod.gen.ts +++ b/packages/contracts/generated/api/console/rule-code-generate/zod.gen.ts @@ -7,21 +7,45 @@ import * as z from 'zod' */ export const zGeneratorResponse = z.unknown() -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) +export const zJsonValue = z + .union([ + z.string(), + z.int(), + z.number(), + z.boolean(), + z.record(z.string(), z.unknown()), + z.array(z.unknown()), + ]) + .nullable() /** * 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/rule-generate/types.gen.ts b/packages/contracts/generated/api/console/rule-generate/types.gen.ts index 4e7c1421461..9a09a91374a 100644 --- a/packages/contracts/generated/api/console/rule-generate/types.gen.ts +++ b/packages/contracts/generated/api/console/rule-generate/types.gen.ts @@ -13,15 +13,42 @@ export type RuleGeneratePayload = { export type GeneratorResponse = unknown 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 + = | string + | number + | number + | boolean + | { + [key: string]: unknown + } + | Array + | null export type PostRuleGenerateData = { body: RuleGeneratePayload diff --git a/packages/contracts/generated/api/console/rule-generate/zod.gen.ts b/packages/contracts/generated/api/console/rule-generate/zod.gen.ts index 6e539e63f4e..b1f31427366 100644 --- a/packages/contracts/generated/api/console/rule-generate/zod.gen.ts +++ b/packages/contracts/generated/api/console/rule-generate/zod.gen.ts @@ -7,21 +7,45 @@ import * as z from 'zod' */ export const zGeneratorResponse = z.unknown() -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) +export const zJsonValue = z + .union([ + z.string(), + z.int(), + z.number(), + z.boolean(), + z.record(z.string(), z.unknown()), + z.array(z.unknown()), + ]) + .nullable() /** * 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/rule-structured-output-generate/types.gen.ts b/packages/contracts/generated/api/console/rule-structured-output-generate/types.gen.ts index f7da1cd5cc8..c2b459fee56 100644 --- a/packages/contracts/generated/api/console/rule-structured-output-generate/types.gen.ts +++ b/packages/contracts/generated/api/console/rule-structured-output-generate/types.gen.ts @@ -12,15 +12,42 @@ export type RuleStructuredOutputPayload = { export type GeneratorResponse = unknown 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 + = | string + | number + | number + | boolean + | { + [key: string]: unknown + } + | Array + | null export type PostRuleStructuredOutputGenerateData = { body: RuleStructuredOutputPayload diff --git a/packages/contracts/generated/api/console/rule-structured-output-generate/zod.gen.ts b/packages/contracts/generated/api/console/rule-structured-output-generate/zod.gen.ts index 6119b0010d0..0929fccae64 100644 --- a/packages/contracts/generated/api/console/rule-structured-output-generate/zod.gen.ts +++ b/packages/contracts/generated/api/console/rule-structured-output-generate/zod.gen.ts @@ -7,21 +7,45 @@ import * as z from 'zod' */ export const zGeneratorResponse = z.unknown() -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) +export const zJsonValue = z + .union([ + z.string(), + z.int(), + z.number(), + z.boolean(), + z.record(z.string(), z.unknown()), + z.array(z.unknown()), + ]) + .nullable() /** * 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/trial-apps/orpc.gen.ts b/packages/contracts/generated/api/console/trial-apps/orpc.gen.ts index ebc2624fa19..35859bf863e 100644 --- a/packages/contracts/generated/api/console/trial-apps/orpc.gen.ts +++ b/packages/contracts/generated/api/console/trial-apps/orpc.gen.ts @@ -19,18 +19,9 @@ import { zGetTrialAppsByAppIdWorkflowsResponse, zPostTrialAppsByAppIdAudioToTextPath, zPostTrialAppsByAppIdAudioToTextResponse, - zPostTrialAppsByAppIdChatMessagesBody, - zPostTrialAppsByAppIdChatMessagesPath, - zPostTrialAppsByAppIdChatMessagesResponse, - zPostTrialAppsByAppIdCompletionMessagesBody, - zPostTrialAppsByAppIdCompletionMessagesPath, - zPostTrialAppsByAppIdCompletionMessagesResponse, zPostTrialAppsByAppIdTextToAudioBody, zPostTrialAppsByAppIdTextToAudioPath, zPostTrialAppsByAppIdTextToAudioResponse, - zPostTrialAppsByAppIdWorkflowsRunBody, - zPostTrialAppsByAppIdWorkflowsRunPath, - zPostTrialAppsByAppIdWorkflowsRunResponse, zPostTrialAppsByAppIdWorkflowsTasksByTaskIdStopPath, zPostTrialAppsByAppIdWorkflowsTasksByTaskIdStopResponse, } from './zod.gen' @@ -50,46 +41,6 @@ export const audioToText = { post, } -export const post2 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postTrialAppsByAppIdChatMessages', - path: '/trial-apps/{app_id}/chat-messages', - tags: ['console'], - }) - .input( - z.object({ - body: zPostTrialAppsByAppIdChatMessagesBody, - params: zPostTrialAppsByAppIdChatMessagesPath, - }), - ) - .output(zPostTrialAppsByAppIdChatMessagesResponse) - -export const chatMessages = { - post: post2, -} - -export const post3 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postTrialAppsByAppIdCompletionMessages', - path: '/trial-apps/{app_id}/completion-messages', - tags: ['console'], - }) - .input( - z.object({ - body: zPostTrialAppsByAppIdCompletionMessagesBody, - params: zPostTrialAppsByAppIdCompletionMessagesPath, - }), - ) - .output(zPostTrialAppsByAppIdCompletionMessagesResponse) - -export const completionMessages = { - post: post3, -} - export const get = oc .route({ inputStructure: 'detailed', @@ -175,7 +126,7 @@ export const site = { get: get4, } -export const post4 = oc +export const post2 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -192,37 +143,13 @@ export const post4 = oc .output(zPostTrialAppsByAppIdTextToAudioResponse) export const textToAudio = { - post: post4, -} - -/** - * Run workflow - */ -export const post5 = oc - .route({ - inputStructure: 'detailed', - method: 'POST', - operationId: 'postTrialAppsByAppIdWorkflowsRun', - path: '/trial-apps/{app_id}/workflows/run', - summary: 'Run workflow', - tags: ['console'], - }) - .input( - z.object({ - body: zPostTrialAppsByAppIdWorkflowsRunBody, - params: zPostTrialAppsByAppIdWorkflowsRunPath, - }), - ) - .output(zPostTrialAppsByAppIdWorkflowsRunResponse) - -export const run = { - post: post5, + post: post2, } /** * Stop workflow task */ -export const post6 = oc +export const post3 = oc .route({ inputStructure: 'detailed', method: 'POST', @@ -235,7 +162,7 @@ export const post6 = oc .output(zPostTrialAppsByAppIdWorkflowsTasksByTaskIdStopResponse) export const stop = { - post: post6, + post: post3, } export const byTaskId = { @@ -263,7 +190,6 @@ export const get5 = oc export const workflows = { get: get5, - run, tasks, } @@ -285,8 +211,6 @@ export const get6 = oc export const byAppId = { get: get6, audioToText, - chatMessages, - completionMessages, datasets, messages, parameters, diff --git a/packages/contracts/generated/api/console/trial-apps/types.gen.ts b/packages/contracts/generated/api/console/trial-apps/types.gen.ts index 894da1102ee..e6892fbfcf5 100644 --- a/packages/contracts/generated/api/console/trial-apps/types.gen.ts +++ b/packages/contracts/generated/api/console/trial-apps/types.gen.ts @@ -4,66 +4,47 @@ export type ClientOptions = { baseUrl: `${string}://${string}/console/api` | (string & {}) } -export type TrialAppDetailWithSite = { - access_mode?: string - api_base_url?: string - created_at?: number - created_by?: string - deleted_tools?: Array - description?: string - enable_api?: boolean - enable_site?: boolean - icon?: string - icon_background?: string - icon_type?: string - icon_url?: string - id?: string - max_active_requests?: number - mode?: string - model_config?: TrialAppModelConfig - name?: string +export type AppDetailWithSite = { + access_mode?: string | null + api_base_url?: string | null + app_id?: string | null + bound_agent_id?: string | null + created_at?: number | null + created_by?: string | null + deleted_tools?: Array + description?: string | null + enable_api: boolean + enable_site: boolean + icon?: string | null + icon_background?: string | null + icon_type?: string | null + readonly icon_url: string | null + id: string + maintainer?: string | null + max_active_requests?: number | null + mode: string + model_config?: ModelConfig | null + name: string permission_keys?: Array - site?: TrialSite - tags?: Array - updated_at?: number - updated_by?: string - use_icon_as_answer_icon?: boolean - workflow?: TrialWorkflowPartial + site?: Site | null + tags?: Array + tracing?: JsonValue | null + updated_at?: number | null + updated_by?: string | null + use_icon_as_answer_icon?: boolean | null + workflow?: WorkflowPartial | null } export type AudioTranscriptResponse = { text: string } -export type ChatRequest = { - conversation_id?: string | null - files?: Array | null - inputs: { - [key: string]: unknown - } - parent_message_id?: string | null - query: string - retriever_from?: string -} - -export type GeneratedAppResponse = JsonValue - -export type CompletionRequest = { - files?: Array | null - inputs: { - [key: string]: unknown - } - query?: string - response_mode?: 'blocking' | 'streaming' | null - retriever_from?: string -} - -export type TrialDatasetList = { - data?: Array - has_more?: boolean - limit?: number - page?: number - total?: number +export type TrialDatasetListResponse = { + data: Array + has_more: boolean + limit: number + page: number + total: number } export type SuggestedQuestionsResponse = { @@ -111,143 +92,69 @@ export type TextToSpeechRequest = { export type AudioBinaryResponse = Blob | File -export type TrialWorkflow = { - conversation_variables?: Array - created_at?: number - created_by?: TrialSimpleAccount - environment_variables?: Array<{ - [key: string]: unknown - }> - features?: { +export type WorkflowResponse = { + conversation_variables: Array + created_at: number + created_by?: SimpleAccountResponse | null + environment_variables: Array + features: { [key: string]: unknown } - graph?: { - [key: string]: unknown - } - hash?: string - id?: string - marked_comment?: string - marked_name?: string - rag_pipeline_variables?: Array - tool_published?: boolean - updated_at?: number - updated_by?: TrialSimpleAccount - version?: string -} - -export type WorkflowRunRequest = { - files?: Array | null - inputs: { + graph: { [key: string]: unknown } + hash: string + id: string + marked_comment: string + marked_name: string + rag_pipeline_variables: Array + tool_published: boolean + updated_at: number + updated_by?: SimpleAccountResponse | null + version: string } export type SimpleResultResponse = { result: string } -export type TrialDeletedTool = { - provider_id?: string - tool_name?: string - type?: string +export type DeletedTool = { + provider_id: string + tool_name: string + type: string } -export type TrialAppModelConfig = { - agent_mode?: { - [key: string]: unknown - } - annotation_reply?: { - [key: string]: unknown - } - chat_prompt_config?: { - [key: string]: unknown - } - completion_prompt_config?: { - [key: string]: unknown - } - created_at?: number - created_by?: string - dataset_configs?: { - [key: string]: unknown - } - dataset_query_variable?: string - external_data_tools?: Array<{ - [key: string]: unknown - }> - file_upload?: { - [key: string]: unknown - } - model?: { - [key: string]: unknown - } - more_like_this?: { - [key: string]: unknown - } - opening_statement?: string - pre_prompt?: string - prompt_type?: string - retriever_resource?: { - [key: string]: unknown - } - sensitive_word_avoidance?: { - [key: string]: unknown - } - speech_to_text?: { - [key: string]: unknown - } - suggested_questions?: Array - suggested_questions_after_answer?: { - [key: string]: unknown - } - text_to_speech?: { - [key: string]: unknown - } - updated_at?: number - updated_by?: string - user_input_form?: Array<{ - [key: string]: unknown - }> +export type ModelConfig = { + 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 TrialSite = { - access_token?: string - app_base_url?: string - chat_color_theme?: string - chat_color_theme_inverted?: boolean - code?: string - copyright?: string - created_at?: number - created_by?: string - custom_disclaimer?: string - customize_domain?: string - customize_token_strategy?: string - default_language?: string - description?: string - icon?: string - icon_background?: string - icon_type?: string - icon_url?: string - privacy_policy?: string - prompt_public?: boolean - show_workflow_steps?: boolean - title?: string - updated_at?: number - updated_by?: string - use_icon_as_answer_icon?: boolean -} - -export type TrialTag = { - id?: string - name?: string - type?: string -} - -export type TrialWorkflowPartial = { - created_at?: number - created_by?: string - id?: string - updated_at?: number - updated_by?: string +export type Tag = { + id: string + name: string + type: string } export type JsonValue @@ -261,16 +168,52 @@ export type JsonValue | Array | null -export type TrialDataset = { - created_at?: number - created_by?: string - data_source_type?: string - description?: string - id?: string - indexing_technique?: string - name?: string - permission?: string +export type WorkflowPartial = { + created_at?: number | null + created_by?: string | null + id: string + updated_at?: number | null + updated_by?: string | null +} + +export type TrialDatasetListItemResponse = { + app_count: number + author_name: string | null + built_in_field_enabled: boolean + chunk_structure: string | null + created_at: number + created_by: string + data_source_type: string | null + description: string | null + doc_form: string | null + doc_metadata: Array + document_count: number + embedding_available?: boolean | null + embedding_model: string | null + embedding_model_provider: string | null + enable_api: boolean + external_knowledge_info?: DatasetExternalKnowledgeInfoResponse + external_retrieval_model: DatasetExternalRetrievalModelResponse | null + icon_info?: DatasetIconInfoResponse + id: string + indexing_technique: string | null + is_multimodal: boolean + is_published: boolean + maintainer?: string | null + name: string + permission: string permission_keys?: Array + pipeline_id: string | null + provider: string + retrieval_model_dict: DatasetRetrievalModelResponse + runtime_mode: string | null + summary_index_setting?: DatasetSummaryIndexSettingResponse + tags: Array + total_available_documents: number + total_documents: number + updated_at: number + updated_by: string | null + word_count: number } export type JsonObject = { @@ -285,56 +228,145 @@ export type SystemParameters = { workflow_file_upload_limit: number } -export type TrialConversationVariable = { - description?: string - id?: string - name?: string - value?: - | string - | number - | number - | boolean - | { - [key: string]: unknown - } - | Array - | null - value_type?: string +export type WorkflowConversationVariableResponse = { + description: string + id: string + name: string + value: unknown + value_type: string } -export type TrialSimpleAccount = { - email?: string - id?: string - name?: string +export type SimpleAccountResponse = { + email: string + id: string + name: string } -export type TrialPipelineVariable = { - allow_file_extension?: Array - allow_file_upload_methods?: Array - allowed_file_types?: Array - belong_to_node_id?: string - default_value?: - | string - | number - | number - | boolean - | { - [key: string]: unknown - } - | Array - | null - label?: string - max_length?: number - options?: Array - placeholder?: string - required?: boolean - tooltips?: string - type?: string - unit?: string - variable?: string +export type WorkflowEnvironmentVariableResponse = { + description: string + id: string + name: string + value: unknown + value_type: string } -export type GeneratedAppResponseWritable = JsonValue +export type PipelineVariableResponse = { + allowed_file_extensions?: Array | null + allowed_file_types?: Array | null + allowed_file_upload_methods?: Array | null + belong_to_node_id: string + default_value?: unknown + label: string + max_length?: number | null + options?: Array | null + placeholder?: string | null + required: boolean + tooltips?: string | null + type: string + unit?: string | null + variable: string +} + +export type DatasetDocMetadataResponse = { + id: string + name: string + type: string +} + +export type DatasetExternalKnowledgeInfoResponse = { + external_knowledge_api_endpoint?: string | null + external_knowledge_api_id?: string | null + external_knowledge_api_name?: string | null + external_knowledge_id?: string | null +} + +export type DatasetExternalRetrievalModelResponse = { + score_threshold?: number | null + score_threshold_enabled?: boolean | null + top_k: number +} + +export type DatasetIconInfoResponse = { + icon?: string | null + icon_background?: string | null + icon_type?: string | null + icon_url?: string | null +} + +export type DatasetRetrievalModelResponse = { + reranking_enable: boolean + reranking_mode?: string | null + reranking_model?: DatasetRerankingModelResponse + score_threshold?: number | null + score_threshold_enabled: boolean + search_method: string + top_k: number + weights?: DatasetWeightedScoreResponse | null +} + +export type DatasetSummaryIndexSettingResponse = { + enable?: boolean | null + model_name?: string | null + model_provider_name?: string | null + summary_prompt?: string | null +} + +export type DatasetTagResponse = { + id: string + name: string + type: string +} + +export type DatasetRerankingModelResponse = { + reranking_model_name?: string | null + reranking_provider_name?: string | null +} + +export type DatasetWeightedScoreResponse = { + keyword_setting?: DatasetKeywordSettingResponse + vector_setting?: DatasetVectorSettingResponse + weight_type?: string | null +} + +export type DatasetKeywordSettingResponse = { + keyword_weight?: number | null +} + +export type DatasetVectorSettingResponse = { + embedding_model_name?: string | null + embedding_provider_name?: string | null + vector_weight?: number | null +} + +export type AppDetailWithSiteWritable = { + access_mode?: string | null + api_base_url?: string | null + app_id?: string | null + bound_agent_id?: string | null + created_at?: number | null + created_by?: string | null + deleted_tools?: Array + description?: string | null + enable_api: boolean + enable_site: boolean + icon?: string | null + icon_background?: string | null + icon_type?: string | null + id: string + maintainer?: string | null + max_active_requests?: number | null + mode: string + model_config?: ModelConfig | null + name: string + permission_keys?: Array + site?: SiteWritable | null + tags?: Array + tracing?: JsonValue | null + updated_at?: number | null + updated_by?: string | null + use_icon_as_answer_icon?: boolean | null + workflow?: WorkflowPartial | null +} export type SiteWritable = { chat_color_theme?: string | null @@ -362,7 +394,7 @@ export type GetTrialAppsByAppIdData = { } export type GetTrialAppsByAppIdResponses = { - 200: TrialAppDetailWithSite + 200: AppDetailWithSite } export type GetTrialAppsByAppIdResponse @@ -384,38 +416,6 @@ export type PostTrialAppsByAppIdAudioToTextResponses = { export type PostTrialAppsByAppIdAudioToTextResponse = PostTrialAppsByAppIdAudioToTextResponses[keyof PostTrialAppsByAppIdAudioToTextResponses] -export type PostTrialAppsByAppIdChatMessagesData = { - body: ChatRequest - path: { - app_id: string - } - query?: never - url: '/trial-apps/{app_id}/chat-messages' -} - -export type PostTrialAppsByAppIdChatMessagesResponses = { - 200: GeneratedAppResponse -} - -export type PostTrialAppsByAppIdChatMessagesResponse - = PostTrialAppsByAppIdChatMessagesResponses[keyof PostTrialAppsByAppIdChatMessagesResponses] - -export type PostTrialAppsByAppIdCompletionMessagesData = { - body: CompletionRequest - path: { - app_id: string - } - query?: never - url: '/trial-apps/{app_id}/completion-messages' -} - -export type PostTrialAppsByAppIdCompletionMessagesResponses = { - 200: GeneratedAppResponse -} - -export type PostTrialAppsByAppIdCompletionMessagesResponse - = PostTrialAppsByAppIdCompletionMessagesResponses[keyof PostTrialAppsByAppIdCompletionMessagesResponses] - export type GetTrialAppsByAppIdDatasetsData = { body?: never path: { @@ -430,7 +430,7 @@ export type GetTrialAppsByAppIdDatasetsData = { } export type GetTrialAppsByAppIdDatasetsResponses = { - 200: TrialDatasetList + 200: TrialDatasetListResponse } export type GetTrialAppsByAppIdDatasetsResponse @@ -511,28 +511,12 @@ export type GetTrialAppsByAppIdWorkflowsData = { } export type GetTrialAppsByAppIdWorkflowsResponses = { - 200: TrialWorkflow + 200: WorkflowResponse } export type GetTrialAppsByAppIdWorkflowsResponse = GetTrialAppsByAppIdWorkflowsResponses[keyof GetTrialAppsByAppIdWorkflowsResponses] -export type PostTrialAppsByAppIdWorkflowsRunData = { - body: WorkflowRunRequest - path: { - app_id: string - } - query?: never - url: '/trial-apps/{app_id}/workflows/run' -} - -export type PostTrialAppsByAppIdWorkflowsRunResponses = { - 200: GeneratedAppResponse -} - -export type PostTrialAppsByAppIdWorkflowsRunResponse - = PostTrialAppsByAppIdWorkflowsRunResponses[keyof PostTrialAppsByAppIdWorkflowsRunResponses] - export type PostTrialAppsByAppIdWorkflowsTasksByTaskIdStopData = { body?: never path: { diff --git a/packages/contracts/generated/api/console/trial-apps/zod.gen.ts b/packages/contracts/generated/api/console/trial-apps/zod.gen.ts index b8768790ef9..74402a204a1 100644 --- a/packages/contracts/generated/api/console/trial-apps/zod.gen.ts +++ b/packages/contracts/generated/api/console/trial-apps/zod.gen.ts @@ -9,29 +9,6 @@ export const zAudioTranscriptResponse = z.object({ text: z.string(), }) -/** - * ChatRequest - */ -export const zChatRequest = z.object({ - conversation_id: z.string().nullish(), - files: z.array(z.unknown()).nullish(), - inputs: z.record(z.string(), z.unknown()), - parent_message_id: z.string().nullish(), - query: z.string(), - retriever_from: z.string().optional().default('explore_app'), -}) - -/** - * CompletionRequest - */ -export const zCompletionRequest = z.object({ - files: z.array(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'), -}) - /** * SuggestedQuestionsResponse */ @@ -74,14 +51,6 @@ export const zTextToSpeechRequest = z.object({ */ export const zAudioBinaryResponse = z.custom() -/** - * WorkflowRunRequest - */ -export const zWorkflowRunRequest = z.object({ - files: z.array(z.unknown()).nullish(), - inputs: z.record(z.string(), z.unknown()), -}) - /** * SimpleResultResponse */ @@ -89,169 +58,22 @@ export const zSimpleResultResponse = z.object({ result: z.string(), }) -export const zTrialDeletedTool = z.object({ - provider_id: z.string().optional(), - tool_name: z.string().optional(), - type: z.string().optional(), +/** + * DeletedTool + */ +export const zDeletedTool = z.object({ + provider_id: z.string(), + tool_name: z.string(), + type: z.string(), }) -export const zTrialAppModelConfig = z.object({ - agent_mode: z.record(z.string(), z.unknown()).optional(), - annotation_reply: z.record(z.string(), z.unknown()).optional(), - chat_prompt_config: z.record(z.string(), z.unknown()).optional(), - completion_prompt_config: z.record(z.string(), z.unknown()).optional(), - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - dataset_configs: z.record(z.string(), z.unknown()).optional(), - dataset_query_variable: z.string().optional(), - external_data_tools: z.array(z.record(z.string(), z.unknown())).optional(), - file_upload: z.record(z.string(), z.unknown()).optional(), - model: z.record(z.string(), z.unknown()).optional(), - more_like_this: z.record(z.string(), z.unknown()).optional(), - opening_statement: z.string().optional(), - pre_prompt: z.string().optional(), - prompt_type: z.string().optional(), - retriever_resource: z.record(z.string(), z.unknown()).optional(), - sensitive_word_avoidance: z.record(z.string(), z.unknown()).optional(), - speech_to_text: z.record(z.string(), z.unknown()).optional(), - suggested_questions: z.array(z.string()).optional(), - suggested_questions_after_answer: z.record(z.string(), z.unknown()).optional(), - text_to_speech: z.record(z.string(), z.unknown()).optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: z.string().optional(), - user_input_form: z.array(z.record(z.string(), z.unknown())).optional(), -}) - -export const zTrialSite = z.object({ - access_token: z.string().optional(), - app_base_url: z.string().optional(), - chat_color_theme: z.string().optional(), - chat_color_theme_inverted: z.boolean().optional(), - code: z.string().optional(), - copyright: z.string().optional(), - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - custom_disclaimer: z.string().optional(), - customize_domain: z.string().optional(), - customize_token_strategy: z.string().optional(), - default_language: z.string().optional(), - description: z.string().optional(), - icon: z.string().optional(), - icon_background: z.string().optional(), - icon_type: z.string().optional(), - icon_url: z.string().optional(), - privacy_policy: z.string().optional(), - prompt_public: z.boolean().optional(), - show_workflow_steps: z.boolean().optional(), - title: z.string().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: z.string().optional(), - use_icon_as_answer_icon: z.boolean().optional(), -}) - -export const zTrialTag = z.object({ - id: z.string().optional(), - name: z.string().optional(), - type: z.string().optional(), -}) - -export const zTrialWorkflowPartial = z.object({ - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - id: z.string().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: z.string().optional(), -}) - -export const zTrialAppDetailWithSite = z.object({ - access_mode: z.string().optional(), - api_base_url: z.string().optional(), - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - deleted_tools: z.array(zTrialDeletedTool).optional(), - description: z.string().optional(), - enable_api: z.boolean().optional(), - enable_site: z.boolean().optional(), - icon: z.string().optional(), - icon_background: z.string().optional(), - icon_type: z.string().optional(), - icon_url: z.string().optional(), - id: z.string().optional(), - max_active_requests: z.int().optional(), - mode: z.string().optional(), - model_config: zTrialAppModelConfig.optional(), - name: z.string().optional(), - permission_keys: z.array(z.string()).optional(), - site: zTrialSite.optional(), - tags: z.array(zTrialTag).optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: z.string().optional(), - use_icon_as_answer_icon: z.boolean().optional(), - workflow: zTrialWorkflowPartial.optional(), +/** + * Tag + */ +export const zTag = z.object({ + id: z.string(), + name: z.string(), + type: z.string(), }) export const zJsonValue = z @@ -266,36 +88,78 @@ export const zJsonValue = z .nullable() /** - * GeneratedAppResponse + * ModelConfig */ -export const zGeneratedAppResponse = zJsonValue - -export const zTrialDataset = z.object({ - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - data_source_type: z.string().optional(), - description: z.string().optional(), - id: z.string().optional(), - indexing_technique: z.string().optional(), - name: z.string().optional(), - permission: z.string().optional(), - permission_keys: z.array(z.string()).optional(), +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(), }) -export const zTrialDatasetList = z.object({ - data: z.array(zTrialDataset).optional(), - has_more: z.boolean().optional(), - limit: z.int().optional(), - page: z.int().optional(), - total: z.int().optional(), +/** + * WorkflowPartial + */ +export const zWorkflowPartial = z.object({ + created_at: z.int().nullish(), + created_by: z.string().nullish(), + id: z.string(), + updated_at: z.int().nullish(), + 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(), }) export const zJsonObject = z.record(z.string(), z.unknown()) @@ -329,93 +193,235 @@ export const zParameters = z.object({ user_input_form: z.array(zJsonObject), }) -export const zTrialConversationVariable = z.object({ - description: z.string().optional(), - id: z.string().optional(), - name: z.string().optional(), - value: z - .union([ - z.string(), - z.int(), - z.number(), - z.boolean(), - z.record(z.string(), z.unknown()), - z.array(z.unknown()), - ]) - .nullish(), - value_type: z.string().optional(), -}) - -export const zTrialSimpleAccount = z.object({ - email: z.string().optional(), - id: z.string().optional(), - name: z.string().optional(), -}) - -export const zTrialPipelineVariable = z.object({ - allow_file_extension: z.array(z.string()).optional(), - allow_file_upload_methods: z.array(z.string()).optional(), - allowed_file_types: z.array(z.string()).optional(), - belong_to_node_id: z.string().optional(), - default_value: z - .union([ - z.string(), - z.int(), - z.number(), - z.boolean(), - z.record(z.string(), z.unknown()), - z.array(z.unknown()), - ]) - .nullish(), - label: z.string().optional(), - max_length: z.int().optional(), - options: z.array(z.string()).optional(), - placeholder: z.string().optional(), - required: z.boolean().optional(), - tooltips: z.string().optional(), - type: z.string().optional(), - unit: z.string().optional(), - variable: z.string().optional(), -}) - -export const zTrialWorkflow = z.object({ - conversation_variables: z.array(zTrialConversationVariable).optional(), - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: zTrialSimpleAccount.optional(), - environment_variables: z.array(z.record(z.string(), z.unknown())).optional(), - features: z.record(z.string(), z.unknown()).optional(), - graph: z.record(z.string(), z.unknown()).optional(), - hash: z.string().optional(), - id: z.string().optional(), - marked_comment: z.string().optional(), - marked_name: z.string().optional(), - rag_pipeline_variables: z.array(zTrialPipelineVariable).optional(), - tool_published: z.boolean().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: zTrialSimpleAccount.optional(), - version: z.string().optional(), +/** + * WorkflowConversationVariableResponse + */ +export const zWorkflowConversationVariableResponse = z.object({ + description: z.string(), + id: z.string(), + name: z.string(), + value: z.unknown(), + value_type: z.string(), }) /** - * GeneratedAppResponse + * SimpleAccountResponse */ -export const zGeneratedAppResponseWritable = zJsonValue +export const zSimpleAccountResponse = z.object({ + email: z.string(), + id: z.string(), + name: z.string(), +}) + +/** + * WorkflowEnvironmentVariableResponse + */ +export const zWorkflowEnvironmentVariableResponse = z.object({ + description: z.string(), + id: z.string(), + name: z.string(), + value: z.unknown(), + value_type: z.string(), +}) + +/** + * PipelineVariableResponse + */ +export const zPipelineVariableResponse = z.object({ + allowed_file_extensions: z.array(z.string()).nullish(), + allowed_file_types: z.array(z.string()).nullish(), + allowed_file_upload_methods: z.array(z.string()).nullish(), + belong_to_node_id: z.string(), + default_value: z.unknown().optional(), + label: z.string(), + max_length: z.int().nullish(), + options: z.array(z.string()).nullish(), + placeholder: z.string().nullish(), + required: z.boolean(), + tooltips: z.string().nullish(), + type: z.string(), + unit: z.string().nullish(), + variable: z.string(), +}) + +/** + * WorkflowResponse + */ +export const zWorkflowResponse = z.object({ + conversation_variables: z.array(zWorkflowConversationVariableResponse), + created_at: z.int(), + created_by: zSimpleAccountResponse.nullish(), + environment_variables: z.array(zWorkflowEnvironmentVariableResponse), + features: z.record(z.string(), z.unknown()), + graph: z.record(z.string(), z.unknown()), + hash: z.string(), + id: z.string(), + marked_comment: z.string(), + marked_name: z.string(), + rag_pipeline_variables: z.array(zPipelineVariableResponse), + tool_published: z.boolean(), + updated_at: z.int(), + updated_by: zSimpleAccountResponse.nullish(), + version: z.string(), +}) + +/** + * DatasetDocMetadataResponse + */ +export const zDatasetDocMetadataResponse = z.object({ + id: z.string(), + name: z.string(), + type: z.string(), +}) + +/** + * DatasetExternalKnowledgeInfoResponse + */ +export const zDatasetExternalKnowledgeInfoResponse = z.object({ + external_knowledge_api_endpoint: z.string().nullish(), + external_knowledge_api_id: z.string().nullish(), + external_knowledge_api_name: z.string().nullish(), + external_knowledge_id: z.string().nullish(), +}) + +/** + * DatasetExternalRetrievalModelResponse + */ +export const zDatasetExternalRetrievalModelResponse = z.object({ + score_threshold: z.number().nullish(), + score_threshold_enabled: z.boolean().nullish(), + top_k: z.int(), +}) + +/** + * DatasetIconInfoResponse + */ +export const zDatasetIconInfoResponse = z.object({ + icon: z.string().nullish(), + icon_background: z.string().nullish(), + icon_type: z.string().nullish(), + icon_url: z.string().nullish(), +}) + +/** + * DatasetSummaryIndexSettingResponse + */ +export const zDatasetSummaryIndexSettingResponse = z.object({ + enable: z.boolean().nullish(), + model_name: z.string().nullish(), + model_provider_name: z.string().nullish(), + summary_prompt: z.string().nullish(), +}) + +/** + * DatasetTagResponse + */ +export const zDatasetTagResponse = z.object({ + id: z.string(), + name: z.string(), + type: z.string(), +}) + +/** + * DatasetRerankingModelResponse + */ +export const zDatasetRerankingModelResponse = z.object({ + reranking_model_name: z.string().nullish(), + reranking_provider_name: z.string().nullish(), +}) + +/** + * DatasetKeywordSettingResponse + */ +export const zDatasetKeywordSettingResponse = z.object({ + keyword_weight: z.number().nullish(), +}) + +/** + * DatasetVectorSettingResponse + */ +export const zDatasetVectorSettingResponse = z.object({ + embedding_model_name: z.string().nullish(), + embedding_provider_name: z.string().nullish(), + vector_weight: z.number().nullish(), +}) + +/** + * DatasetWeightedScoreResponse + */ +export const zDatasetWeightedScoreResponse = z.object({ + keyword_setting: zDatasetKeywordSettingResponse.optional(), + vector_setting: zDatasetVectorSettingResponse.optional(), + weight_type: z.string().nullish(), +}) + +/** + * DatasetRetrievalModelResponse + */ +export const zDatasetRetrievalModelResponse = z.object({ + reranking_enable: z.boolean(), + reranking_mode: z.string().nullish(), + reranking_model: zDatasetRerankingModelResponse.optional(), + score_threshold: z.number().nullish(), + score_threshold_enabled: z.boolean(), + search_method: z.string(), + top_k: z.int(), + weights: zDatasetWeightedScoreResponse.nullish(), +}) + +/** + * TrialDatasetListItemResponse + */ +export const zTrialDatasetListItemResponse = z.object({ + app_count: z.int(), + author_name: z.string().nullable(), + built_in_field_enabled: z.boolean(), + chunk_structure: z.string().nullable(), + created_at: z.int(), + created_by: z.string(), + data_source_type: z.string().nullable(), + description: z.string().nullable(), + doc_form: z.string().nullable(), + doc_metadata: z.array(zDatasetDocMetadataResponse), + document_count: z.int(), + embedding_available: z.boolean().nullish(), + embedding_model: z.string().nullable(), + embedding_model_provider: z.string().nullable(), + enable_api: z.boolean(), + external_knowledge_info: zDatasetExternalKnowledgeInfoResponse.optional(), + external_retrieval_model: zDatasetExternalRetrievalModelResponse.nullable(), + icon_info: zDatasetIconInfoResponse.optional(), + id: z.string(), + indexing_technique: z.string().nullable(), + is_multimodal: z.boolean(), + is_published: z.boolean(), + maintainer: z.string().nullish(), + name: z.string(), + permission: z.string(), + permission_keys: z.array(z.string()).optional(), + pipeline_id: z.string().nullable(), + provider: z.string(), + retrieval_model_dict: zDatasetRetrievalModelResponse, + runtime_mode: z.string().nullable(), + summary_index_setting: zDatasetSummaryIndexSettingResponse.optional(), + tags: z.array(zDatasetTagResponse), + total_available_documents: z.int(), + total_documents: z.int(), + updated_at: z.int(), + updated_by: z.string().nullable(), + word_count: z.int(), +}) + +/** + * TrialDatasetListResponse + */ +export const zTrialDatasetListResponse = z.object({ + data: z.array(zTrialDatasetListItemResponse), + has_more: z.boolean(), + limit: z.int(), + page: z.int(), + total: z.int(), +}) /** * Site @@ -436,14 +442,47 @@ export const zSiteWritable = z.object({ use_icon_as_answer_icon: z.boolean(), }) +/** + * AppDetailWithSite + */ +export const zAppDetailWithSiteWritable = 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(), + 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: zSiteWritable.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(), +}) + export const zGetTrialAppsByAppIdPath = z.object({ app_id: z.uuid(), }) /** - * Success + * App detail retrieved successfully */ -export const zGetTrialAppsByAppIdResponse = zTrialAppDetailWithSite +export const zGetTrialAppsByAppIdResponse = zAppDetailWithSite export const zPostTrialAppsByAppIdAudioToTextPath = z.object({ app_id: z.uuid(), @@ -454,28 +493,6 @@ export const zPostTrialAppsByAppIdAudioToTextPath = z.object({ */ export const zPostTrialAppsByAppIdAudioToTextResponse = zAudioTranscriptResponse -export const zPostTrialAppsByAppIdChatMessagesBody = zChatRequest - -export const zPostTrialAppsByAppIdChatMessagesPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Success - */ -export const zPostTrialAppsByAppIdChatMessagesResponse = zGeneratedAppResponse - -export const zPostTrialAppsByAppIdCompletionMessagesBody = zCompletionRequest - -export const zPostTrialAppsByAppIdCompletionMessagesPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Success - */ -export const zPostTrialAppsByAppIdCompletionMessagesResponse = zGeneratedAppResponse - export const zGetTrialAppsByAppIdDatasetsPath = z.object({ app_id: z.uuid(), }) @@ -489,7 +506,7 @@ export const zGetTrialAppsByAppIdDatasetsQuery = z.object({ /** * Success */ -export const zGetTrialAppsByAppIdDatasetsResponse = zTrialDatasetList +export const zGetTrialAppsByAppIdDatasetsResponse = zTrialDatasetListResponse export const zGetTrialAppsByAppIdMessagesByMessageIdSuggestedQuestionsPath = z.object({ app_id: z.uuid(), @@ -536,20 +553,9 @@ export const zGetTrialAppsByAppIdWorkflowsPath = z.object({ }) /** - * Success + * Workflow detail retrieved successfully */ -export const zGetTrialAppsByAppIdWorkflowsResponse = zTrialWorkflow - -export const zPostTrialAppsByAppIdWorkflowsRunBody = zWorkflowRunRequest - -export const zPostTrialAppsByAppIdWorkflowsRunPath = z.object({ - app_id: z.uuid(), -}) - -/** - * Success - */ -export const zPostTrialAppsByAppIdWorkflowsRunResponse = zGeneratedAppResponse +export const zGetTrialAppsByAppIdWorkflowsResponse = zWorkflowResponse export const zPostTrialAppsByAppIdWorkflowsTasksByTaskIdStopPath = z.object({ app_id: z.uuid(), diff --git a/packages/contracts/generated/api/console/workflow-generate/types.gen.ts b/packages/contracts/generated/api/console/workflow-generate/types.gen.ts index 7f67a572cb5..7fdaec5f4f0 100644 --- a/packages/contracts/generated/api/console/workflow-generate/types.gen.ts +++ b/packages/contracts/generated/api/console/workflow-generate/types.gen.ts @@ -17,15 +17,42 @@ export type WorkflowGeneratePayload = { export type GeneratorResponse = unknown 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 + = | string + | number + | number + | boolean + | { + [key: string]: unknown + } + | Array + | null export type PostWorkflowGenerateData = { body: WorkflowGeneratePayload diff --git a/packages/contracts/generated/api/console/workflow-generate/zod.gen.ts b/packages/contracts/generated/api/console/workflow-generate/zod.gen.ts index c57f0e31412..3076374073e 100644 --- a/packages/contracts/generated/api/console/workflow-generate/zod.gen.ts +++ b/packages/contracts/generated/api/console/workflow-generate/zod.gen.ts @@ -7,21 +7,45 @@ import * as z from 'zod' */ export const zGeneratorResponse = z.unknown() -/** - * LLMMode - * - * Enum class for large language model mode. - */ -export const zLlmMode = z.enum(['chat', 'completion']) +export const zJsonValue = z + .union([ + z.string(), + z.int(), + z.number(), + z.boolean(), + z.record(z.string(), z.unknown()), + z.array(z.unknown()), + ]) + .nullable() /** * 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/workspaces/orpc.gen.ts b/packages/contracts/generated/api/console/workspaces/orpc.gen.ts index 4f7c1179949..f5e49c82a47 100644 --- a/packages/contracts/generated/api/console/workspaces/orpc.gen.ts +++ b/packages/contracts/generated/api/console/workspaces/orpc.gen.ts @@ -40,9 +40,6 @@ import { zGetWorkspacesCurrentAgentProvidersResponse, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesPath, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse, - zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath, - zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery, - zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdPath, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse, zGetWorkspacesCurrentCustomizedSnippetsQuery, @@ -525,33 +522,6 @@ export const checkDependencies = { get: get3, } -/** - * Export snippet as DSL - * - * Export snippet configuration as DSL - */ -export const get4 = oc - .route({ - description: 'Export snippet configuration as DSL', - inputStructure: 'detailed', - method: 'GET', - operationId: 'getWorkspacesCurrentCustomizedSnippetsBySnippetIdExport', - path: '/workspaces/current/customized-snippets/{snippet_id}/export', - summary: 'Export snippet as DSL', - tags: ['console'], - }) - .input( - z.object({ - params: zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath, - query: zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery.optional(), - }), - ) - .output(zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse) - -export const export_ = { - get: get4, -} - /** * Increment snippet use count when it is inserted into a workflow * @@ -599,7 +569,7 @@ export const delete_ = oc /** * Get customized snippet details */ -export const get5 = oc +export const get4 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -633,17 +603,16 @@ export const patch = oc export const bySnippetId = { delete: delete_, - get: get5, + get: get4, patch, checkDependencies, - export: export_, useCount, } /** * List customized snippets with pagination and search */ -export const get6 = oc +export const get5 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -672,13 +641,13 @@ export const post4 = oc .output(zPostWorkspacesCurrentCustomizedSnippetsResponse) export const customizedSnippets = { - get: get6, + get: get5, post: post4, imports, bySnippetId, } -export const get7 = oc +export const get6 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -689,10 +658,10 @@ export const get7 = oc .output(zGetWorkspacesCurrentDatasetOperatorsResponse) export const datasetOperators = { - get: get7, + get: get6, } -export const get8 = oc +export const get7 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -715,7 +684,7 @@ export const post5 = oc .output(zPostWorkspacesCurrentDefaultModelResponse) export const defaultModel = { - get: get8, + get: get7, post: post5, } @@ -806,7 +775,7 @@ export const enable = { /** * List endpoints for a specific plugin */ -export const get9 = oc +export const get8 = oc .route({ description: 'List endpoints for a specific plugin', inputStructure: 'detailed', @@ -819,13 +788,13 @@ export const get9 = oc .output(zGetWorkspacesCurrentEndpointsListPluginResponse) export const plugin = { - get: get9, + get: get8, } /** * List plugin endpoints with pagination */ -export const get10 = oc +export const get9 = oc .route({ description: 'List plugin endpoints with pagination', inputStructure: 'detailed', @@ -838,7 +807,7 @@ export const get10 = oc .output(zGetWorkspacesCurrentEndpointsListResponse) export const list = { - get: get10, + get: get9, plugin, } @@ -1034,7 +1003,7 @@ export const byMemberId = { updateRole, } -export const get11 = oc +export const get10 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1045,14 +1014,14 @@ export const get11 = oc .output(zGetWorkspacesCurrentMembersResponse) export const members = { - get: get11, + get: get10, inviteEmail, ownerTransferCheck, sendOwnerTransferConfirmEmail, byMemberId, } -export const get12 = oc +export const get11 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1064,7 +1033,7 @@ export const get12 = oc .output(zGetWorkspacesCurrentModelProvidersByProviderCheckoutUrlResponse) export const checkoutUrl = { - get: get12, + get: get11, } export const post16 = oc @@ -1124,7 +1093,7 @@ export const delete5 = oc ) .output(zDeleteWorkspacesCurrentModelProvidersByProviderCredentialsResponse) -export const get13 = oc +export const get12 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1175,7 +1144,7 @@ export const put2 = oc export const credentials = { delete: delete5, - get: get13, + get: get12, post: post18, put: put2, switch: switch_, @@ -1239,7 +1208,7 @@ export const delete6 = oc ) .output(zDeleteWorkspacesCurrentModelProvidersByProviderModelsCredentialsResponse) -export const get14 = oc +export const get13 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1290,7 +1259,7 @@ export const put3 = oc export const credentials2 = { delete: delete6, - get: get14, + get: get13, post: post21, put: put3, switch: switch2, @@ -1394,7 +1363,7 @@ export const loadBalancingConfigs = { byConfigId, } -export const get15 = oc +export const get14 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1411,7 +1380,7 @@ export const get15 = oc .output(zGetWorkspacesCurrentModelProvidersByProviderModelsParameterRulesResponse) export const parameterRules = { - get: get15, + get: get14, } export const delete7 = oc @@ -1431,7 +1400,7 @@ export const delete7 = oc ) .output(zDeleteWorkspacesCurrentModelProvidersByProviderModelsResponse) -export const get16 = oc +export const get15 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1460,7 +1429,7 @@ export const post24 = oc export const models = { delete: delete7, - get: get16, + get: get15, post: post24, credentials: credentials2, disable: disable2, @@ -1496,7 +1465,7 @@ export const byProvider = { preferredProviderType, } -export const get17 = oc +export const get16 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1508,11 +1477,11 @@ export const get17 = oc .output(zGetWorkspacesCurrentModelProvidersResponse) export const modelProviders = { - get: get17, + get: get16, byProvider, } -export const get18 = oc +export const get17 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1524,7 +1493,7 @@ export const get18 = oc .output(zGetWorkspacesCurrentModelsModelTypesByModelTypeResponse) export const byModelType = { - get: get18, + get: get17, } export const modelTypes = { @@ -1540,7 +1509,7 @@ export const models2 = { * * Returns permission flags that control workspace features like member invitations and owner transfer. */ -export const get19 = oc +export const get18 = oc .route({ description: 'Returns permission flags that control workspace features like member invitations and owner transfer.', @@ -1554,10 +1523,10 @@ export const get19 = oc .output(zGetWorkspacesCurrentPermissionResponse) export const permission = { - get: get19, + get: get18, } -export const get20 = oc +export const get19 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1569,7 +1538,7 @@ export const get20 = oc .output(zGetWorkspacesCurrentPluginAssetResponse) export const asset = { - get: get20, + get: get19, } export const post26 = oc @@ -1602,7 +1571,7 @@ export const exclude = { post: post27, } -export const get21 = oc +export const get20 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1614,7 +1583,7 @@ export const get21 = oc .output(zGetWorkspacesCurrentPluginAutoUpgradeFetchResponse) export const fetch_ = { - get: get21, + get: get20, } export const autoUpgrade = { @@ -1623,7 +1592,7 @@ export const autoUpgrade = { fetch: fetch_, } -export const get22 = oc +export const get21 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1634,10 +1603,10 @@ export const get22 = oc .output(zGetWorkspacesCurrentPluginDebuggingKeyResponse) export const debuggingKey = { - get: get22, + get: get21, } -export const get23 = oc +export const get22 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1649,10 +1618,10 @@ export const get23 = oc .output(zGetWorkspacesCurrentPluginFetchManifestResponse) export const fetchManifest = { - get: get23, + get: get22, } -export const get24 = oc +export const get23 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1664,7 +1633,7 @@ export const get24 = oc .output(zGetWorkspacesCurrentPluginIconResponse) export const icon = { - get: get24, + get: get23, } export const post28 = oc @@ -1752,7 +1721,7 @@ export const latestVersions = { post: post32, } -export const get25 = oc +export const get24 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1764,12 +1733,12 @@ export const get25 = oc .output(zGetWorkspacesCurrentPluginListResponse) export const list2 = { - get: get25, + get: get24, installations, latestVersions, } -export const get26 = oc +export const get25 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1781,14 +1750,14 @@ export const get26 = oc .output(zGetWorkspacesCurrentPluginMarketplacePkgResponse) export const pkg2 = { - get: get26, + get: get25, } export const marketplace2 = { pkg: pkg2, } -export const get27 = oc +export const get26 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1800,7 +1769,7 @@ export const get27 = oc .output(zGetWorkspacesCurrentPluginParametersDynamicOptionsResponse) export const dynamicOptions = { - get: get27, + get: get26, } /** @@ -1844,7 +1813,7 @@ export const change2 = { post: post34, } -export const get28 = oc +export const get27 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1855,7 +1824,7 @@ export const get28 = oc .output(zGetWorkspacesCurrentPluginPermissionFetchResponse) export const fetch2 = { - get: get28, + get: get27, } export const permission2 = { @@ -1863,7 +1832,7 @@ export const permission2 = { fetch: fetch2, } -export const get29 = oc +export const get28 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1875,7 +1844,7 @@ export const get29 = oc .output(zGetWorkspacesCurrentPluginReadmeResponse) export const readme = { - get: get29, + get: get28, } export const post35 = oc @@ -1923,7 +1892,7 @@ export const delete8 = { byIdentifier, } -export const get30 = oc +export const get29 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1935,11 +1904,11 @@ export const get30 = oc .output(zGetWorkspacesCurrentPluginTasksByTaskIdResponse) export const byTaskId = { - get: get30, + get: get29, delete: delete8, } -export const get31 = oc +export const get30 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1951,7 +1920,7 @@ export const get31 = oc .output(zGetWorkspacesCurrentPluginTasksResponse) export const tasks = { - get: get31, + get: get30, deleteAll, byTaskId, } @@ -2055,7 +2024,7 @@ export const upload = { pkg: pkg3, } -export const get32 = oc +export const get31 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2072,7 +2041,7 @@ export const get32 = oc .output(zGetWorkspacesCurrentPluginByCategoryListResponse) export const list3 = { - get: get32, + get: get31, } export const byCategory = { @@ -2125,7 +2094,7 @@ export const delete9 = oc .input(z.object({ params: zDeleteWorkspacesCurrentRbacAccessPoliciesByPolicyIdPath })) .output(zDeleteWorkspacesCurrentRbacAccessPoliciesByPolicyIdResponse) -export const get33 = oc +export const get32 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2149,12 +2118,12 @@ export const put4 = oc export const byPolicyId = { delete: delete9, - get: get33, + get: get32, put: put4, copy, } -export const get34 = oc +export const get33 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2176,7 +2145,7 @@ export const post45 = oc .output(zPostWorkspacesCurrentRbacAccessPoliciesResponse) export const accessPolicies = { - get: get34, + get: get33, post: post45, byPolicyId, } @@ -2235,7 +2204,7 @@ export const delete10 = oc ) .output(zDeleteWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsResponse) -export const get35 = oc +export const get34 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2252,10 +2221,10 @@ export const get35 = oc export const memberBindings = { delete: delete10, - get: get35, + get: get34, } -export const get36 = oc +export const get35 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2271,7 +2240,7 @@ export const get36 = oc .output(zGetWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings = { - get: get36, + get: get35, } export const byPolicyId2 = { @@ -2283,7 +2252,7 @@ export const accessPolicies2 = { byPolicyId: byPolicyId2, } -export const get37 = oc +export const get36 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2295,10 +2264,10 @@ export const get37 = oc .output(zGetWorkspacesCurrentRbacAppsByAppIdAccessPolicyResponse) export const accessPolicy = { - get: get37, + get: get36, } -export const get38 = oc +export const get37 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2310,7 +2279,7 @@ export const get38 = oc .output(zGetWorkspacesCurrentRbacAppsByAppIdUserAccessPoliciesResponse) export const userAccessPolicies = { - get: get38, + get: get37, } export const put7 = oc @@ -2340,7 +2309,7 @@ export const users = { byTargetAccountId, } -export const get39 = oc +export const get38 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2363,7 +2332,7 @@ export const put8 = oc .output(zPutWorkspacesCurrentRbacAppsByAppIdWhitelistResponse) export const whitelist = { - get: get39, + get: get38, put: put8, } @@ -2398,7 +2367,7 @@ export const delete11 = oc zDeleteWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsResponse, ) -export const get40 = oc +export const get39 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2419,10 +2388,10 @@ export const get40 = oc export const memberBindings2 = { delete: delete11, - get: get40, + get: get39, } -export const get41 = oc +export const get40 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2438,7 +2407,7 @@ export const get41 = oc .output(zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings2 = { - get: get41, + get: get40, } export const byPolicyId3 = { @@ -2450,7 +2419,7 @@ export const accessPolicies4 = { byPolicyId: byPolicyId3, } -export const get42 = oc +export const get41 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2462,10 +2431,10 @@ export const get42 = oc .output(zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPolicyResponse) export const accessPolicy2 = { - get: get42, + get: get41, } -export const get43 = oc +export const get42 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2477,7 +2446,7 @@ export const get43 = oc .output(zGetWorkspacesCurrentRbacDatasetsByDatasetIdUserAccessPoliciesResponse) export const userAccessPolicies2 = { - get: get43, + get: get42, } export const put9 = oc @@ -2507,7 +2476,7 @@ export const users2 = { byTargetAccountId: byTargetAccountId2, } -export const get44 = oc +export const get43 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2530,7 +2499,7 @@ export const put10 = oc .output(zPutWorkspacesCurrentRbacDatasetsByDatasetIdWhitelistResponse) export const whitelist2 = { - get: get44, + get: get43, put: put10, } @@ -2546,7 +2515,7 @@ export const datasets = { byDatasetId, } -export const get45 = oc +export const get44 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2569,7 +2538,7 @@ export const put11 = oc .output(zPutWorkspacesCurrentRbacMembersByMemberIdRbacRolesResponse) export const rbacRoles = { - get: get45, + get: get44, put: put11, } @@ -2581,7 +2550,7 @@ export const members2 = { byMemberId: byMemberId2, } -export const get46 = oc +export const get45 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2592,10 +2561,10 @@ export const get46 = oc .output(zGetWorkspacesCurrentRbacMyPermissionsResponse) export const myPermissions = { - get: get46, + get: get45, } -export const get47 = oc +export const get46 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2606,10 +2575,10 @@ export const get47 = oc .output(zGetWorkspacesCurrentRbacRolePermissionsCatalogAppResponse) export const app = { - get: get47, + get: get46, } -export const get48 = oc +export const get47 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2620,10 +2589,10 @@ export const get48 = oc .output(zGetWorkspacesCurrentRbacRolePermissionsCatalogDatasetResponse) export const dataset = { - get: get48, + get: get47, } -export const get49 = oc +export const get48 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2634,7 +2603,7 @@ export const get49 = oc .output(zGetWorkspacesCurrentRbacRolePermissionsCatalogResponse) export const catalog = { - get: get49, + get: get48, app, dataset, } @@ -2659,7 +2628,7 @@ export const copy2 = { post: post46, } -export const get50 = oc +export const get49 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2671,7 +2640,7 @@ export const get50 = oc .output(zGetWorkspacesCurrentRbacRolesByRoleIdMembersResponse) export const members3 = { - get: get50, + get: get49, } export const delete12 = oc @@ -2685,7 +2654,7 @@ export const delete12 = oc .input(z.object({ params: zDeleteWorkspacesCurrentRbacRolesByRoleIdPath })) .output(zDeleteWorkspacesCurrentRbacRolesByRoleIdResponse) -export const get51 = oc +export const get50 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2709,13 +2678,13 @@ export const put12 = oc export const byRoleId = { delete: delete12, - get: get51, + get: get50, put: put12, copy: copy2, members: members3, } -export const get52 = oc +export const get51 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2737,7 +2706,7 @@ export const post47 = oc .output(zPostWorkspacesCurrentRbacRolesResponse) export const roles = { - get: get52, + get: get51, post: post47, byRoleId, } @@ -2761,7 +2730,7 @@ export const bindings = { put: put13, } -export const get53 = oc +export const get52 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2777,10 +2746,10 @@ export const get53 = oc .output(zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdMemberBindingsResponse) export const memberBindings3 = { - get: get53, + get: get52, } -export const get54 = oc +export const get53 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2796,7 +2765,7 @@ export const get54 = oc .output(zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings3 = { - get: get54, + get: get53, } export const byPolicyId4 = { @@ -2809,7 +2778,7 @@ export const accessPolicies6 = { byPolicyId: byPolicyId4, } -export const get55 = oc +export const get54 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2820,7 +2789,7 @@ export const get55 = oc .output(zGetWorkspacesCurrentRbacWorkspaceAppsAccessPolicyResponse) export const accessPolicy3 = { - get: get55, + get: get54, } export const apps2 = { @@ -2847,7 +2816,7 @@ export const bindings2 = { put: put14, } -export const get56 = oc +export const get55 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2863,10 +2832,10 @@ export const get56 = oc .output(zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdMemberBindingsResponse) export const memberBindings4 = { - get: get56, + get: get55, } -export const get57 = oc +export const get56 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2882,7 +2851,7 @@ export const get57 = oc .output(zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings4 = { - get: get57, + get: get56, } export const byPolicyId5 = { @@ -2895,7 +2864,7 @@ export const accessPolicies7 = { byPolicyId: byPolicyId5, } -export const get58 = oc +export const get57 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2906,7 +2875,7 @@ export const get58 = oc .output(zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPolicyResponse) export const accessPolicy4 = { - get: get58, + get: get57, } export const datasets2 = { @@ -2931,7 +2900,7 @@ export const rbac = { workspace, } -export const get59 = oc +export const get58 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2942,7 +2911,7 @@ export const get59 = oc .output(zGetWorkspacesCurrentToolLabelsResponse) export const toolLabels = { - get: get59, + get: get58, } export const post48 = oc @@ -2975,7 +2944,7 @@ export const delete13 = { post: post49, } -export const get60 = oc +export const get59 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2986,11 +2955,11 @@ export const get60 = oc .input(z.object({ query: zGetWorkspacesCurrentToolProviderApiGetQuery })) .output(zGetWorkspacesCurrentToolProviderApiGetResponse) -export const get61 = { - get: get60, +export const get60 = { + get: get59, } -export const get62 = oc +export const get61 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3002,7 +2971,7 @@ export const get62 = oc .output(zGetWorkspacesCurrentToolProviderApiRemoteResponse) export const remote = { - get: get62, + get: get61, } export const post50 = oc @@ -3039,7 +3008,7 @@ export const test = { pre, } -export const get63 = oc +export const get62 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3051,7 +3020,7 @@ export const get63 = oc .output(zGetWorkspacesCurrentToolProviderApiToolsResponse) export const tools = { - get: get63, + get: get62, } export const post52 = oc @@ -3072,7 +3041,7 @@ export const update2 = { export const api = { add, delete: delete13, - get: get61, + get: get60, remote, schema, test, @@ -3100,7 +3069,7 @@ export const add2 = { post: post53, } -export const get64 = oc +export const get63 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3117,10 +3086,10 @@ export const get64 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialInfoResponse) export const info = { - get: get64, + get: get63, } -export const get65 = oc +export const get64 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3140,7 +3109,7 @@ export const get65 = oc ) export const byCredentialType = { - get: get65, + get: get64, } export const schema2 = { @@ -3152,7 +3121,7 @@ export const credential = { schema: schema2, } -export const get66 = oc +export const get65 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3169,7 +3138,7 @@ export const get66 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialsResponse) export const credentials3 = { - get: get66, + get: get65, } export const post54 = oc @@ -3212,7 +3181,7 @@ export const delete14 = { post: post55, } -export const get67 = oc +export const get66 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3224,10 +3193,10 @@ export const get67 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderIconResponse) export const icon2 = { - get: get67, + get: get66, } -export const get68 = oc +export const get67 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3239,10 +3208,10 @@ export const get68 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderInfoResponse) export const info2 = { - get: get68, + get: get67, } -export const get69 = oc +export const get68 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3256,7 +3225,7 @@ export const get69 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderOauthClientSchemaResponse) export const clientSchema = { - get: get69, + get: get68, } export const delete15 = oc @@ -3274,7 +3243,7 @@ export const delete15 = oc ) .output(zDeleteWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientResponse) -export const get70 = oc +export const get69 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3305,7 +3274,7 @@ export const post56 = oc export const customClient = { delete: delete15, - get: get70, + get: get69, post: post56, } @@ -3314,7 +3283,7 @@ export const oauth = { customClient, } -export const get71 = oc +export const get70 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3326,7 +3295,7 @@ export const get71 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderToolsResponse) export const tools2 = { - get: get71, + get: get70, } export const post57 = oc @@ -3381,7 +3350,7 @@ export const auth = { post: post58, } -export const get72 = oc +export const get71 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3393,14 +3362,14 @@ export const get72 = oc .output(zGetWorkspacesCurrentToolProviderMcpToolsByProviderIdResponse) export const byProviderId = { - get: get72, + get: get71, } export const tools3 = { byProviderId, } -export const get73 = oc +export const get72 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3412,7 +3381,7 @@ export const get73 = oc .output(zGetWorkspacesCurrentToolProviderMcpUpdateByProviderIdResponse) export const byProviderId2 = { - get: get73, + get: get72, } export const update4 = { @@ -3491,7 +3460,7 @@ export const delete17 = { post: post61, } -export const get74 = oc +export const get73 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3502,11 +3471,11 @@ export const get74 = oc .input(z.object({ query: zGetWorkspacesCurrentToolProviderWorkflowGetQuery.optional() })) .output(zGetWorkspacesCurrentToolProviderWorkflowGetResponse) -export const get75 = { - get: get74, +export const get74 = { + get: get73, } -export const get76 = oc +export const get75 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3518,7 +3487,7 @@ export const get76 = oc .output(zGetWorkspacesCurrentToolProviderWorkflowToolsResponse) export const tools4 = { - get: get76, + get: get75, } export const post62 = oc @@ -3539,7 +3508,7 @@ export const update5 = { export const workflow = { create: create2, delete: delete17, - get: get75, + get: get74, tools: tools4, update: update5, } @@ -3551,7 +3520,7 @@ export const toolProvider = { workflow, } -export const get77 = oc +export const get76 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3563,10 +3532,10 @@ export const get77 = oc .output(zGetWorkspacesCurrentToolProvidersResponse) export const toolProviders = { - get: get77, + get: get76, } -export const get78 = oc +export const get77 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3577,10 +3546,10 @@ export const get78 = oc .output(zGetWorkspacesCurrentToolsApiResponse) export const api2 = { - get: get78, + get: get77, } -export const get79 = oc +export const get78 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3591,10 +3560,10 @@ export const get79 = oc .output(zGetWorkspacesCurrentToolsBuiltinResponse) export const builtin2 = { - get: get79, + get: get78, } -export const get80 = oc +export const get79 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3605,10 +3574,10 @@ export const get80 = oc .output(zGetWorkspacesCurrentToolsMcpResponse) export const mcp2 = { - get: get80, + get: get79, } -export const get81 = oc +export const get80 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3619,7 +3588,7 @@ export const get81 = oc .output(zGetWorkspacesCurrentToolsWorkflowResponse) export const workflow2 = { - get: get81, + get: get80, } export const tools5 = { @@ -3629,7 +3598,7 @@ export const tools5 = { workflow: workflow2, } -export const get82 = oc +export const get81 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3641,13 +3610,13 @@ export const get82 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderIconResponse) export const icon3 = { - get: get82, + get: get81, } /** * Get info for a trigger provider */ -export const get83 = oc +export const get82 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3660,7 +3629,7 @@ export const get83 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderInfoResponse) export const info3 = { - get: get83, + get: get82, } /** @@ -3681,7 +3650,7 @@ export const delete18 = oc /** * Get OAuth client configuration for a provider */ -export const get84 = oc +export const get83 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3715,7 +3684,7 @@ export const post63 = oc export const client = { delete: delete18, - get: get84, + get: get83, post: post63, } @@ -3782,7 +3751,7 @@ export const create3 = { /** * Get the request logs for a subscription instance for a trigger provider */ -export const get85 = oc +export const get84 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3803,7 +3772,7 @@ export const get85 = oc ) export const bySubscriptionBuilderId2 = { - get: get85, + get: get84, } export const logs = { @@ -3877,7 +3846,7 @@ export const verifyAndUpdate = { /** * Get a subscription instance for a trigger provider */ -export const get86 = oc +export const get85 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3898,7 +3867,7 @@ export const get86 = oc ) export const bySubscriptionBuilderId5 = { - get: get86, + get: get85, } export const builder = { @@ -3913,7 +3882,7 @@ export const builder = { /** * List all trigger subscriptions for the current tenant's provider */ -export const get87 = oc +export const get86 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3926,13 +3895,13 @@ export const get87 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsListResponse) export const list4 = { - get: get87, + get: get86, } /** * Initiate OAuth authorization flow for a trigger provider */ -export const get88 = oc +export const get87 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3949,7 +3918,7 @@ export const get88 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsOauthAuthorizeResponse) export const authorize = { - get: get88, + get: get87, } export const oauth3 = { @@ -4066,7 +4035,7 @@ export const triggerProvider = { /** * List all trigger providers for the current tenant */ -export const get89 = oc +export const get88 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4078,7 +4047,7 @@ export const get89 = oc .output(zGetWorkspacesCurrentTriggersResponse) export const triggers = { - get: get89, + get: get88, } export const post71 = oc @@ -4179,7 +4148,7 @@ export const switch3 = { post: post75, } -export const get90 = oc +export const get89 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4191,7 +4160,7 @@ export const get90 = oc .output(zGetWorkspacesByTenantIdModelProvidersByProviderByIconTypeByLangResponse) export const byLang = { - get: get90, + get: get89, } export const byIconType = { @@ -4210,7 +4179,7 @@ export const byTenantId = { modelProviders: modelProviders2, } -export const get91 = oc +export const get90 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4221,7 +4190,7 @@ export const get91 = oc .output(zGetWorkspacesResponse) export const workspaces = { - get: get91, + get: get90, current, customConfig, info: info4, diff --git a/packages/contracts/generated/api/console/workspaces/types.gen.ts b/packages/contracts/generated/api/console/workspaces/types.gen.ts index 9fd704c2a5c..09bb8132845 100644 --- a/packages/contracts/generated/api/console/workspaces/types.gen.ts +++ b/packages/contracts/generated/api/console/workspaces/types.gen.ts @@ -31,12 +31,12 @@ export type AgentProviderListResponse = Array<{ [key: string]: unknown }> -export type SnippetPagination = { - data?: Array - has_more?: boolean - limit?: number - page?: number - total?: number +export type SnippetPaginationResponse = { + data: Array + has_more: boolean + limit: number + page: number + total: number } export type CreateSnippetPayload = { @@ -50,28 +50,28 @@ export type CreateSnippetPayload = { type?: 'group' | 'node' } -export type Snippet = { - created_at?: number - created_by?: AnonymousInlineModelB0Fd3F86D9D5 - description?: string +export type SnippetResponse = { + created_at?: number | null + created_by?: SimpleAccountResponse | null + description?: string | null graph?: { [key: string]: unknown - } + } | null icon_info?: { [key: string]: unknown - } - id?: string - input_fields?: { + } | null + id: string + input_fields?: Array<{ [key: string]: unknown - } - is_published?: boolean - name?: string - tags?: Array - type?: string - updated_at?: number - updated_by?: AnonymousInlineModelB0Fd3F86D9D5 - use_count?: number - version?: number + }> | null + is_published: boolean + name: string + tags?: Array + type: string + updated_at?: number | null + updated_by?: SimpleAccountResponse | null + use_count: number + version: number } export type SnippetImportPayload = { @@ -83,8 +83,13 @@ export type SnippetImportPayload = { yaml_url?: string | null } -export type SnippetImportResponse = { - [key: string]: unknown +export type SnippetImportInfo = { + current_dsl_version?: string + error?: string + id: string + imported_dsl_version?: string + snippet_id?: string | null + status: ImportStatus } export type UpdateSnippetPayload = { @@ -93,13 +98,11 @@ export type UpdateSnippetPayload = { name?: string | null } -export type SnippetDependencyCheckResponse = { - [key: string]: unknown +export type CheckDependenciesResult = { + leaked_dependencies?: Array } -export type TextFileResponse = string - -export type SnippetUseCountResponse = { +export type SnippetUseCountIncrementResponse = { result: string use_count: number } @@ -845,23 +848,23 @@ export type WorkspaceCustomConfigResponse = { replace_webapp_logo?: string | null } -export type AnonymousInlineModel744Ff9Cc03E6 = { - author_name?: string - created_at?: number - created_by?: string - description?: string +export type SnippetListItemResponse = { + author_name?: string | null + created_at?: number | null + created_by?: string | null + description?: string | null icon_info?: { [key: string]: unknown - } - id?: string - is_published?: boolean - name?: string - tags?: Array - type?: string - updated_at?: number - updated_by?: string - use_count?: number - version?: number + } | null + id: string + is_published: boolean + name: string + tags?: Array + type: string + updated_at?: number | null + updated_by?: string | null + use_count: number + version: number } export type IconInfo = { @@ -882,16 +885,24 @@ export type InputFieldDefinition = { type?: string | null } -export type AnonymousInlineModelB0Fd3F86D9D5 = { - email?: string - id?: string - name?: string +export type SimpleAccountResponse = { + email: string + id: string + name: string } -export type AnonymousInlineModel7B8B49Ca164e = { - id?: string - name?: string - type?: string +export type SnippetTagResponse = { + id: string + name: string + type: string +} + +export type ImportStatus = 'completed' | 'completed-with-warnings' | 'failed' | 'pending' + +export type PluginDependency = { + current_identifier?: string | null + type: Type + value: Github | Marketplace | Package } export type AccountWithRoleResponse = { @@ -1189,6 +1200,32 @@ export type WorkflowToolParameterConfiguration = { name: string } +export type Type + = | 'app-selector' + | 'array[tools]' + | 'boolean' + | 'model-selector' + | 'secret-input' + | 'select' + | 'text-input' + +export type Github = { + github_plugin_unique_identifier: string + package: string + repo: string + version: string +} + +export type Marketplace = { + marketplace_plugin_unique_identifier: string + version?: string | null +} + +export type Package = { + plugin_unique_identifier: string + version?: string | null +} + export type SimpleProviderEntityResponse = { icon_small?: I18nObject | null icon_small_dark?: I18nObject | null @@ -1524,15 +1561,6 @@ export type ModelSelectorScope export type ToolSelectorScope = 'all' | 'builtin' | 'custom' | 'workflow' -export type Type - = | 'app-selector' - | 'array[tools]' - | 'boolean' - | 'model-selector' - | 'secret-input' - | 'select' - | 'text-input' - export type FormOption = { label: GraphonModelRuntimeEntitiesCommonEntitiesI18nObject show_on?: Array @@ -1645,7 +1673,7 @@ export type GetWorkspacesCurrentCustomizedSnippetsData = { } export type GetWorkspacesCurrentCustomizedSnippetsResponses = { - 200: SnippetPagination + 200: SnippetPaginationResponse } export type GetWorkspacesCurrentCustomizedSnippetsResponse @@ -1663,7 +1691,7 @@ export type PostWorkspacesCurrentCustomizedSnippetsErrors = { } export type PostWorkspacesCurrentCustomizedSnippetsResponses = { - 201: Snippet + 201: SnippetResponse } export type PostWorkspacesCurrentCustomizedSnippetsResponse @@ -1681,8 +1709,8 @@ export type PostWorkspacesCurrentCustomizedSnippetsImportsErrors = { } export type PostWorkspacesCurrentCustomizedSnippetsImportsResponses = { - 200: SnippetImportResponse - 202: SnippetImportResponse + 200: SnippetImportInfo + 202: SnippetImportInfo } export type PostWorkspacesCurrentCustomizedSnippetsImportsResponse @@ -1702,7 +1730,7 @@ export type PostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmError } export type PostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponses = { - 200: SnippetImportResponse + 200: SnippetImportInfo } export type PostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponse @@ -1742,7 +1770,7 @@ export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdErrors = { } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponses = { - 200: Snippet + 200: SnippetResponse } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse @@ -1763,7 +1791,7 @@ export type PatchWorkspacesCurrentCustomizedSnippetsBySnippetIdErrors = { } export type PatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponses = { - 200: Snippet + 200: SnippetResponse } export type PatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse @@ -1783,34 +1811,12 @@ export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesEr } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponses = { - 200: SnippetDependencyCheckResponse + 200: CheckDependenciesResult } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse = GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponses[keyof GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponses] -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportData = { - body?: never - path: { - snippet_id: string - } - query?: { - include_secret?: string - } - url: '/workspaces/current/customized-snippets/{snippet_id}/export' -} - -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportErrors = { - 404: unknown -} - -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponses = { - 200: TextFileResponse -} - -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse - = GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponses[keyof GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponses] - export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementData = { body?: never path: { @@ -1825,7 +1831,7 @@ export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementE } export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponses = { - 200: SnippetUseCountResponse + 200: SnippetUseCountIncrementResponse } export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponse diff --git a/packages/contracts/generated/api/console/workspaces/zod.gen.ts b/packages/contracts/generated/api/console/workspaces/zod.gen.ts index 7415aaa5712..8ecd9998f09 100644 --- a/packages/contracts/generated/api/console/workspaces/zod.gen.ts +++ b/packages/contracts/generated/api/console/workspaces/zod.gen.ts @@ -27,24 +27,9 @@ export const zSnippetImportPayload = z.object({ }) /** - * SnippetImportResponse + * SnippetUseCountIncrementResponse */ -export const zSnippetImportResponse = z.record(z.string(), z.unknown()) - -/** - * SnippetDependencyCheckResponse - */ -export const zSnippetDependencyCheckResponse = z.record(z.string(), z.unknown()) - -/** - * TextFileResponse - */ -export const zTextFileResponse = z.string() - -/** - * SnippetUseCountResponse - */ -export const zSnippetUseCountResponse = z.object({ +export const zSnippetUseCountIncrementResponse = z.object({ result: z.string(), use_count: z.int(), }) @@ -753,91 +738,91 @@ export const zCreateSnippetPayload = z.object({ type: z.enum(['group', 'node']).optional().default('node'), }) -export const zAnonymousInlineModelB0Fd3F86D9D5 = z.object({ - email: z.string().optional(), - id: z.string().optional(), - name: z.string().optional(), +/** + * SimpleAccountResponse + */ +export const zSimpleAccountResponse = z.object({ + email: z.string(), + id: z.string(), + name: z.string(), }) -export const zAnonymousInlineModel7B8B49Ca164e = z.object({ - id: z.string().optional(), - name: z.string().optional(), - type: z.string().optional(), +/** + * SnippetTagResponse + */ +export const zSnippetTagResponse = z.object({ + id: z.string(), + name: z.string(), + type: z.string(), }) -export const zSnippet = z.object({ - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: zAnonymousInlineModelB0Fd3F86D9D5.optional(), - description: z.string().optional(), - graph: z.record(z.string(), z.unknown()).optional(), - icon_info: z.record(z.string(), z.unknown()).optional(), - id: z.string().optional(), - input_fields: z.record(z.string(), z.unknown()).optional(), - is_published: z.boolean().optional(), - name: z.string().optional(), - tags: z.array(zAnonymousInlineModel7B8B49Ca164e).optional(), - type: z.string().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: zAnonymousInlineModelB0Fd3F86D9D5.optional(), - use_count: z.int().optional(), - version: z.int().optional(), +/** + * SnippetResponse + */ +export const zSnippetResponse = z.object({ + created_at: z.int().nullish(), + created_by: zSimpleAccountResponse.nullish(), + description: z.string().nullish(), + graph: z.record(z.string(), z.unknown()).nullish(), + icon_info: z.record(z.string(), z.unknown()).nullish(), + id: z.string(), + input_fields: z.array(z.record(z.string(), z.unknown())).nullish(), + is_published: z.boolean(), + name: z.string(), + tags: z.array(zSnippetTagResponse).optional(), + type: z.string(), + updated_at: z.int().nullish(), + updated_by: zSimpleAccountResponse.nullish(), + use_count: z.int(), + version: z.int(), }) -export const zAnonymousInlineModel744Ff9Cc03E6 = z.object({ - author_name: z.string().optional(), - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - description: z.string().optional(), - icon_info: z.record(z.string(), z.unknown()).optional(), - id: z.string().optional(), - is_published: z.boolean().optional(), - name: z.string().optional(), - tags: z.array(zAnonymousInlineModel7B8B49Ca164e).optional(), - type: z.string().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: z.string().optional(), - use_count: z.int().optional(), - version: z.int().optional(), +/** + * SnippetListItemResponse + */ +export const zSnippetListItemResponse = z.object({ + author_name: z.string().nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + description: z.string().nullish(), + icon_info: z.record(z.string(), z.unknown()).nullish(), + id: z.string(), + is_published: z.boolean(), + name: z.string(), + tags: z.array(zSnippetTagResponse).optional(), + type: z.string(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + use_count: z.int(), + version: z.int(), }) -export const zSnippetPagination = z.object({ - data: z.array(zAnonymousInlineModel744Ff9Cc03E6).optional(), - has_more: z.boolean().optional(), - limit: z.int().optional(), - page: z.int().optional(), - total: z.int().optional(), +/** + * SnippetPaginationResponse + */ +export const zSnippetPaginationResponse = z.object({ + data: z.array(zSnippetListItemResponse), + has_more: z.boolean(), + limit: z.int(), + page: z.int(), + total: z.int(), +}) + +/** + * ImportStatus + */ +export const zImportStatus = z.enum(['completed', 'completed-with-warnings', 'failed', 'pending']) + +/** + * SnippetImportInfo + */ +export const zSnippetImportInfo = z.object({ + current_dsl_version: z.string().optional().default('0.1.0'), + error: z.string().optional().default(''), + id: z.string(), + imported_dsl_version: z.string().optional().default(''), + snippet_id: z.string().nullish(), + status: zImportStatus, }) /** @@ -1327,6 +1312,61 @@ export const zMcpProviderUpdatePayload = z.object({ server_url: z.string(), }) +/** + * Type + */ +export const zType = z.enum([ + 'app-selector', + 'array[tools]', + 'boolean', + 'model-selector', + 'secret-input', + 'select', + 'text-input', +]) + +/** + * Github + */ +export const zGithub = z.object({ + github_plugin_unique_identifier: z.string(), + package: z.string(), + repo: z.string(), + version: z.string(), +}) + +/** + * Marketplace + */ +export const zMarketplace = z.object({ + marketplace_plugin_unique_identifier: z.string(), + version: z.string().nullish(), +}) + +/** + * Package + */ +export const zPackage = z.object({ + plugin_unique_identifier: z.string(), + version: z.string().nullish(), +}) + +/** + * PluginDependency + */ +export const zPluginDependency = z.object({ + current_identifier: z.string().nullish(), + type: zType, + value: z.union([zGithub, zMarketplace, zPackage]), +}) + +/** + * CheckDependenciesResult + */ +export const zCheckDependenciesResult = z.object({ + leaked_dependencies: z.array(zPluginDependency).optional(), +}) + /** * ConfigurateMethod * @@ -1929,19 +1969,6 @@ export const zModelSelectorScope = z.enum([ */ export const zToolSelectorScope = z.enum(['all', 'builtin', 'custom', 'workflow']) -/** - * Type - */ -export const zType = z.enum([ - 'app-selector', - 'array[tools]', - 'boolean', - 'model-selector', - 'secret-input', - 'select', - 'text-input', -]) - /** * ProviderConfig * @@ -2268,21 +2295,21 @@ export const zGetWorkspacesCurrentCustomizedSnippetsQuery = z.object({ /** * Snippets retrieved successfully */ -export const zGetWorkspacesCurrentCustomizedSnippetsResponse = zSnippetPagination +export const zGetWorkspacesCurrentCustomizedSnippetsResponse = zSnippetPaginationResponse export const zPostWorkspacesCurrentCustomizedSnippetsBody = zCreateSnippetPayload /** * Snippet created successfully */ -export const zPostWorkspacesCurrentCustomizedSnippetsResponse = zSnippet +export const zPostWorkspacesCurrentCustomizedSnippetsResponse = zSnippetResponse export const zPostWorkspacesCurrentCustomizedSnippetsImportsBody = zSnippetImportPayload /** * Snippet imported successfully */ -export const zPostWorkspacesCurrentCustomizedSnippetsImportsResponse = zSnippetImportResponse +export const zPostWorkspacesCurrentCustomizedSnippetsImportsResponse = zSnippetImportInfo export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmPath = z.object({ import_id: z.string(), @@ -2292,7 +2319,7 @@ export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmPat * Import confirmed successfully */ export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponse - = zSnippetImportResponse + = zSnippetImportInfo export const zDeleteWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({ snippet_id: z.uuid(), @@ -2310,7 +2337,7 @@ export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({ /** * Snippet retrieved successfully */ -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippet +export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippetResponse export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdBody = zUpdateSnippetPayload @@ -2321,7 +2348,7 @@ export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object /** * Snippet updated successfully */ -export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippet +export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippetResponse export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesPath = z.object({ snippet_id: z.uuid(), @@ -2331,20 +2358,7 @@ export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependencies * Dependencies checked successfully */ export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse - = zSnippetDependencyCheckResponse - -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath = z.object({ - snippet_id: z.uuid(), -}) - -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery = z.object({ - include_secret: z.string().optional().default('false'), -}) - -/** - * Snippet exported successfully - */ -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse = zTextFileResponse + = zCheckDependenciesResult export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementPath = z.object({ snippet_id: z.uuid(), @@ -2354,7 +2368,7 @@ export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncremen * Use count incremented successfully */ export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponse - = zSnippetUseCountResponse + = zSnippetUseCountIncrementResponse /** * Success