Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,12 +29,12 @@ def get_current_date_time() -> str:
|
|
| 29 |
class BasicAgent:
|
| 30 |
def __init__(self):
|
| 31 |
print("BasicAgent initialized.")
|
| 32 |
-
|
| 33 |
-
if not
|
| 34 |
-
raise ValueError("
|
| 35 |
self.model = LiteLLMModel(
|
| 36 |
-
model_id="
|
| 37 |
-
api_key=
|
| 38 |
)
|
| 39 |
self.tools = [
|
| 40 |
DuckDuckGoSearchTool(),
|
|
@@ -48,7 +48,7 @@ class BasicAgent:
|
|
| 48 |
max_steps=8,
|
| 49 |
additional_authorized_imports=["datetime", "re", "json", "math", "collections"],
|
| 50 |
)
|
| 51 |
-
print("BasicAgent ready with
|
| 52 |
|
| 53 |
def __call__(self, question: str) -> str:
|
| 54 |
print(f"Agent received question: {question[:80]}...")
|
|
@@ -106,7 +106,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 106 |
except Exception as e:
|
| 107 |
print(f"Error on task {task_id}: {e}")
|
| 108 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"ERROR: {e}"})
|
| 109 |
-
time.sleep(
|
| 110 |
if not answers_payload:
|
| 111 |
return "No answers.", pd.DataFrame(results_log)
|
| 112 |
submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
|
|
@@ -135,7 +135,7 @@ with gr.Blocks() as demo:
|
|
| 135 |
gr.Markdown(
|
| 136 |
"""
|
| 137 |
**Instructions:**
|
| 138 |
-
1. Clone this space and set `
|
| 139 |
2. Log in with your Hugging Face account below.
|
| 140 |
3. Click 'Run Evaluation & Submit' to start.
|
| 141 |
"""
|
|
|
|
| 29 |
class BasicAgent:
|
| 30 |
def __init__(self):
|
| 31 |
print("BasicAgent initialized.")
|
| 32 |
+
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 33 |
+
if not gemini_api_key:
|
| 34 |
+
raise ValueError("GEMINI_API_KEY environment variable not set")
|
| 35 |
self.model = LiteLLMModel(
|
| 36 |
+
model_id="gemini/gemini-2.0-flash",
|
| 37 |
+
api_key=gemini_api_key,
|
| 38 |
)
|
| 39 |
self.tools = [
|
| 40 |
DuckDuckGoSearchTool(),
|
|
|
|
| 48 |
max_steps=8,
|
| 49 |
additional_authorized_imports=["datetime", "re", "json", "math", "collections"],
|
| 50 |
)
|
| 51 |
+
print("BasicAgent ready with Gemini 2.0 Flash (CodeAgent).")
|
| 52 |
|
| 53 |
def __call__(self, question: str) -> str:
|
| 54 |
print(f"Agent received question: {question[:80]}...")
|
|
|
|
| 106 |
except Exception as e:
|
| 107 |
print(f"Error on task {task_id}: {e}")
|
| 108 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"ERROR: {e}"})
|
| 109 |
+
time.sleep(1)
|
| 110 |
if not answers_payload:
|
| 111 |
return "No answers.", pd.DataFrame(results_log)
|
| 112 |
submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
|
|
|
|
| 135 |
gr.Markdown(
|
| 136 |
"""
|
| 137 |
**Instructions:**
|
| 138 |
+
1. Clone this space and set `GEMINI_API_KEY` in your Space secrets.
|
| 139 |
2. Log in with your Hugging Face account below.
|
| 140 |
3. Click 'Run Evaluation & Submit' to start.
|
| 141 |
"""
|