|  | 
| 16 | 16 | from controllers.console.explore.error import AppSuggestedQuestionsAfterAnswerDisabledError | 
| 17 | 17 | from controllers.console.wraps import ( | 
| 18 | 18 |     account_initialization_required, | 
| 19 |  | -    cloud_edition_billing_resource_check, | 
| 20 | 19 |     edit_permission_required, | 
| 21 | 20 |     setup_required, | 
| 22 | 21 | ) | 
| 23 | 22 | from core.app.entities.app_invoke_entities import InvokeFrom | 
| 24 | 23 | from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError | 
| 25 | 24 | from core.model_runtime.errors.invoke import InvokeError | 
| 26 | 25 | from extensions.ext_database import db | 
| 27 |  | -from fields.conversation_fields import annotation_fields, message_detail_fields | 
|  | 26 | +from fields.conversation_fields import message_detail_fields | 
| 28 | 27 | from libs.helper import uuid_value | 
| 29 | 28 | from libs.infinite_scroll_pagination import InfiniteScrollPagination | 
| 30 | 29 | from libs.login import current_account_with_tenant, login_required | 
| 31 | 30 | from models.model import AppMode, Conversation, Message, MessageAnnotation, MessageFeedback | 
| 32 |  | -from services.annotation_service import AppAnnotationService | 
| 33 | 31 | from services.errors.conversation import ConversationNotExistsError | 
| 34 | 32 | from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError | 
| 35 | 33 | from services.message_service import MessageService | 
| @@ -194,45 +192,6 @@ def post(self, app_model): | 
| 194 | 192 |         return {"result": "success"} | 
| 195 | 193 | 
 | 
| 196 | 194 | 
 | 
| 197 |  | -@console_ns.route("/apps/<uuid:app_id>/annotations") | 
| 198 |  | -class MessageAnnotationApi(Resource): | 
| 199 |  | -    @api.doc("create_message_annotation") | 
| 200 |  | -    @api.doc(description="Create message annotation") | 
| 201 |  | -    @api.doc(params={"app_id": "Application ID"}) | 
| 202 |  | -    @api.expect( | 
| 203 |  | -        api.model( | 
| 204 |  | -            "MessageAnnotationRequest", | 
| 205 |  | -            { | 
| 206 |  | -                "message_id": fields.String(description="Message ID"), | 
| 207 |  | -                "question": fields.String(required=True, description="Question text"), | 
| 208 |  | -                "answer": fields.String(required=True, description="Answer text"), | 
| 209 |  | -                "annotation_reply": fields.Raw(description="Annotation reply"), | 
| 210 |  | -            }, | 
| 211 |  | -        ) | 
| 212 |  | -    ) | 
| 213 |  | -    @api.response(200, "Annotation created successfully", annotation_fields) | 
| 214 |  | -    @api.response(403, "Insufficient permissions") | 
| 215 |  | -    @marshal_with(annotation_fields) | 
| 216 |  | -    @get_app_model | 
| 217 |  | -    @setup_required | 
| 218 |  | -    @login_required | 
| 219 |  | -    @cloud_edition_billing_resource_check("annotation") | 
| 220 |  | -    @account_initialization_required | 
| 221 |  | -    @edit_permission_required | 
| 222 |  | -    def post(self, app_model): | 
| 223 |  | -        parser = ( | 
| 224 |  | -            reqparse.RequestParser() | 
| 225 |  | -            .add_argument("message_id", required=False, type=uuid_value, location="json") | 
| 226 |  | -            .add_argument("question", required=True, type=str, location="json") | 
| 227 |  | -            .add_argument("answer", required=True, type=str, location="json") | 
| 228 |  | -            .add_argument("annotation_reply", required=False, type=dict, location="json") | 
| 229 |  | -        ) | 
| 230 |  | -        args = parser.parse_args() | 
| 231 |  | -        annotation = AppAnnotationService.up_insert_app_annotation_from_message(args, app_model.id) | 
| 232 |  | - | 
| 233 |  | -        return annotation | 
| 234 |  | - | 
| 235 |  | - | 
| 236 | 195 | @console_ns.route("/apps/<uuid:app_id>/annotations/count") | 
| 237 | 196 | class MessageAnnotationCountApi(Resource): | 
| 238 | 197 |     @api.doc("get_annotation_count") | 
|  | 
0 commit comments