shukdevdatta123 commited on
Commit
5029883
·
verified ·
1 Parent(s): 24242aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
2
  import os
3
  import re
4
  from groq import Groq
5
- from groq.errors import AuthenticationError, APIError
6
 
7
  def validate_api_key(api_key):
8
  """Validate if the API key has the correct format."""
@@ -26,12 +25,12 @@ def test_api_connection(api_key):
26
  max_tokens=5
27
  )
28
  return True, "API connection successful"
29
- except AuthenticationError:
30
- return False, "Authentication failed: Invalid API key"
31
- except APIError as e:
32
- return False, f"API Error: {str(e)}"
33
  except Exception as e:
34
- return False, f"Error connecting to Groq API: {str(e)}"
 
 
 
 
35
 
36
  def chat_with_groq(api_key, model, user_message, temperature, max_tokens, top_p, chat_history):
37
  """
@@ -85,9 +84,7 @@ def clear_conversation():
85
  models = [
86
  "deepseek-r1-distill-llama-70b",
87
  "llama3-70b-8192",
88
- "llama3-8b-8192",
89
- "mixtral-8x7b-32768",
90
- "gemma-7b-it"
91
  ]
92
 
93
  # Create the Gradio interface
 
2
  import os
3
  import re
4
  from groq import Groq
 
5
 
6
  def validate_api_key(api_key):
7
  """Validate if the API key has the correct format."""
 
25
  max_tokens=5
26
  )
27
  return True, "API connection successful"
 
 
 
 
28
  except Exception as e:
29
+ # Handle all exceptions since Groq might not expose specific error types
30
+ if "authentication" in str(e).lower() or "api key" in str(e).lower():
31
+ return False, "Authentication failed: Invalid API key"
32
+ else:
33
+ return False, f"Error connecting to Groq API: {str(e)}"
34
 
35
  def chat_with_groq(api_key, model, user_message, temperature, max_tokens, top_p, chat_history):
36
  """
 
84
  models = [
85
  "deepseek-r1-distill-llama-70b",
86
  "llama3-70b-8192",
87
+ "llama3-8b-8192"
 
 
88
  ]
89
 
90
  # Create the Gradio interface