MCPcopy
hub / github.com/1Panel-dev/MaxKB / chat

Method chat

apps/chat/serializers/chat.py:251–282  ·  view source on GitHub ↗
(self, instance: Dict, with_valid=True)

Source from the content-addressed store, hash-verified

249 return chat_id
250
251 def chat(self, instance: Dict, with_valid=True):
252 if with_valid:
253 self.is_valid(raise_exception=True)
254 OpenAIInstanceSerializer(data=instance).is_valid(raise_exception=True)
255 chat_id = instance.get('chat_id')
256 message = self.get_message(instance)
257 re_chat = instance.get('re_chat', False)
258 stream = instance.get('stream', False)
259 application_id = self.data.get('application_id')
260 chat_user_id = self.data.get('chat_user_id')
261 chat_user_type = self.data.get('chat_user_type')
262 ip_address = self.data.get('ip_address')
263 source = self.data.get('source')
264 chat_id = self.generate_chat(chat_id, application_id, message, chat_user_id, chat_user_type, ip_address, source)
265 return ChatSerializers(
266 data={
267 'chat_id': chat_id,
268 'chat_user_id': chat_user_id,
269 'chat_user_type': chat_user_type,
270 'application_id': application_id,
271 'ip_address': ip_address,
272 'source': source,
273 }
274 ).chat({'message': message,
275 're_chat': re_chat,
276 'stream': stream,
277 'form_data': instance.get('form_data', {}),
278 'image_list': instance.get('image_list', []),
279 'document_list': instance.get('document_list', []),
280 'audio_list': instance.get('audio_list', []),
281 'other_list': instance.get('other_list', [])},
282 base_to_response=OpenaiToResponse())
283
284
285class ChatSerializers(serializers.Serializer):

Callers

nothing calls this directly

Calls 8

get_messageMethod · 0.95
generate_chatMethod · 0.95
OpenaiToResponseClass · 0.90
ChatSerializersClass · 0.85
is_validMethod · 0.45
getMethod · 0.45
chatMethod · 0.45

Tested by

no test coverage detected