randydev commited on
Commit
0d14b43
·
verified ·
1 Parent(s): ef75606

Update chatbot/plugins/chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +6 -5
chatbot/plugins/chat.py CHANGED
@@ -48,9 +48,9 @@ python language powered by @xtdevs on telegram support and language models Meta
48
 
49
  async def process_stream(message, prompt):
50
  client_hf = InferenceClient(api_key=HF_KEY)
51
- backup_chat = await db._get_openai_chat_from_db(message.from_user.id)
52
- backup_chat.append({"role": "system", "content": SYSTEM_PROMPT})
53
- backup_chat.append({"role": "user", "content": prompt})
54
  stream = client_hf.chat.completions.create(
55
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
56
  messages=backup_chat,
@@ -59,10 +59,11 @@ async def process_stream(message, prompt):
59
  )
60
  accumulated_text = ""
61
  for chunk in stream:
 
62
  new_content = chunk.choices[0].delta.content
63
  accumulated_text += new_content
64
- backup_chat.append({"role": "user", "content": accumulated_text})
65
- await db._update_openai_chat_in_db(message.from_user.id, backup_chat)
66
  return accumulated_text
67
 
68
  @Client.on_message(
 
48
 
49
  async def process_stream(message, prompt):
50
  client_hf = InferenceClient(api_key=HF_KEY)
51
+ # backup_chat = await db._get_openai_chat_from_db(message.from_user.id)
52
+ # backup_chat.append({"role": "system", "content": SYSTEM_PROMPT})
53
+ # backup_chat.append({"role": "user", "content": prompt})
54
  stream = client_hf.chat.completions.create(
55
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
56
  messages=backup_chat,
 
59
  )
60
  accumulated_text = ""
61
  for chunk in stream:
62
+ LOGS.info(chunk)
63
  new_content = chunk.choices[0].delta.content
64
  accumulated_text += new_content
65
+ # backup_chat.append({"role": "user", "content": accumulated_text})
66
+ # await db._update_openai_chat_in_db(message.from_user.id, backup_chat)
67
  return accumulated_text
68
 
69
  @Client.on_message(