mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 10:38:32 +08:00
refactor(api): migrate console app common endpoints to BaseModel (#37951)
Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
2429b757d8
commit
4fc8f0ddd1
@ -30,7 +30,6 @@ from controllers.console.wraps import (
|
||||
)
|
||||
from events.app_event import app_model_config_was_updated
|
||||
from extensions.ext_database import db
|
||||
from libs.helper import dump_response
|
||||
from libs.login import login_required
|
||||
from models import Account
|
||||
from models.agent_config_entities import (
|
||||
@ -99,4 +98,4 @@ class AgentAppFeatureConfigResource(Resource):
|
||||
|
||||
app_model_config_was_updated.send(app_model, app_model_config=new_app_model_config)
|
||||
|
||||
return dump_response(SimpleResultResponse, {"result": "success"})
|
||||
return SimpleResultResponse(result="success").model_dump(mode="json")
|
||||
|
||||
@ -230,13 +230,10 @@ class AppTracePayload(BaseModel):
|
||||
|
||||
|
||||
class AppTraceResponse(ResponseModel):
|
||||
enabled: bool
|
||||
enabled: bool = False
|
||||
tracing_provider: str | None = None
|
||||
|
||||
|
||||
type JSONValue = Any
|
||||
|
||||
|
||||
class Tag(ResponseModel):
|
||||
id: str
|
||||
name: str
|
||||
@ -257,7 +254,7 @@ class WorkflowPartial(ResponseModel):
|
||||
|
||||
|
||||
class ModelConfigPartial(ResponseModel):
|
||||
model: JSONValue | None = Field(default=None, validation_alias=AliasChoices("model_dict", "model"))
|
||||
model: Any | None = Field(default=None, validation_alias=AliasChoices("model_dict", "model"))
|
||||
pre_prompt: str | None = None
|
||||
created_by: str | None = None
|
||||
created_at: int | None = None
|
||||
@ -272,54 +269,52 @@ class ModelConfigPartial(ResponseModel):
|
||||
|
||||
class ModelConfig(ResponseModel):
|
||||
opening_statement: str | None = None
|
||||
suggested_questions: JSONValue | None = Field(
|
||||
suggested_questions: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("suggested_questions_list", "suggested_questions")
|
||||
)
|
||||
suggested_questions_after_answer: JSONValue | None = Field(
|
||||
suggested_questions_after_answer: Any | None = Field(
|
||||
default=None,
|
||||
validation_alias=AliasChoices("suggested_questions_after_answer_dict", "suggested_questions_after_answer"),
|
||||
)
|
||||
speech_to_text: JSONValue | None = Field(
|
||||
speech_to_text: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("speech_to_text_dict", "speech_to_text")
|
||||
)
|
||||
text_to_speech: JSONValue | None = Field(
|
||||
text_to_speech: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("text_to_speech_dict", "text_to_speech")
|
||||
)
|
||||
retriever_resource: JSONValue | None = Field(
|
||||
retriever_resource: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("retriever_resource_dict", "retriever_resource")
|
||||
)
|
||||
annotation_reply: JSONValue | None = Field(
|
||||
annotation_reply: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("annotation_reply_dict", "annotation_reply")
|
||||
)
|
||||
more_like_this: JSONValue | None = Field(
|
||||
more_like_this: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("more_like_this_dict", "more_like_this")
|
||||
)
|
||||
sensitive_word_avoidance: JSONValue | None = Field(
|
||||
sensitive_word_avoidance: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("sensitive_word_avoidance_dict", "sensitive_word_avoidance")
|
||||
)
|
||||
external_data_tools: JSONValue | None = Field(
|
||||
external_data_tools: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("external_data_tools_list", "external_data_tools")
|
||||
)
|
||||
model: JSONValue | None = Field(default=None, validation_alias=AliasChoices("model_dict", "model"))
|
||||
user_input_form: JSONValue | None = Field(
|
||||
model: Any | None = Field(default=None, validation_alias=AliasChoices("model_dict", "model"))
|
||||
user_input_form: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("user_input_form_list", "user_input_form")
|
||||
)
|
||||
dataset_query_variable: str | None = None
|
||||
pre_prompt: str | None = None
|
||||
agent_mode: JSONValue | None = Field(default=None, validation_alias=AliasChoices("agent_mode_dict", "agent_mode"))
|
||||
agent_mode: Any | None = Field(default=None, validation_alias=AliasChoices("agent_mode_dict", "agent_mode"))
|
||||
prompt_type: str | None = None
|
||||
chat_prompt_config: JSONValue | None = Field(
|
||||
chat_prompt_config: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("chat_prompt_config_dict", "chat_prompt_config")
|
||||
)
|
||||
completion_prompt_config: JSONValue | None = Field(
|
||||
completion_prompt_config: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("completion_prompt_config_dict", "completion_prompt_config")
|
||||
)
|
||||
dataset_configs: JSONValue | None = Field(
|
||||
dataset_configs: Any | None = Field(
|
||||
default=None, validation_alias=AliasChoices("dataset_configs_dict", "dataset_configs")
|
||||
)
|
||||
file_upload: JSONValue | None = Field(
|
||||
default=None, validation_alias=AliasChoices("file_upload_dict", "file_upload")
|
||||
)
|
||||
file_upload: Any | None = Field(default=None, validation_alias=AliasChoices("file_upload_dict", "file_upload"))
|
||||
created_by: str | None = None
|
||||
created_at: int | None = None
|
||||
updated_by: str | None = None
|
||||
@ -440,7 +435,7 @@ class AppDetail(ResponseModel):
|
||||
alias="model_config",
|
||||
)
|
||||
workflow: WorkflowPartial | None = None
|
||||
tracing: JSONValue | None = None
|
||||
tracing: Any | None = None
|
||||
use_icon_as_answer_icon: bool | None = None
|
||||
created_by: str | None = None
|
||||
created_at: int | None = None
|
||||
@ -486,6 +481,16 @@ class AppExportResponse(ResponseModel):
|
||||
data: str
|
||||
|
||||
|
||||
class AppImportResponse(ResponseModel):
|
||||
id: str
|
||||
status: ImportStatus
|
||||
app_id: str | None = None
|
||||
app_mode: str | None = None
|
||||
current_dsl_version: str
|
||||
imported_dsl_version: str = ""
|
||||
error: str = ""
|
||||
|
||||
|
||||
def _enrich_app_list_items(session: Session, *, apps: Sequence[App], tenant_id: str) -> None:
|
||||
if FeatureService.get_system_features().webapp_auth.enabled:
|
||||
app_ids = [str(app.id) for app in apps]
|
||||
@ -528,7 +533,9 @@ def _enrich_app_list_items(session: Session, *, apps: Sequence[App], tenant_id:
|
||||
|
||||
|
||||
register_enum_models(console_ns, RetrievalMethod, WorkflowExecutionStatus, DatasetPermissionEnum)
|
||||
register_response_schema_models(console_ns, AppTraceResponse, RedirectUrlResponse, SimpleResultResponse)
|
||||
register_response_schema_models(
|
||||
console_ns, RedirectUrlResponse, SimpleResultResponse, AppImportResponse, AppTraceResponse
|
||||
)
|
||||
|
||||
register_schema_models(
|
||||
console_ns,
|
||||
@ -620,8 +627,8 @@ class AppListApi(Resource):
|
||||
app_service = AppService()
|
||||
app_pagination = app_service.get_paginate_apps(current_user_id, current_tenant_id, params, db.session)
|
||||
if not app_pagination:
|
||||
empty = AppPagination(page=args.page, limit=args.limit, total=0, has_more=False, data=[])
|
||||
return empty.model_dump(mode="json"), 200
|
||||
response = AppPagination(page=args.page, limit=args.limit, total=0, has_more=False, data=[])
|
||||
return response.model_dump(mode="json"), 200
|
||||
|
||||
app_ids = [str(app.id) for app in app_pagination.items]
|
||||
permission_keys_map = permissions.app.permission_keys_by_resource_ids(app_ids)
|
||||
@ -710,9 +717,7 @@ class StarredAppListApi(Resource):
|
||||
return empty.model_dump(mode="json"), 200
|
||||
|
||||
_enrich_app_list_items(session, apps=app_pagination.items, tenant_id=current_tenant_id)
|
||||
|
||||
pagination_model = AppPagination.model_validate(app_pagination, from_attributes=True)
|
||||
return pagination_model.model_dump(mode="json"), 200
|
||||
return AppPagination.model_validate(app_pagination, from_attributes=True).model_dump(mode="json"), 200
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/star")
|
||||
@ -731,7 +736,7 @@ class AppStarApi(Resource):
|
||||
@get_app_model(mode=None)
|
||||
def post(self, session: Session, current_user_id: str, app_model: App):
|
||||
AppService.star_app(session, app=app_model, account_id=current_user_id)
|
||||
return dump_response(SimpleResultResponse, {"result": "success"})
|
||||
return SimpleResultResponse(result="success").model_dump(mode="json")
|
||||
|
||||
@console_ns.doc("unstar_app")
|
||||
@console_ns.doc(description="Remove the current account's star from an application")
|
||||
@ -747,7 +752,7 @@ class AppStarApi(Resource):
|
||||
@get_app_model(mode=None)
|
||||
def delete(self, session: Session, current_user_id: str, app_model: App):
|
||||
AppService.unstar_app(session, app=app_model, account_id=current_user_id)
|
||||
return dump_response(SimpleResultResponse, {"result": "success"})
|
||||
return SimpleResultResponse(result="success").model_dump(mode="json")
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>")
|
||||
@ -815,8 +820,7 @@ class AppApi(Resource):
|
||||
"max_active_requests": args.max_active_requests or 0,
|
||||
}
|
||||
app_model = app_service.update_app(app_model, args_dict)
|
||||
response_model = AppDetailWithSite.model_validate(app_model, from_attributes=True)
|
||||
return response_model.model_dump(mode="json")
|
||||
return dump_response(AppDetailWithSite, app_model)
|
||||
|
||||
@console_ns.doc("delete_app")
|
||||
@console_ns.doc(description="Delete application")
|
||||
@ -844,6 +848,7 @@ class AppCopyApi(Resource):
|
||||
@console_ns.doc(params={"app_id": "Application ID to copy"})
|
||||
@console_ns.expect(console_ns.models[CopyAppPayload.__name__])
|
||||
@console_ns.response(201, "App copied successfully", console_ns.models[AppDetailWithSite.__name__])
|
||||
@console_ns.response(202, "App copy requires confirmation", console_ns.models[AppImportResponse.__name__])
|
||||
@console_ns.response(403, "Insufficient permissions")
|
||||
@setup_required
|
||||
@login_required
|
||||
@ -873,10 +878,10 @@ class AppCopyApi(Resource):
|
||||
)
|
||||
if result.status == ImportStatus.FAILED:
|
||||
session.rollback()
|
||||
return result.model_dump(mode="json"), 400
|
||||
return dump_response(AppImportResponse, result), 400
|
||||
if result.status == ImportStatus.PENDING:
|
||||
session.rollback()
|
||||
return result.model_dump(mode="json"), 202
|
||||
return dump_response(AppImportResponse, result), 202
|
||||
session.commit()
|
||||
|
||||
# Inherit web app permission from original app
|
||||
@ -927,14 +932,14 @@ class AppExportApi(Resource):
|
||||
"""Export app"""
|
||||
args = AppExportQuery.model_validate(request.args.to_dict(flat=True))
|
||||
|
||||
payload = AppExportResponse(
|
||||
response = AppExportResponse(
|
||||
data=AppDslService.export_dsl(
|
||||
app_model=app_model,
|
||||
include_secret=args.include_secret,
|
||||
workflow_id=args.workflow_id,
|
||||
)
|
||||
)
|
||||
return payload.model_dump(mode="json")
|
||||
return response.model_dump(mode="json")
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/publish-to-creators-platform")
|
||||
@ -960,7 +965,7 @@ class AppPublishToCreatorsPlatformApi(Resource):
|
||||
claim_code = upload_dsl(dsl_bytes)
|
||||
redirect_url = get_redirect_url(current_user_id, claim_code)
|
||||
|
||||
return {"redirect_url": redirect_url}
|
||||
return RedirectUrlResponse(redirect_url=redirect_url).model_dump(mode="json")
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/name")
|
||||
@ -981,8 +986,7 @@ class AppNameApi(Resource):
|
||||
|
||||
app_service = AppService()
|
||||
app_model = app_service.update_app_name(app_model, args.name)
|
||||
response_model = AppDetail.model_validate(app_model, from_attributes=True)
|
||||
return response_model.model_dump(mode="json")
|
||||
return dump_response(AppDetail, app_model)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/icon")
|
||||
@ -1009,8 +1013,7 @@ class AppIconApi(Resource):
|
||||
args.icon_background or "",
|
||||
args.icon_type,
|
||||
)
|
||||
response_model = AppDetail.model_validate(app_model, from_attributes=True)
|
||||
return response_model.model_dump(mode="json")
|
||||
return dump_response(AppDetail, app_model)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/site-enable")
|
||||
@ -1032,8 +1035,7 @@ class AppSiteStatus(Resource):
|
||||
|
||||
app_service = AppService()
|
||||
app_model = app_service.update_app_site_status(app_model, args.enable_site)
|
||||
response_model = AppDetail.model_validate(app_model, from_attributes=True)
|
||||
return response_model.model_dump(mode="json")
|
||||
return dump_response(AppDetail, app_model)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/api-enable")
|
||||
@ -1055,8 +1057,7 @@ class AppApiStatus(Resource):
|
||||
|
||||
app_service = AppService()
|
||||
app_model = app_service.update_app_api_status(app_model, args.enable_api)
|
||||
response_model = AppDetail.model_validate(app_model, from_attributes=True)
|
||||
return response_model.model_dump(mode="json")
|
||||
return dump_response(AppDetail, app_model)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/trace")
|
||||
@ -1079,7 +1080,7 @@ class AppTraceApi(Resource):
|
||||
"""Get app trace"""
|
||||
app_trace_config = OpsTraceManager.get_app_tracing_config(app_model.id, session)
|
||||
|
||||
return app_trace_config
|
||||
return dump_response(AppTraceResponse, app_trace_config)
|
||||
|
||||
@console_ns.doc("update_app_trace")
|
||||
@console_ns.doc(description="Update app tracing configuration")
|
||||
@ -1107,4 +1108,4 @@ class AppTraceApi(Resource):
|
||||
tracing_provider=args.tracing_provider,
|
||||
)
|
||||
|
||||
return {"result": "success"}
|
||||
return SimpleResultResponse(result="success").model_dump(mode="json")
|
||||
|
||||
@ -22,7 +22,7 @@ from controllers.console.wraps import (
|
||||
)
|
||||
from extensions.ext_database import db
|
||||
from fields.base import ResponseModel
|
||||
from libs.helper import to_timestamp
|
||||
from libs.helper import dump_response, to_timestamp
|
||||
from libs.login import login_required
|
||||
from models.enums import AppMCPServerStatus
|
||||
from models.model import App, AppMCPServer
|
||||
@ -93,7 +93,7 @@ class AppMCPServerController(Resource):
|
||||
server = db.session.scalar(select(AppMCPServer).where(AppMCPServer.app_id == app_model.id).limit(1))
|
||||
if server is None:
|
||||
return {}
|
||||
return AppMCPServerResponse.model_validate(server, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(AppMCPServerResponse, server)
|
||||
|
||||
@console_ns.doc("create_app_mcp_server")
|
||||
@console_ns.doc(description="Create MCP server configuration for an application")
|
||||
@ -128,7 +128,7 @@ class AppMCPServerController(Resource):
|
||||
)
|
||||
db.session.add(server)
|
||||
db.session.commit()
|
||||
return AppMCPServerResponse.model_validate(server, from_attributes=True).model_dump(mode="json"), 201
|
||||
return dump_response(AppMCPServerResponse, server), 201
|
||||
|
||||
@console_ns.doc("update_app_mcp_server")
|
||||
@console_ns.doc(description="Update MCP server configuration for an application")
|
||||
@ -176,7 +176,7 @@ class AppMCPServerController(Resource):
|
||||
except ValueError:
|
||||
raise ValueError("Invalid status")
|
||||
db.session.commit()
|
||||
return AppMCPServerResponse.model_validate(server, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(AppMCPServerResponse, server)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:server_id>/server/refresh")
|
||||
@ -203,4 +203,4 @@ class AppMCPServerRefreshController(Resource):
|
||||
raise NotFound()
|
||||
server.server_code = AppMCPServer.generate_server_code(16)
|
||||
db.session.commit()
|
||||
return AppMCPServerResponse.model_validate(server, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(AppMCPServerResponse, server)
|
||||
|
||||
@ -22,6 +22,7 @@ from controllers.console.wraps import (
|
||||
from extensions.ext_database import db
|
||||
from fields.base import ResponseModel
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
from libs.helper import dump_response
|
||||
from libs.login import login_required
|
||||
from models import Site
|
||||
from models.account import Account
|
||||
@ -127,7 +128,7 @@ class AppSite(Resource):
|
||||
site.updated_at = naive_utc_now()
|
||||
db.session.commit()
|
||||
|
||||
return AppSiteResponse.model_validate(site, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(AppSiteResponse, site)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/site/access-token-reset")
|
||||
@ -156,4 +157,4 @@ class AppSiteAccessTokenReset(Resource):
|
||||
site.updated_at = naive_utc_now()
|
||||
db.session.commit()
|
||||
|
||||
return AppSiteResponse.model_validate(site, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(AppSiteResponse, site)
|
||||
|
||||
@ -12,6 +12,7 @@ from configs import dify_config
|
||||
from controllers.common.schema import query_params_from_model, register_schema_models
|
||||
from extensions.ext_database import db
|
||||
from fields.base import ResponseModel
|
||||
from libs.helper import dump_response
|
||||
from libs.login import login_required
|
||||
from models.enums import AppTriggerStatus
|
||||
from models.model import App, AppMode
|
||||
@ -121,7 +122,7 @@ class WebhookTriggerApi(Resource):
|
||||
if not webhook_trigger:
|
||||
raise NotFound("Webhook trigger not found for this node")
|
||||
|
||||
return WebhookTriggerResponse.model_validate(webhook_trigger, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(WebhookTriggerResponse, webhook_trigger)
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/triggers")
|
||||
@ -160,9 +161,7 @@ class AppTriggersApi(Resource):
|
||||
else:
|
||||
trigger.icon = "" # type: ignore
|
||||
|
||||
return WorkflowTriggerListResponse.model_validate({"data": triggers}, from_attributes=True).model_dump(
|
||||
mode="json"
|
||||
)
|
||||
return dump_response(WorkflowTriggerListResponse, {"data": triggers})
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/trigger-enable")
|
||||
@ -204,4 +203,4 @@ class AppTriggerEnableApi(Resource):
|
||||
else:
|
||||
trigger.icon = "" # type: ignore
|
||||
|
||||
return WorkflowTriggerResponse.model_validate(trigger, from_attributes=True).model_dump(mode="json")
|
||||
return dump_response(WorkflowTriggerResponse, trigger)
|
||||
|
||||
@ -2903,6 +2903,7 @@ Create a copy of an existing application
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | App copied successfully | **application/json**: [AppDetailWithSite](#appdetailwithsite)<br> |
|
||||
| 202 | App copy requires confirmation | **application/json**: [AppImportResponse](#appimportresponse)<br> |
|
||||
| 403 | Insufficient permissions | |
|
||||
|
||||
### [GET] /apps/{app_id}/export
|
||||
@ -12954,7 +12955,7 @@ Default namespace
|
||||
| role | string | | No |
|
||||
| site | [AppDetailSiteResponse](#appdetailsiteresponse) | | No |
|
||||
| tags | [ [Tag](#tag) ] | | No |
|
||||
| tracing | [JSONValue](#jsonvalue) | | No |
|
||||
| tracing | | | No |
|
||||
| updated_at | integer | | No |
|
||||
| updated_by | string | | No |
|
||||
| use_icon_as_answer_icon | boolean | | No |
|
||||
@ -14890,7 +14891,7 @@ Enum class for api provider schema type.
|
||||
| name | string | | Yes |
|
||||
| permission_keys | [ string ] | | No |
|
||||
| tags | [ [Tag](#tag) ] | | No |
|
||||
| tracing | [JSONValue](#jsonvalue) | | No |
|
||||
| tracing | | | No |
|
||||
| updated_at | integer | | No |
|
||||
| updated_by | string | | No |
|
||||
| use_icon_as_answer_icon | boolean | | No |
|
||||
@ -14953,7 +14954,7 @@ Enum class for api provider schema type.
|
||||
| permission_keys | [ string ] | | No |
|
||||
| site | [AppDetailSiteResponse](#appdetailsiteresponse) | | No |
|
||||
| tags | [ [Tag](#tag) ] | | No |
|
||||
| tracing | [JSONValue](#jsonvalue) | | No |
|
||||
| tracing | | | No |
|
||||
| updated_at | integer | | No |
|
||||
| updated_by | string | | No |
|
||||
| use_icon_as_answer_icon | boolean | | No |
|
||||
@ -15000,6 +15001,18 @@ Enum class for api provider schema type.
|
||||
| yaml_content | string | | No |
|
||||
| yaml_url | string | | No |
|
||||
|
||||
#### AppImportResponse
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| app_id | string | | No |
|
||||
| app_mode | string | | No |
|
||||
| current_dsl_version | string | | Yes |
|
||||
| error | string | | No |
|
||||
| id | string | | Yes |
|
||||
| imported_dsl_version | string | | No |
|
||||
| status | [ImportStatus](#importstatus) | | Yes |
|
||||
|
||||
#### AppListQuery
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
@ -15147,7 +15160,7 @@ AppMCPServer Status Enum
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| enabled | boolean | | Yes |
|
||||
| enabled | boolean | | No |
|
||||
| tracing_provider | string | | No |
|
||||
|
||||
#### AppVariableConfig
|
||||
@ -18467,7 +18480,7 @@ Metadata operation data
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| created_at | integer | | No |
|
||||
| created_by | string | | No |
|
||||
| model | [JSONValue](#jsonvalue) | | No |
|
||||
| model | | | No |
|
||||
| pre_prompt | string | | No |
|
||||
| updated_at | integer | | No |
|
||||
| updated_by | string | | No |
|
||||
|
||||
@ -52,7 +52,7 @@ export type AgentAppDetailWithSite = {
|
||||
role?: string | null
|
||||
site?: AppDetailSiteResponse | null
|
||||
tags?: Array<Tag>
|
||||
tracing?: JsonValue | null
|
||||
tracing?: unknown | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
use_icon_as_answer_icon?: boolean | null
|
||||
@ -578,17 +578,6 @@ export type Tag = {
|
||||
type: string
|
||||
}
|
||||
|
||||
export type JsonValue
|
||||
= | string
|
||||
| number
|
||||
| number
|
||||
| boolean
|
||||
| {
|
||||
[key: string]: unknown
|
||||
}
|
||||
| Array<unknown>
|
||||
| null
|
||||
|
||||
export type WorkflowPartial = {
|
||||
created_at?: number | null
|
||||
created_by?: string | null
|
||||
@ -979,6 +968,17 @@ export type Feedback = {
|
||||
rating: string
|
||||
}
|
||||
|
||||
export type JsonValue
|
||||
= | string
|
||||
| number
|
||||
| number
|
||||
| boolean
|
||||
| {
|
||||
[key: string]: unknown
|
||||
}
|
||||
| Array<unknown>
|
||||
| null
|
||||
|
||||
export type MessageFile = {
|
||||
belongs_to?: string | null
|
||||
filename: string
|
||||
@ -1081,7 +1081,7 @@ export type AgentConfigRevisionResponse = {
|
||||
export type ModelConfigPartial = {
|
||||
created_at?: number | null
|
||||
created_by?: string | null
|
||||
model?: JsonValue | null
|
||||
model?: unknown | null
|
||||
pre_prompt?: string | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
@ -1862,7 +1862,7 @@ export type AgentAppDetailWithSiteWritable = {
|
||||
role?: string | null
|
||||
site?: AppDetailSiteResponseWritable | null
|
||||
tags?: Array<Tag>
|
||||
tracing?: JsonValue | null
|
||||
tracing?: unknown | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
use_icon_as_answer_icon?: boolean | null
|
||||
|
||||
@ -325,17 +325,6 @@ export const zTag = z.object({
|
||||
type: z.string(),
|
||||
})
|
||||
|
||||
export const zJsonValue = z
|
||||
.union([
|
||||
z.string(),
|
||||
z.int(),
|
||||
z.number(),
|
||||
z.boolean(),
|
||||
z.record(z.string(), z.unknown()),
|
||||
z.array(z.unknown()),
|
||||
])
|
||||
.nullable()
|
||||
|
||||
/**
|
||||
* WorkflowPartial
|
||||
*/
|
||||
@ -802,6 +791,17 @@ export const zAgentLogMessageListResponse = z.object({
|
||||
total: z.int(),
|
||||
})
|
||||
|
||||
export const zJsonValue = z
|
||||
.union([
|
||||
z.string(),
|
||||
z.int(),
|
||||
z.number(),
|
||||
z.boolean(),
|
||||
z.record(z.string(), z.unknown()),
|
||||
z.array(z.unknown()),
|
||||
])
|
||||
.nullable()
|
||||
|
||||
/**
|
||||
* AgentThought
|
||||
*/
|
||||
@ -947,7 +947,7 @@ export const zAgentStatisticSummaryResponse = z.object({
|
||||
export const zModelConfigPartial = z.object({
|
||||
created_at: z.int().nullish(),
|
||||
created_by: z.string().nullish(),
|
||||
model: zJsonValue.nullish(),
|
||||
model: z.unknown().nullish(),
|
||||
pre_prompt: z.string().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
@ -1065,7 +1065,7 @@ export const zAgentAppDetailWithSite = z.object({
|
||||
role: z.string().nullish(),
|
||||
site: zAppDetailSiteResponse.nullish(),
|
||||
tags: z.array(zTag).optional(),
|
||||
tracing: zJsonValue.nullish(),
|
||||
tracing: z.unknown().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
use_icon_as_answer_icon: z.boolean().nullish(),
|
||||
@ -2672,7 +2672,7 @@ export const zAgentAppDetailWithSiteWritable = z.object({
|
||||
role: z.string().nullish(),
|
||||
site: zAppDetailSiteResponseWritable.nullish(),
|
||||
tags: z.array(zTag).optional(),
|
||||
tracing: zJsonValue.nullish(),
|
||||
tracing: z.unknown().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
use_icon_as_answer_icon: z.boolean().nullish(),
|
||||
|
||||
@ -45,7 +45,7 @@ export type AppDetailWithSite = {
|
||||
permission_keys?: Array<string>
|
||||
site?: AppDetailSiteResponse | null
|
||||
tags?: Array<Tag>
|
||||
tracing?: JsonValue | null
|
||||
tracing?: unknown | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
use_icon_as_answer_icon?: boolean | null
|
||||
@ -417,7 +417,7 @@ export type AppDetail = {
|
||||
name: string
|
||||
permission_keys?: Array<string>
|
||||
tags?: Array<Tag>
|
||||
tracing?: JsonValue | null
|
||||
tracing?: unknown | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
use_icon_as_answer_icon?: boolean | null
|
||||
@ -526,6 +526,16 @@ export type CopyAppPayload = {
|
||||
name?: string | null
|
||||
}
|
||||
|
||||
export type AppImportResponse = {
|
||||
app_id?: string | null
|
||||
app_mode?: string | null
|
||||
current_dsl_version: string
|
||||
error?: string
|
||||
id: string
|
||||
imported_dsl_version?: string
|
||||
status: ImportStatus
|
||||
}
|
||||
|
||||
export type AppExportResponse = {
|
||||
data: string
|
||||
}
|
||||
@ -733,7 +743,7 @@ export type TextToSpeechVoiceListResponse = Array<{
|
||||
}>
|
||||
|
||||
export type AppTraceResponse = {
|
||||
enabled: boolean
|
||||
enabled?: boolean
|
||||
tracing_provider?: string | null
|
||||
}
|
||||
|
||||
@ -1343,17 +1353,6 @@ export type Tag = {
|
||||
type: string
|
||||
}
|
||||
|
||||
export type JsonValue
|
||||
= | string
|
||||
| number
|
||||
| number
|
||||
| boolean
|
||||
| {
|
||||
[key: string]: unknown
|
||||
}
|
||||
| Array<unknown>
|
||||
| null
|
||||
|
||||
export type WorkflowPartial = {
|
||||
created_at?: number | null
|
||||
created_by?: string | null
|
||||
@ -1391,6 +1390,17 @@ export type AdvancedChatWorkflowRunForListResponse = {
|
||||
version?: string | null
|
||||
}
|
||||
|
||||
export type JsonValue
|
||||
= | string
|
||||
| number
|
||||
| number
|
||||
| boolean
|
||||
| {
|
||||
[key: string]: unknown
|
||||
}
|
||||
| Array<unknown>
|
||||
| null
|
||||
|
||||
export type AgentConfigVersionResponse = {
|
||||
id: string
|
||||
kind: 'build_draft' | 'draft' | 'snapshot'
|
||||
@ -2156,7 +2166,7 @@ export type WorkflowDraftVariableWithoutValue = {
|
||||
export type ModelConfigPartial = {
|
||||
created_at?: number | null
|
||||
created_by?: string | null
|
||||
model?: JsonValue | null
|
||||
model?: unknown | null
|
||||
pre_prompt?: string | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
@ -3003,7 +3013,7 @@ export type AppDetailWithSiteWritable = {
|
||||
permission_keys?: Array<string>
|
||||
site?: AppDetailSiteResponseWritable | null
|
||||
tags?: Array<Tag>
|
||||
tracing?: JsonValue | null
|
||||
tracing?: unknown | null
|
||||
updated_at?: number | null
|
||||
updated_by?: string | null
|
||||
use_icon_as_answer_icon?: boolean | null
|
||||
@ -4623,6 +4633,7 @@ export type PostAppsByAppIdCopyErrors = {
|
||||
|
||||
export type PostAppsByAppIdCopyResponses = {
|
||||
201: AppDetailWithSite
|
||||
202: AppImportResponse
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdCopyResponse
|
||||
|
||||
@ -463,7 +463,7 @@ export const zTextToSpeechVoiceListResponse = z.array(z.record(z.string(), z.unk
|
||||
* AppTraceResponse
|
||||
*/
|
||||
export const zAppTraceResponse = z.object({
|
||||
enabled: z.boolean(),
|
||||
enabled: z.boolean().optional().default(false),
|
||||
tracing_provider: z.string().nullish(),
|
||||
})
|
||||
|
||||
@ -909,22 +909,6 @@ export const zTag = z.object({
|
||||
type: z.string(),
|
||||
})
|
||||
|
||||
export const zJsonValue = z
|
||||
.union([
|
||||
z.string(),
|
||||
z.int(),
|
||||
z.number(),
|
||||
z.boolean(),
|
||||
z.record(z.string(), z.unknown()),
|
||||
z.array(z.unknown()),
|
||||
])
|
||||
.nullable()
|
||||
|
||||
/**
|
||||
* GeneratedAppResponse
|
||||
*/
|
||||
export const zGeneratedAppResponse = zJsonValue
|
||||
|
||||
/**
|
||||
* WorkflowPartial
|
||||
*/
|
||||
@ -955,6 +939,35 @@ export const zImport = z.object({
|
||||
status: zImportStatus,
|
||||
})
|
||||
|
||||
/**
|
||||
* AppImportResponse
|
||||
*/
|
||||
export const zAppImportResponse = z.object({
|
||||
app_id: z.string().nullish(),
|
||||
app_mode: z.string().nullish(),
|
||||
current_dsl_version: z.string(),
|
||||
error: z.string().optional().default(''),
|
||||
id: z.string(),
|
||||
imported_dsl_version: z.string().optional().default(''),
|
||||
status: zImportStatus,
|
||||
})
|
||||
|
||||
export const zJsonValue = z
|
||||
.union([
|
||||
z.string(),
|
||||
z.int(),
|
||||
z.number(),
|
||||
z.boolean(),
|
||||
z.record(z.string(), z.unknown()),
|
||||
z.array(z.unknown()),
|
||||
])
|
||||
.nullable()
|
||||
|
||||
/**
|
||||
* GeneratedAppResponse
|
||||
*/
|
||||
export const zGeneratedAppResponse = zJsonValue
|
||||
|
||||
/**
|
||||
* AgentConfigVersionResponse
|
||||
*/
|
||||
@ -2212,7 +2225,7 @@ export const zWorkflowDraftVariableListWithoutValue = z.object({
|
||||
export const zModelConfigPartial = z.object({
|
||||
created_at: z.int().nullish(),
|
||||
created_by: z.string().nullish(),
|
||||
model: zJsonValue.nullish(),
|
||||
model: z.unknown().nullish(),
|
||||
pre_prompt: z.string().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
@ -2305,7 +2318,7 @@ export const zAppDetailWithSite = z.object({
|
||||
permission_keys: z.array(z.string()).optional(),
|
||||
site: zAppDetailSiteResponse.nullish(),
|
||||
tags: z.array(zTag).optional(),
|
||||
tracing: zJsonValue.nullish(),
|
||||
tracing: z.unknown().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
use_icon_as_answer_icon: z.boolean().nullish(),
|
||||
@ -2331,7 +2344,7 @@ export const zAppDetail = z.object({
|
||||
name: z.string(),
|
||||
permission_keys: z.array(z.string()).optional(),
|
||||
tags: z.array(zTag).optional(),
|
||||
tracing: zJsonValue.nullish(),
|
||||
tracing: z.unknown().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
use_icon_as_answer_icon: z.boolean().nullish(),
|
||||
@ -4127,7 +4140,7 @@ export const zAppDetailWithSiteWritable = z.object({
|
||||
permission_keys: z.array(z.string()).optional(),
|
||||
site: zAppDetailSiteResponseWritable.nullish(),
|
||||
tags: z.array(zTag).optional(),
|
||||
tracing: zJsonValue.nullish(),
|
||||
tracing: z.unknown().nullish(),
|
||||
updated_at: z.int().nullish(),
|
||||
updated_by: z.string().nullish(),
|
||||
use_icon_as_answer_icon: z.boolean().nullish(),
|
||||
@ -5194,10 +5207,7 @@ export const zPostAppsByAppIdCopyPath = z.object({
|
||||
app_id: z.uuid(),
|
||||
})
|
||||
|
||||
/**
|
||||
* App copied successfully
|
||||
*/
|
||||
export const zPostAppsByAppIdCopyResponse = zAppDetailWithSite
|
||||
export const zPostAppsByAppIdCopyResponse = z.union([zAppDetailWithSite, zAppImportResponse])
|
||||
|
||||
export const zGetAppsByAppIdExportPath = z.object({
|
||||
app_id: z.uuid(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user