(self, instance: Dict, with_valid=True)
| 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 | |
| 285 | class ChatSerializers(serializers.Serializer): |
nothing calls this directly
no test coverage detected