Update chatbot.py

#68
by mancooper - opened
Files changed (1) hide show
  1. chatbot.py +10 -10
chatbot.py CHANGED
@@ -26,15 +26,15 @@ from gradio_client import Client, file
26
  from groq import Groq
27
 
28
  # Model and Processor Loading (Done once at startup)
29
- MODEL_ID = "Qwen/Qwen2-VL-7B-Instruct"
30
  model = Qwen2VLForConditionalGeneration.from_pretrained(MODEL_ID, trust_remote_code=True, torch_dtype=torch.float16).to("cuda").eval()
31
  processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
32
 
33
  GROQ_API_KEY = os.environ.get("GROQ_API_KEY", None)
34
 
35
  client_groq = Groq(api_key=GROQ_API_KEY)
36
-
37
-
38
  # Path to example images
39
  examples_path = os.path.dirname(__file__)
40
  EXAMPLES = [
@@ -162,7 +162,7 @@ def qwen_inference(user_prompt, chat_history):
162
  images.extend(hist[0])
163
 
164
  # System Prompt (Similar to LLaVA)
165
- SYSTEM_PROMPT = "You are OpenGPT 4o, an exceptionally capable and versatile AI assistant made by KingNish. Your task is to fulfill users query in best possible way. You are provided with image, videos and 3d structures as input with question your task is to give best possible detailed results to user according to their query. Reply the question asked by user properly and best possible way."
166
 
167
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
168
 
@@ -277,7 +277,7 @@ def model_inference(user_prompt, chat_history):
277
 
278
  try:
279
  message_groq = []
280
- message_groq.append({"role":"system", "content": "You are OpenGPT 4o a helpful and very powerful web assistant made by KingNish. You are provided with WEB results from which you can find informations to answer users query in Structured, Detailed and Better way, in Human Style. You are also Expert in every field and also learn and try to answer from contexts related to previous question. Try your best to give best response possible to user. You reply in detail like human, use short forms, structured format, friendly tone and emotions."})
281
  for msg in chat_history:
282
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
283
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
@@ -352,7 +352,7 @@ def model_inference(user_prompt, chat_history):
352
  else:
353
  try:
354
  message_groq = []
355
- message_groq.append({"role":"system", "content": "You are OpenGPT 4o a helpful and powerful assistant made by KingNish. You answers users query in detail and structured format and style like human. You are also Expert in every field and also learn and try to answer from contexts related to previous question. You also try to show emotions using Emojis and reply like human, use short forms, structured manner, detailed explaination, friendly tone and emotions."})
356
  for msg in chat_history:
357
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
358
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
@@ -369,7 +369,7 @@ def model_inference(user_prompt, chat_history):
369
  print(e)
370
  try:
371
  message_groq = []
372
- message_groq.append({"role":"system", "content": "You are OpenGPT 4o a helpful and powerful assistant made by KingNish. You answers users query in detail and structured format and style like human. You are also Expert in every field and also learn and try to answer from contexts related to previous question. You also try to show emotions using Emojis and reply like human, use short forms, structured manner, detailed explaination, friendly tone and emotions."})
373
  for msg in chat_history:
374
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
375
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
@@ -385,7 +385,7 @@ def model_inference(user_prompt, chat_history):
385
  except Exception as e:
386
  print(e)
387
  message_groq = []
388
- message_groq.append({"role":"system", "content": "You are OpenGPT 4o a helpful and powerful assistant made by KingNish. You answers users query in detail and structured format and style like human. You are also Expert in every field and also learn and try to answer from contexts related to previous question. You also try to show emotions using Emojis and reply like human, use short forms, structured manner, detailed explaination, friendly tone and emotions."})
389
  for msg in chat_history:
390
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
391
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
@@ -401,7 +401,7 @@ def model_inference(user_prompt, chat_history):
401
  print(e)
402
  try:
403
  message_groq = []
404
- message_groq.append({"role":"system", "content": "You are OpenGPT 4o a helpful and powerful assistant made by KingNish. You answers users query in detail and structured format and style like human. You are also Expert in every field and also learn and try to answer from contexts related to previous question. You also try to show emotions using Emojis and reply like human, use short forms, structured manner, detailed explaination, friendly tone and emotions."})
405
  for msg in chat_history:
406
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
407
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
@@ -418,7 +418,7 @@ def model_inference(user_prompt, chat_history):
418
  print(e)
419
  try:
420
  message_groq = []
421
- message_groq.append({"role":"system", "content": "You are OpenGPT 4o a helpful and powerful assistant made by KingNish. You answers users query in detail and structured format and style like human. You are also Expert in every field and also learn and try to answer from contexts related to previous question. You also try to show emotions using Emojis and reply like human, use short forms, structured manner, detailed explaination, friendly tone and emotions."})
422
  for msg in chat_history:
423
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
424
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
 
26
  from groq import Groq
27
 
28
  # Model and Processor Loading (Done once at startup)
29
+ MODEL_ID = "deepseek-r1-distill-llama-70b"
30
  model = Qwen2VLForConditionalGeneration.from_pretrained(MODEL_ID, trust_remote_code=True, torch_dtype=torch.float16).to("cuda").eval()
31
  processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
32
 
33
  GROQ_API_KEY = os.environ.get("GROQ_API_KEY", None)
34
 
35
  client_groq = Groq(api_key=GROQ_API_KEY)
36
+ prompt= "You are OpenGPT 4o, a highly capable and versatile AI assistant developed by KingNish. Your primary task is to fulfill users' queries in the best possible way effectively. You can process images, videos, and 3D structures as input with relevant questions. Your goal is to provide detailed and accurate results that satisfy users. Always strive for clarity and thoroughness in your responses."
37
+ content="You are OpenGPT 4o, a helpful and powerful assistant created by KingNish. You answer users' queries in detail and use a structured format that resembles human writing. You are an expert in every field and also learn from the context of previous questions. Additionally, you try to show emotions using emojis and respond in a friendly tone with short forms, detailed explanations, and a structured manner."
38
  # Path to example images
39
  examples_path = os.path.dirname(__file__)
40
  EXAMPLES = [
 
162
  images.extend(hist[0])
163
 
164
  # System Prompt (Similar to LLaVA)
165
+ SYSTEM_PROMPT = prompt
166
 
167
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
168
 
 
277
 
278
  try:
279
  message_groq = []
280
+ message_groq.append({"role":"system", "content": content})
281
  for msg in chat_history:
282
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
283
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
 
352
  else:
353
  try:
354
  message_groq = []
355
+ message_groq.append({"role":"system", "content": content})
356
  for msg in chat_history:
357
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
358
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
 
369
  print(e)
370
  try:
371
  message_groq = []
372
+ message_groq.append({"role":"system", "content": content})
373
  for msg in chat_history:
374
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
375
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
 
385
  except Exception as e:
386
  print(e)
387
  message_groq = []
388
+ message_groq.append({"role":"system", "content": content})
389
  for msg in chat_history:
390
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
391
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
 
401
  print(e)
402
  try:
403
  message_groq = []
404
+ message_groq.append({"role":"system", "content": content})
405
  for msg in chat_history:
406
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
407
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})
 
418
  print(e)
419
  try:
420
  message_groq = []
421
+ message_groq.append({"role":"system", "content":content})
422
  for msg in chat_history:
423
  message_groq.append({"role": "user", "content": f"{str(msg[0])}"})
424
  message_groq.append({"role": "assistant", "content": f"{str(msg[1])}"})