zcaspar commited on
Commit
0742336
·
verified ·
1 Parent(s): 75497ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -38
app.py CHANGED
@@ -3,7 +3,6 @@ import json
3
  import gradio as gr
4
  from openai import OpenAI
5
  import requests
6
- from huggingface_hub import hf_hub_download
7
  import time
8
  import google.generativeai as genai
9
  from groq import Groq
@@ -108,48 +107,13 @@ def query_gemini(prompt, chatbot_state):
108
  response_times["Gemini Flash 2.0"].append(time.time() - start_time)
109
 
110
 
111
- def query_groq_Llama3_3(prompt, chatbot_state):
112
- """Queries Groq's model via Groq API."""
113
- start_time = time.time()
114
- try:
115
- # Format conversation history
116
- messages = [{"role": entry["role"], "content": entry["content"]} for entry in chatbot_state]
117
- messages.append({"role": "user", "content": prompt})
118
-
119
- # Make the API call to Groq
120
- response = groq_client.chat.completions.create(
121
- model="llama-3.3-70b-versatile",
122
- messages=messages
123
- )
124
-
125
- # Extract the content correctly
126
- reply = response.choices[0].message.content
127
- return reply
128
-
129
- except AttributeError as e:
130
- # Handle specific error related to object structure
131
- return f"Groq Attribute Error: {str(e)}"
132
- except Exception as e:
133
- # Handle general errors
134
- return f"Groq Error: {str(e)}"
135
- finally:
136
- response_times["Groq - llama-3.3-70b"].append(time.time() - start_time)
137
-
138
  def chatbot_response(prompt, model_choice, chatbot_state):
139
  """Handles the conversation flow and updates the chatbot state."""
140
  # Add user message to the conversation history
141
  chatbot_state.append({"role": "user", "content": prompt})
142
 
143
  # Generate a response based on the selected model
144
- if model_choice == "Mistral-7B-Instruct":
145
- response = query_mistral(prompt, chatbot_state)
146
- elif model_choice == "Groq - llama-3.1-8b":
147
- response = query_groq(prompt, chatbot_state)
148
- elif model_choice == "Groq - Llama 3.3":
149
- response = query_groq_Llama3_3(prompt, chatbot_state)
150
- elif model_choice == "Grok 2":
151
- response = query_grok(prompt, chatbot_state)
152
- elif model_choice == "Gemini Flash 2.0":
153
  response = query_gemini(prompt, chatbot_state)
154
  elif model_choice == "Deepseek":
155
  response = query_deepseek(prompt, chatbot_state)
@@ -213,4 +177,5 @@ with gr.Blocks() as demo:
213
  outputs=[chatbot, chatbot_input, chatbot_state] # Clear the chatbot UI and the state
214
  )
215
 
216
- demo.launch(auth=("latham", "1956"),share=False)
 
 
3
  import gradio as gr
4
  from openai import OpenAI
5
  import requests
 
6
  import time
7
  import google.generativeai as genai
8
  from groq import Groq
 
107
  response_times["Gemini Flash 2.0"].append(time.time() - start_time)
108
 
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  def chatbot_response(prompt, model_choice, chatbot_state):
111
  """Handles the conversation flow and updates the chatbot state."""
112
  # Add user message to the conversation history
113
  chatbot_state.append({"role": "user", "content": prompt})
114
 
115
  # Generate a response based on the selected model
116
+ if model_choice == "Gemini Flash 2.0":
 
 
 
 
 
 
 
 
117
  response = query_gemini(prompt, chatbot_state)
118
  elif model_choice == "Deepseek":
119
  response = query_deepseek(prompt, chatbot_state)
 
177
  outputs=[chatbot, chatbot_input, chatbot_state] # Clear the chatbot UI and the state
178
  )
179
 
180
+ demo.launch(auth=("latham", "1956"))
181
+