diff --git a/api/controllers/common/fields.py b/api/controllers/common/fields.py index 79869916ed..3466eea1f6 100644 --- a/api/controllers/common/fields.py +++ b/api/controllers/common/fields.py @@ -1,5 +1,7 @@ from flask_restful import fields +from libs.helper import AppIconUrlField + parameters__system_parameters = { "image_file_size_limit": fields.Integer, "video_file_size_limit": fields.Integer, @@ -22,3 +24,20 @@ parameters_fields = { "file_upload": fields.Raw, "system_parameters": fields.Nested(parameters__system_parameters), } + +site_fields = { + "title": fields.String, + "chat_color_theme": fields.String, + "chat_color_theme_inverted": fields.Boolean, + "icon_type": fields.String, + "icon": fields.String, + "icon_background": fields.String, + "icon_url": AppIconUrlField, + "description": fields.String, + "copyright": fields.String, + "privacy_policy": fields.String, + "custom_disclaimer": fields.String, + "default_language": fields.String, + "show_workflow_steps": fields.Boolean, + "use_icon_as_answer_icon": fields.Boolean, +} diff --git a/api/controllers/service_api/__init__.py b/api/controllers/service_api/__init__.py index d97074e8b9..d964e27819 100644 --- a/api/controllers/service_api/__init__.py +++ b/api/controllers/service_api/__init__.py @@ -6,6 +6,6 @@ bp = Blueprint("service_api", __name__, url_prefix="/v1") api = ExternalApi(bp) from . import index -from .app import annotation, app, audio, completion, conversation, file, message, workflow +from .app import annotation, app, audio, completion, conversation, file, message, site, workflow from .dataset import dataset, document, hit_testing, metadata, segment, upload_file from .workspace import models diff --git a/api/controllers/service_api/app/site.py b/api/controllers/service_api/app/site.py new file mode 100644 index 0000000000..e752dfee30 --- /dev/null +++ b/api/controllers/service_api/app/site.py @@ -0,0 +1,30 @@ +from flask_restful import Resource, marshal_with +from werkzeug.exceptions import Forbidden + +from controllers.common import fields +from controllers.service_api import api +from controllers.service_api.wraps import validate_app_token +from extensions.ext_database import db +from models.account import TenantStatus +from models.model import App, Site + + +class AppSiteApi(Resource): + """Resource for app sites.""" + + @validate_app_token + @marshal_with(fields.site_fields) + def get(self, app_model: App): + """Retrieve app site info.""" + site = db.session.query(Site).filter(Site.app_id == app_model.id).first() + + if not site: + raise Forbidden() + + if app_model.tenant.status == TenantStatus.ARCHIVE: + raise Forbidden() + + return site + + +api.add_resource(AppSiteApi, "/site") diff --git a/web/app/components/develop/template/template.en.mdx b/web/app/components/develop/template/template.en.mdx index 43dc226107..8212e800f7 100755 --- a/web/app/components/develop/template/template.en.mdx +++ b/web/app/components/develop/template/template.en.mdx @@ -647,3 +647,62 @@ The text generation application offers non-session support and is ideal for tran +--- + + + + + Used to get the WebApp settings of the application. + ### Response + - `title` (string) WebApp name + - `chat_color_theme` (string) Chat color theme, in hex format + - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted + - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture + - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL. + - `icon_background` (string) Background color in hex format + - `icon_url` (string) Icon URL + - `description` (string) Description + - `copyright` (string) Copyright information + - `privacy_policy` (string) Privacy policy link + - `custom_disclaimer` (string) Custom disclaimer + - `default_language` (string) Default language + - `show_workflow_steps` (bool) Whether to show workflow details + - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ diff --git a/web/app/components/develop/template/template.ja.mdx b/web/app/components/develop/template/template.ja.mdx index 2c676e392f..5061792caf 100755 --- a/web/app/components/develop/template/template.ja.mdx +++ b/web/app/components/develop/template/template.ja.mdx @@ -645,3 +645,62 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from +--- + + + + + アプリのWebApp設定を取得するために使用します。 + ### レスポンス + - `title` (string) WebApp名 + - `chat_color_theme` (string) チャットの色テーマ、16進数形式 + - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか + - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像 + - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像URL + - `icon_background` (string) 16進数形式の背景色 + - `icon_url` (string) アイコンのURL + - `description` (string) 説明 + - `copyright` (string) 著作権情報 + - `privacy_policy` (string) プライバシーポリシーのリンク + - `custom_disclaimer` (string) カスタム免責事項 + - `default_language` (string) デフォルト言語 + - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか + - `use_icon_as_answer_icon` (bool) WebAppのアイコンをチャット内の🤖に置き換えるかどうか + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ diff --git a/web/app/components/develop/template/template.zh.mdx b/web/app/components/develop/template/template.zh.mdx index da9aa43204..df83684c06 100755 --- a/web/app/components/develop/template/template.zh.mdx +++ b/web/app/components/develop/template/template.zh.mdx @@ -507,7 +507,6 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - --- --- + + + + 用于获取应用的 WebApp 设置 + ### Response + - `title` (string) WebApp 名称 + - `chat_color_theme` (string) 聊天颜色主题, hex 格式 + - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转 + - `icon_type` (string) 图标类型, `emoji`-表情, `image`-图片 + - `icon` (string) 图标, 如果是 `emoji` 类型, 则是 emoji 表情符号, 如果是 `image` 类型, 则是图片 URL + - `icon_background` (string) hex 格式的背景色 + - `icon_url` (string) 图标 URL + - `description` (string) 描述 + - `copyright` (string) 版权信息 + - `privacy_policy` (string) 隐私政策链接 + - `custom_disclaimer` (string) 自定义免责声明 + - `default_language` (string) 默认语言 + - `show_workflow_steps` (bool) 是否显示工作流详情 + - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ + --- + + + + Used to get the WebApp settings of the application. + ### Response + - `title` (string) WebApp name + - `chat_color_theme` (string) Chat color theme, in hex format + - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted + - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture + - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL + - `icon_background` (string) Background color in hex format + - `icon_url` (string) Icon URL + - `description` (string) Description + - `copyright` (string) Copyright information + - `privacy_policy` (string) Privacy policy link + - `custom_disclaimer` (string) Custom disclaimer + - `default_language` (string) Default language + - `show_workflow_steps` (bool) Whether to show workflow details + - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ + + +--- + + + + + アプリのWebApp設定を取得するために使用します。 + ### 応答 + - `title` (string) WebApp名 + - `chat_color_theme` (string) チャットの色テーマ、16進数形式 + - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか + - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像 + - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像URL + - `icon_background` (string) 16進数形式の背景色 + - `icon_url` (string) アイコンのURL + - `description` (string) 説明 + - `copyright` (string) 著作権情報 + - `privacy_policy` (string) プライバシーポリシーのリンク + - `custom_disclaimer` (string) カスタム免責事項 + - `default_language` (string) デフォルト言語 + - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか + - `use_icon_as_answer_icon` (bool) WebAppのアイコンをチャット内の🤖に置き換えるかどうか + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ diff --git a/web/app/components/develop/template/template_advanced_chat.zh.mdx b/web/app/components/develop/template/template_advanced_chat.zh.mdx index f8d5934974..9077f5492f 100755 --- a/web/app/components/develop/template/template_advanced_chat.zh.mdx +++ b/web/app/components/develop/template/template_advanced_chat.zh.mdx @@ -1329,7 +1329,63 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' --- ---- + + + + 用于获取应用的 WebApp 设置 + ### Response + - `title` (string) WebApp 名称 + - `chat_color_theme` (string) 聊天颜色主题, hex 格式 + - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转 + - `icon_type` (string) 图标类型, `emoji`-表情, `image`-图片 + - `icon` (string) 图标, 如果是 `emoji` 类型, 则是 emoji 表情符号, 如果是 `image` 类型, 则是图片 URL + - `icon_background` (string) hex 格式的背景色 + - `icon_url` (string) 图标 URL + - `description` (string) 描述 + - `copyright` (string) 版权信息 + - `privacy_policy` (string) 隐私政策链接 + - `custom_disclaimer` (string) 自定义免责声明 + - `default_language` (string) 默认语言 + - `show_workflow_steps` (bool) 是否显示工作流详情 + - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ --- + + + + Used to get the WebApp settings of the application. + ### Response + - `title` (string) WebApp name + - `chat_color_theme` (string) Chat color theme, in hex format + - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted + - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture + - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL + - `icon_background` (string) Background color in hex format + - `icon_url` (string) Icon URL + - `description` (string) Description + - `copyright` (string) Copyright information + - `privacy_policy` (string) Privacy policy link + - `custom_disclaimer` (string) Custom disclaimer + - `default_language` (string) Default language + - `show_workflow_steps` (bool) Whether to show workflow details + - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ + + +--- + + + + + アプリのWebApp設定を取得するために使用します。 + ### 応答 + - `title` (string) WebApp名 + - `chat_color_theme` (string) チャットの色テーマ、16進数形式 + - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか + - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像 + - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像URL + - `icon_background` (string) 16進数形式の背景色 + - `icon_url` (string) アイコンのURL + - `description` (string) 説明 + - `copyright` (string) 著作権情報 + - `privacy_policy` (string) プライバシーポリシーのリンク + - `custom_disclaimer` (string) カスタム免責事項 + - `default_language` (string) デフォルト言語 + - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか + - `use_icon_as_answer_icon` (bool) WebAppのアイコンをチャット内の🤖に置き換えるかどうか + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ diff --git a/web/app/components/develop/template/template_chat.zh.mdx b/web/app/components/develop/template/template_chat.zh.mdx index 99c9876546..866170027f 100644 --- a/web/app/components/develop/template/template_chat.zh.mdx +++ b/web/app/components/develop/template/template_chat.zh.mdx @@ -1332,3 +1332,63 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' + +--- + + + + + 用于获取应用的 WebApp 设置 + ### Response + - `title` (string) WebApp 名称 + - `chat_color_theme` (string) 聊天颜色主题, hex 格式 + - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转 + - `icon_type` (string) 图标类型, `emoji`-表情, `image`-图片 + - `icon` (string) 图标, 如果是 `emoji` 类型, 则是 emoji 表情符号, 如果是 `image` 类型, 则是图片 URL + - `icon_background` (string) hex 格式的背景色 + - `icon_url` (string) 图标 URL + - `description` (string) 描述 + - `copyright` (string) 版权信息 + - `privacy_policy` (string) 隐私政策链接 + - `custom_disclaimer` (string) 自定义免责声明 + - `default_language` (string) 默认语言 + - `show_workflow_steps` (bool) 是否显示工作流详情 + - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "chat_color_theme": "#ff4a4a", + "chat_color_theme_inverted": false, + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + "use_icon_as_answer_icon": false, + } + ``` + + + +___ diff --git a/web/app/components/develop/template/template_workflow.en.mdx b/web/app/components/develop/template/template_workflow.en.mdx index 556b306a64..2afcedc88c 100644 --- a/web/app/components/develop/template/template_workflow.en.mdx +++ b/web/app/components/develop/template/template_workflow.en.mdx @@ -737,3 +737,56 @@ Workflow applications offers non-session support and is ideal for translation, a +--- + + + + + Used to get the WebApp settings of the application. + ### Response + - `title` (string) WebApp name + - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture + - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL. + - `icon_background` (string) Background color in hex format + - `icon_url` (string) Icon URL + - `description` (string) Description + - `copyright` (string) Copyright information + - `privacy_policy` (string) Privacy policy link + - `custom_disclaimer` (string) Custom disclaimer + - `default_language` (string) Default language + - `show_workflow_steps` (bool) Whether to show workflow details + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + } + ``` + + + +___ diff --git a/web/app/components/develop/template/template_workflow.ja.mdx b/web/app/components/develop/template/template_workflow.ja.mdx index 3f33be58b9..b6afea9bc4 100644 --- a/web/app/components/develop/template/template_workflow.ja.mdx +++ b/web/app/components/develop/template/template_workflow.ja.mdx @@ -740,3 +740,57 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from +——— + + + + + アプリのWebApp設定を取得するために使用します。 + ### 応答 + - `title` (string) WebApp名 + - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像 + - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像URL + - `icon_background` (string) 16進数形式の背景色 + - `icon_url` (string) アイコンのURL + - `description` (string) 説明 + - `copyright` (string) 著作権情報 + - `privacy_policy` (string) プライバシーポリシーのリンク + - `custom_disclaimer` (string) カスタム免責事項 + - `default_language` (string) デフォルト言語 + - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + } + ``` + + + +___ + diff --git a/web/app/components/develop/template/template_workflow.zh.mdx b/web/app/components/develop/template/template_workflow.zh.mdx index b032407ee9..e78b309e05 100644 --- a/web/app/components/develop/template/template_workflow.zh.mdx +++ b/web/app/components/develop/template/template_workflow.zh.mdx @@ -727,3 +727,57 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 + +--- + + + + + 用于获取应用的 WebApp 设置 + ### Response + - `title` (string) WebApp 名称 + - `icon_type` (string) 图标类型, `emoji`-表情, `image`-图片 + - `icon` (string) 图标, 如果是 `emoji` 类型, 则是 emoji 表情符号, 如果是 `image` 类型, 则是图片 URL + - `icon_background` (string) hex 格式的背景色 + - `icon_url` (string) 图标 URL + - `description` (string) 描述 + - `copyright` (string) 版权信息 + - `privacy_policy` (string) 隐私政策链接 + - `custom_disclaimer` (string) 自定义免责声明 + - `default_language` (string) 默认语言 + - `show_workflow_steps` (bool) 是否显示工作流详情 + + + + ```bash {{ title: 'cURL' }} + curl -X GET '${props.appDetail.api_base_url}/site' \ + -H 'Authorization: Bearer {api_key}' + ``` + + + + + ```json {{ title: 'Response' }} + { + "title": "My App", + "icon_type": "emoji", + "icon": "😄", + "icon_background": "#FFEAD5", + "icon_url": null, + "description": "This is my app.", + "copyright": "all rights reserved", + "privacy_policy": "", + "custom_disclaimer": "All generated by AI", + "default_language": "en-US", + "show_workflow_steps": false, + } + ``` + + + +___