bestroi commited on
Commit
ffe03e5
·
verified ·
1 Parent(s): 8c6f94a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -595,17 +595,19 @@ with gr.Blocks(title="Archaeological Query Engine") as app:
595
  elem_classes=["results-output"]
596
  )
597
 
598
- # Function to handle the Generate Answer button click
599
- def on_generate_answer(city, question, max_sources, api_key, temperature):
600
  if not question or question.strip() == "":
601
  return "Please enter a question to generate an answer."
602
 
603
- # Use the provided Groq API key directly
604
- # Replace this with your actual Groq API key
605
- groq_api_key = Groq(api_key=os.environ.get("GROQ_API"))
 
 
606
 
607
  try:
608
- return generate_answer_with_groq(city, question, max_sources, groq_api_key, temperature)
 
609
  except Exception as e:
610
  return f"Error: {str(e)}"
611
 
 
595
  elem_classes=["results-output"]
596
  )
597
 
598
+ def on_generate_answer(city, question, max_sources, api_key, temperature):
 
599
  if not question or question.strip() == "":
600
  return "Please enter a question to generate an answer."
601
 
602
+ # Get the Groq API key from environment variable
603
+ groq_api_key = os.environ.get("GROQ_API")
604
+
605
+ if not groq_api_key:
606
+ return "Error: GROQ_API environment variable not set. Please set your Groq API key in the environment."
607
 
608
  try:
609
+ # Use the API key string (not a Groq client object)
610
+ return generate_answer_with_groq(city, question, max_sources, groq_api_key, temperature)
611
  except Exception as e:
612
  return f"Error: {str(e)}"
613