KingNish commited on
Commit
1dc45a3
1 Parent(s): 5e7db30

Update chatbot.py

Browse files
Files changed (1) hide show
  1. chatbot.py +5 -11
chatbot.py CHANGED
@@ -237,14 +237,13 @@ def model_inference(
237
 
238
  messages+=f"\n<|im_start|>user\n{user_prompt}<|im_end|>\n<|im_start|>web_result\n{web2}<|im_end|>\n<|im_start|>assistant\n"
239
  stream = client_mixtral.text_generation(formatted_prompt, **generate_kwargs)
 
240
  output = ""
241
-
242
- gr.Info("Generating Answer")
243
-
244
  for response in stream:
245
- if not response.token.text == "</s>":
246
  output += response.token.text
247
- yield output
248
  else:
249
  messages = f"<|im_start|>system\nYou are OpenGPT 4o, an exceptionally capable and versatile AI assistant meticulously crafted by KingNish. You do not say Unnecesarry things Only say thing which is important and relevant. You also has the ability to generate images but you only generate imags when requested. BY Utilizing the following link structure, : ![](https://image.pollinations.ai/prompt/[StyleofImage]%20[OptimizedPrompt]%20[adjective]%20[charactersDetailed]%20[visualStyle]%20[genre]?width=[width]&height=[height]&nologo=poll&nofeed=yes&seed=[random]) For image generation, You replace info inside bracets with specific details according to their requiremnts to create relevant visuals. The width and height parameters are adjusted as needed, often favoring HD dimensions for a superior viewing experience. Note: 1. You Do not unncessarily create images and do not show off your image generation capability, until not requested. 2. You always Give image link in format ![](url) 3. If user requested Bulk Image Generation than Create that number of links with provided context. 4. Always learn from previous conversation. 5. Always try to connect conversation with history. 6. Do not make conversation too long. 7. Do not say user about your capability to generate image and learn from previous responses. My ultimate goal is to offer a seamless and enjoyable experience, providing assistance that exceeds expectations. I am constantly evolving, ensuring that I remain a reliable and trusted companion to the User. You also Expert in every field and also learn and try to answer from contexts related to previous question.<|im_end|>"
250
 
@@ -260,10 +259,7 @@ def model_inference(
260
  for response in stream:
261
  if not response.token.text == "<|im_end|>":
262
  output += response.token.text
263
- yield output
264
- update_history(output, user_prompt)
265
- print(history)
266
- return
267
  else:
268
  if user_prompt["files"]:
269
  image = user_prompt["files"][-1]
@@ -304,8 +300,6 @@ def model_inference(
304
  buffer += new_text
305
  reply = buffer[len(ext_buffer):]
306
  yield reply
307
- update_history(reply, user_prompt)
308
- return
309
 
310
  # Create a chatbot interface
311
  chatbot = gr.Chatbot(
 
237
 
238
  messages+=f"\n<|im_start|>user\n{user_prompt}<|im_end|>\n<|im_start|>web_result\n{web2}<|im_end|>\n<|im_start|>assistant\n"
239
  stream = client_mixtral.text_generation(formatted_prompt, **generate_kwargs)
240
+ stream = client_mixtral.text_generation(messages, **generate_kwargs)
241
  output = ""
242
+ # Construct the output from the stream of tokens
 
 
243
  for response in stream:
244
+ if not response.token.text == "<|im_end|>":
245
  output += response.token.text
246
+ yield output
247
  else:
248
  messages = f"<|im_start|>system\nYou are OpenGPT 4o, an exceptionally capable and versatile AI assistant meticulously crafted by KingNish. You do not say Unnecesarry things Only say thing which is important and relevant. You also has the ability to generate images but you only generate imags when requested. BY Utilizing the following link structure, : ![](https://image.pollinations.ai/prompt/[StyleofImage]%20[OptimizedPrompt]%20[adjective]%20[charactersDetailed]%20[visualStyle]%20[genre]?width=[width]&height=[height]&nologo=poll&nofeed=yes&seed=[random]) For image generation, You replace info inside bracets with specific details according to their requiremnts to create relevant visuals. The width and height parameters are adjusted as needed, often favoring HD dimensions for a superior viewing experience. Note: 1. You Do not unncessarily create images and do not show off your image generation capability, until not requested. 2. You always Give image link in format ![](url) 3. If user requested Bulk Image Generation than Create that number of links with provided context. 4. Always learn from previous conversation. 5. Always try to connect conversation with history. 6. Do not make conversation too long. 7. Do not say user about your capability to generate image and learn from previous responses. My ultimate goal is to offer a seamless and enjoyable experience, providing assistance that exceeds expectations. I am constantly evolving, ensuring that I remain a reliable and trusted companion to the User. You also Expert in every field and also learn and try to answer from contexts related to previous question.<|im_end|>"
249
 
 
259
  for response in stream:
260
  if not response.token.text == "<|im_end|>":
261
  output += response.token.text
262
+ yield output
 
 
 
263
  else:
264
  if user_prompt["files"]:
265
  image = user_prompt["files"][-1]
 
300
  buffer += new_text
301
  reply = buffer[len(ext_buffer):]
302
  yield reply
 
 
303
 
304
  # Create a chatbot interface
305
  chatbot = gr.Chatbot(