chat_embed.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. # coding=utf-8
  2. """
  3. @project: MaxKB
  4. @Author:虎虎
  5. @file: chat_embed.py
  6. @date:2025/5/30 15:22
  7. @desc:
  8. """
  9. from django.utils.translation import gettext_lazy as _
  10. from drf_spectacular.utils import extend_schema
  11. from rest_framework.request import Request
  12. from rest_framework.views import APIView
  13. from chat.api.chat_embed_api import ChatEmbedAPI
  14. from chat.serializers.chat_embed_serializers import ChatEmbedSerializer
  15. class ChatEmbedView(APIView):
  16. @extend_schema(
  17. methods=['GET'],
  18. description=_('Get embedded js'),
  19. summary=_('Get embedded js'),
  20. operation_id=_('Get embedded js'), # type: ignore
  21. parameters=ChatEmbedAPI.get_parameters(),
  22. responses=ChatEmbedAPI.get_response(),
  23. tags=[_('Chat')] # type: ignore
  24. )
  25. def get(self, request: Request):
  26. return ChatEmbedSerializer(
  27. data={'protocol': request.query_params.get('protocol'), 'token': request.query_params.get('token'),
  28. 'host': request.query_params.get('host'), }).get_embed(params=request.query_params)