YchKhan commited on
Commit
fec7c0c
Β·
verified Β·
1 Parent(s): cc67e26

Update app.py

Browse files

add groq models

Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -28,6 +28,9 @@ from openai import OpenAI
28
  from mistralai.client import MistralClient
29
  from mistralai.models.chat_completion import ChatMessage
30
 
 
 
 
31
  MODEL_LIST = [
32
  "mistral-tiny",
33
  "mistral-small",
@@ -448,7 +451,17 @@ def gpt_answer(api_key, query, model="gpt-3.5-turbo-1106", system_prompt="Use th
448
  ChatMessage(role="user", content=query)],
449
  )
450
  return chat_response.choices[0].message.content
451
-
 
 
 
 
 
 
 
 
 
 
452
 
453
  def add_line_breaks(input_string, line_length=100):
454
  lines = []
@@ -517,7 +530,7 @@ with gr.Blocks() as demo:
517
  gr.Markdown("Upload your documents and question them.")
518
  with gr.Accordion("Open to enter your API key", open=False):
519
  apikey_input = gr.Textbox(placeholder="Type here your OpenAI API key to use Summarization and Q&A", label="OpenAI API Key",type='password')
520
- dd_model = gr.Dropdown(["mistral-tiny", "mistral-small", "mistral-medium","gpt-3.5-turbo-1106", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4-1106-preview", "gpt-4", "gpt-4-32k"], value="gpt-3.5-turbo-1106", label='List of models', allow_custom_value=True, scale=1)
521
 
522
  with gr.Tab("Upload PDF & TXT"):
523
  with gr.Accordion("Get files from the web", open=False):
 
28
  from mistralai.client import MistralClient
29
  from mistralai.models.chat_completion import ChatMessage
30
 
31
+ from groq import Groq
32
+
33
+
34
  MODEL_LIST = [
35
  "mistral-tiny",
36
  "mistral-small",
 
451
  ChatMessage(role="user", content=query)],
452
  )
453
  return chat_response.choices[0].message.content
454
+ if 'groq' in model:
455
+ client = Groq(api_key=api_key)
456
+ chat_completion = client.chat.completions.create(
457
+ messages=[
458
+ {"role": "system", "content": system_prompt},
459
+ {"role": "user", "content": query},
460
+
461
+ ],
462
+ model=model,
463
+ )
464
+ return chat_completion.choices[0].message.content
465
 
466
  def add_line_breaks(input_string, line_length=100):
467
  lines = []
 
530
  gr.Markdown("Upload your documents and question them.")
531
  with gr.Accordion("Open to enter your API key", open=False):
532
  apikey_input = gr.Textbox(placeholder="Type here your OpenAI API key to use Summarization and Q&A", label="OpenAI API Key",type='password')
533
+ dd_model = gr.Dropdown(["groq:llama-3.3-70b-specdec", "groq:llama-3.3-70b-versatile", "groq:mixtral-8x7b-32768", "groq:llama-3.1-70b-versatile", "groq:llama-3.2-90b-text-preview", "mistral-tiny", "mistral-small", "mistral-medium","gpt-3.5-turbo-1106", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4-1106-preview", "gpt-4", "gpt-4-32k"], value="gpt-3.5-turbo-1106", label='List of models', allow_custom_value=True, scale=1)
534
 
535
  with gr.Tab("Upload PDF & TXT"):
536
  with gr.Accordion("Get files from the web", open=False):