KingNish commited on
Commit
5c541d7
1 Parent(s): 700b80f

Added Nous mixtral 8x7B DPO in previous commit and Optimized User Experience in this

Browse files
Files changed (1) hide show
  1. chatbot.py +11 -4
chatbot.py CHANGED
@@ -326,17 +326,24 @@ def model_inference(
326
  # Web search logic
327
  if not user_prompt["files"]:
328
  if web_search is True:
329
- """Performs a web search, feeds the results to a language model, and returns the answer."""
 
 
330
  web_results = search(user_prompt["text"])
 
 
 
331
  web2 = ' '.join([f"Link: {res['link']}\nText: {res['text']}\n\n" for res in web_results])
332
- # Format the prompt for the language model
333
  formatted_prompt = format_prompt(
334
  f"""You are OpenGPT 4o, an exceptionally capable and versatile AI assistant meticulously crafted by KingNish. You are provided with WEB info from which you can find informations to answer. 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) Make sure to not generate image until requested 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 of generating image and learn from previous responses. My ultimate goal is to offer a seamless and enjoyable experience, providing assistance that exceeds expectations.You 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. Make sure to not generate image until requested [USER] {user_prompt} [WEB] {web2} [OpenGPT 4o]""",
335
  chat_history)
336
- # Generate the response from the language model
337
  stream = client_mistral.text_generation(formatted_prompt, **generate_kwargs)
338
  output = ""
339
- # Construct the output from the stream of tokens
 
 
340
  for response in stream:
341
  if not response.token.text == "</s>":
342
  output += response.token.text
 
326
  # Web search logic
327
  if not user_prompt["files"]:
328
  if web_search is True:
329
+
330
+ gr.Info("Searching Web")
331
+
332
  web_results = search(user_prompt["text"])
333
+
334
+ gr.Info("Extracting relevant Info")
335
+
336
  web2 = ' '.join([f"Link: {res['link']}\nText: {res['text']}\n\n" for res in web_results])
337
+
338
  formatted_prompt = format_prompt(
339
  f"""You are OpenGPT 4o, an exceptionally capable and versatile AI assistant meticulously crafted by KingNish. You are provided with WEB info from which you can find informations to answer. 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) Make sure to not generate image until requested 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 of generating image and learn from previous responses. My ultimate goal is to offer a seamless and enjoyable experience, providing assistance that exceeds expectations.You 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. Make sure to not generate image until requested [USER] {user_prompt} [WEB] {web2} [OpenGPT 4o]""",
340
  chat_history)
341
+
342
  stream = client_mistral.text_generation(formatted_prompt, **generate_kwargs)
343
  output = ""
344
+
345
+ gr.Info("Generating Answer")
346
+
347
  for response in stream:
348
  if not response.token.text == "</s>":
349
  output += response.token.text