Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

annotation_fields.py 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. from flask_restx import Api, Namespace, fields
  2. from libs.helper import TimestampField
  3. annotation_fields = {
  4. "id": fields.String,
  5. "question": fields.String,
  6. "answer": fields.Raw(attribute="content"),
  7. "hit_count": fields.Integer,
  8. "created_at": TimestampField,
  9. # 'account': fields.Nested(simple_account_fields, allow_null=True)
  10. }
  11. def build_annotation_model(api_or_ns: Api | Namespace):
  12. """Build the annotation model for the API or Namespace."""
  13. return api_or_ns.model("Annotation", annotation_fields)
  14. annotation_list_fields = {
  15. "data": fields.List(fields.Nested(annotation_fields)),
  16. }
  17. annotation_hit_history_fields = {
  18. "id": fields.String,
  19. "source": fields.String,
  20. "score": fields.Float,
  21. "question": fields.String,
  22. "created_at": TimestampField,
  23. "match": fields.String(attribute="annotation_question"),
  24. "response": fields.String(attribute="annotation_content"),
  25. }
  26. annotation_hit_history_list_fields = {
  27. "data": fields.List(fields.Nested(annotation_hit_history_fields)),
  28. }