Update app.py
Browse files
app.py
CHANGED
|
@@ -12,41 +12,47 @@ GEMINI_MODEL = "gemini-2.5-flash-lite" # Fast, cost-effective model
|
|
| 12 |
# --- Gemini Agent Definition ---
|
| 13 |
class GeminiAgent:
|
| 14 |
def __init__(self):
|
| 15 |
-
api_key = os.getenv("GEMINI_API_KEY")
|
| 16 |
if not api_key:
|
| 17 |
-
raise ValueError("GEMINI_API_KEY
|
| 18 |
-
|
| 19 |
-
self.
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def __call__(self, question: str) -> str:
|
| 23 |
-
print(f"GeminiAgent received question
|
| 24 |
-
|
| 25 |
prompt = f"""
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
Your answer should be a number, a short string, or a comma-separated list.
|
| 29 |
-
Do not use phrases like "I don't know", "NA", "not applicable", or leave the answer empty.
|
| 30 |
-
Avoid giving a step-by-step explanation in your final answer.
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
Final Answer:
|
| 35 |
-
"""
|
| 36 |
try:
|
| 37 |
time.sleep(6)
|
| 38 |
|
| 39 |
-
response = self.
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
# simple clean (NO second call)
|
| 43 |
if not answer:
|
| 44 |
-
answer = "0"
|
| 45 |
|
| 46 |
return answer
|
|
|
|
| 47 |
except Exception as e:
|
| 48 |
-
print(
|
| 49 |
-
# Last resort: return a non-empty, generic answer (should rarely happen)
|
| 50 |
return f"Error occurred: {e}"
|
| 51 |
|
| 52 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
|
|
| 12 |
# --- Gemini Agent Definition ---
|
| 13 |
class GeminiAgent:
|
| 14 |
def __init__(self):
|
| 15 |
+
api_key = os.getenv("GEMINI_API_KEY") # keep same secret
|
| 16 |
if not api_key:
|
| 17 |
+
raise ValueError("GEMINI_API_KEY not set")
|
| 18 |
+
|
| 19 |
+
self.client = Groq(api_key=api_key)
|
| 20 |
+
self.model = "llama3-70b-8192"
|
| 21 |
+
|
| 22 |
+
print("Groq Agent initialized")
|
| 23 |
|
| 24 |
def __call__(self, question: str) -> str:
|
| 25 |
+
print(f"GeminiAgent received question: {question[:50]}...")
|
| 26 |
+
|
| 27 |
prompt = f"""
|
| 28 |
+
You are an expert assistant for the GAIA benchmark.
|
| 29 |
+
Provide a short, factual answer.
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
Question: {question}
|
| 32 |
+
|
| 33 |
+
Final Answer:
|
| 34 |
+
"""
|
| 35 |
|
|
|
|
|
|
|
| 36 |
try:
|
| 37 |
time.sleep(6)
|
| 38 |
|
| 39 |
+
response = self.client.chat.completions.create(
|
| 40 |
+
model=self.model,
|
| 41 |
+
messages=[
|
| 42 |
+
{"role": "user", "content": prompt}
|
| 43 |
+
],
|
| 44 |
+
temperature=0
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
answer = response.choices[0].message.content.strip()
|
| 48 |
|
|
|
|
| 49 |
if not answer:
|
| 50 |
+
answer = "0"
|
| 51 |
|
| 52 |
return answer
|
| 53 |
+
|
| 54 |
except Exception as e:
|
| 55 |
+
print("Groq API error:", e)
|
|
|
|
| 56 |
return f"Error occurred: {e}"
|
| 57 |
|
| 58 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|