MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / generate_chat

Method generate_chat

apps/chat/serializers/chat.py:229–249  ·  view source on GitHub ↗
(chat_id, application_id, message, chat_user_id, chat_user_type, ip_address, source)

Source from the content-addressed store, hash-verified

227
228 @staticmethod
229 def generate_chat(chat_id, application_id, message, chat_user_id, chat_user_type, ip_address, source):
230 if chat_id is None:
231 chat_id = str(uuid.uuid1())
232 chat_info = ChatInfo(chat_id, chat_user_id, chat_user_type, ip_address, source, [], [],
233 application_id)
234 chat_info.set_cache()
235 else:
236 chat_info = ChatInfo.get_cache(chat_id)
237 if chat_info is None:
238 open_chat = ChatSerializers(data={
239 'chat_id': chat_id,
240 'chat_user_id': chat_user_id,
241 'chat_user_type': chat_user_type,
242 'application_id': application_id,
243 'ip_address': ip_address,
244 'source': source,
245 })
246 open_chat.is_valid(raise_exception=True)
247 chat_info = open_chat.re_open_chat(chat_id)
248 chat_info.set_cache()
249 return chat_id
250
251 def chat(self, instance: Dict, with_valid=True):
252 if with_valid:

Callers 1

chatMethod · 0.95

Calls 6

set_cacheMethod · 0.95
re_open_chatMethod · 0.95
ChatInfoClass · 0.90
ChatSerializersClass · 0.85
get_cacheMethod · 0.80
is_validMethod · 0.45

Tested by

no test coverage detected