From 16fec084f5daa4ded8360ba0ee447b7b51f66cb1 Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Fri, 24 May 2024 11:11:12 +0800 Subject: [PATCH] Fix/4630 bug api suggested (#4633) --- api/controllers/service_api/app/message.py | 4 ++-- .../develop/template/template_advanced_chat.en.mdx | 12 ++++++++++-- .../develop/template/template_advanced_chat.zh.mdx | 11 +++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/api/controllers/service_api/app/message.py b/api/controllers/service_api/app/message.py index 08f382b0a7..c8b44cfa38 100644 --- a/api/controllers/service_api/app/message.py +++ b/api/controllers/service_api/app/message.py @@ -97,7 +97,7 @@ class MessageListApi(Resource): class MessageFeedbackApi(Resource): - @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.JSON)) + @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.JSON, required=True)) def post(self, app_model: App, end_user: EndUser, message_id): message_id = str(message_id) @@ -114,7 +114,7 @@ class MessageFeedbackApi(Resource): class MessageSuggestedApi(Resource): - @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.QUERY)) + @validate_app_token(fetch_user_arg=FetchUserArg(fetch_from=WhereisUserArg.QUERY, required=True)) def get(self, app_model: App, end_user: EndUser, message_id): message_id = str(message_id) app_mode = AppMode.value_of(app_model.mode) diff --git a/web/app/components/develop/template/template_advanced_chat.en.mdx b/web/app/components/develop/template/template_advanced_chat.en.mdx index f473feda2b..006134e45e 100644 --- a/web/app/components/develop/template/template_advanced_chat.en.mdx +++ b/web/app/components/develop/template/template_advanced_chat.en.mdx @@ -476,13 +476,21 @@ Chat applications support session persistence, allowing previous chat history to Message ID + + ### Query + + + User identifier, used to define the identity of the end-user for retrieval and statistics. + Should be uniquely defined by the developer within the application. + + - + ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \ + curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \ --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ --header 'Content-Type: application/json' \ ``` 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 ca087e345d..4c57f2abaa 100644 --- a/web/app/components/develop/template/template_advanced_chat.zh.mdx +++ b/web/app/components/develop/template/template_advanced_chat.zh.mdx @@ -483,13 +483,20 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' Message ID + + ### Query + + + 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。 + + - + ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \ + curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested'?user=abc-123 \ --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ --header 'Content-Type: application/json' \ ```