Spaces:
Sleeping
Sleeping
preparatory changes
Browse files- .gitignore +1 -0
- agents.py +21 -0
- app.py +22 -11
- requirements.txt +4 -1
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
**/__pycache__/
|
agents.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
# --- Basic Agent Definition ---
|
| 4 |
+
class BasicAgent:
|
| 5 |
+
def __init__(self):
|
| 6 |
+
print("BasicAgent initialized.")
|
| 7 |
+
def __call__(self, question: str) -> str:
|
| 8 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 9 |
+
fixed_answer = "This is a default answer."
|
| 10 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 11 |
+
return fixed_answer
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class LangAgent:
|
| 15 |
+
def __init__(self):
|
| 16 |
+
print("BasicAgent initialized.")
|
| 17 |
+
def __call__(self, question: str) -> str:
|
| 18 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 19 |
+
fixed_answer = "This is a default answer."
|
| 20 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 21 |
+
return fixed_answer
|
app.py
CHANGED
|
@@ -3,21 +3,12 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
|
| 11 |
-
# --- Basic Agent Definition ---
|
| 12 |
-
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
-
class BasicAgent:
|
| 14 |
-
def __init__(self):
|
| 15 |
-
print("BasicAgent initialized.")
|
| 16 |
-
def __call__(self, question: str) -> str:
|
| 17 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
-
fixed_answer = "This is a default answer."
|
| 19 |
-
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 20 |
-
return fixed_answer
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
@@ -58,6 +49,26 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 58 |
print("Fetched questions list is empty.")
|
| 59 |
return "Fetched questions list is empty or invalid format.", None
|
| 60 |
print(f"Fetched {len(questions_data)} questions.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
except requests.exceptions.RequestException as e:
|
| 62 |
print(f"Error fetching questions: {e}")
|
| 63 |
return f"Error fetching questions: {e}", None
|
|
@@ -193,4 +204,4 @@ if __name__ == "__main__":
|
|
| 193 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 194 |
|
| 195 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 196 |
-
demo.launch(debug=True, share=False)
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from agents import BasicAgent
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 14 |
"""
|
|
|
|
| 49 |
print("Fetched questions list is empty.")
|
| 50 |
return "Fetched questions list is empty or invalid format.", None
|
| 51 |
print(f"Fetched {len(questions_data)} questions.")
|
| 52 |
+
# Log a quick overview so we can debug availability, especially file_name fields.
|
| 53 |
+
with_file = [q for q in questions_data if q.get("file_name")]
|
| 54 |
+
without_file = len(questions_data) - len(with_file)
|
| 55 |
+
print(f"Questions with file_name set: {len(with_file)}; without: {without_file}")
|
| 56 |
+
for q in with_file:
|
| 57 |
+
print(f"Task {q.get('task_id')} expects file: {q.get('file_name')}")
|
| 58 |
+
# Probe file availability so we can see what the backend returns.
|
| 59 |
+
for q in with_file:
|
| 60 |
+
task_id = q.get("task_id")
|
| 61 |
+
file_url = f"{api_url}/files/{task_id}"
|
| 62 |
+
try:
|
| 63 |
+
probe = requests.get(file_url, timeout=15)
|
| 64 |
+
print(
|
| 65 |
+
f"Attempted access to resource at {file_url} -> "
|
| 66 |
+
f"status {probe.status_code}, "
|
| 67 |
+
f"content-type {probe.headers.get('content-type')}, "
|
| 68 |
+
f"bytes {len(probe.content)}"
|
| 69 |
+
)
|
| 70 |
+
except Exception as e:
|
| 71 |
+
print(f"Attempted access to resource at {file_url} -> error: {e}")
|
| 72 |
except requests.exceptions.RequestException as e:
|
| 73 |
print(f"Error fetching questions: {e}")
|
| 74 |
return f"Error fetching questions: {e}", None
|
|
|
|
| 204 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 205 |
|
| 206 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 207 |
+
demo.launch(debug=True, share=False)
|
requirements.txt
CHANGED
|
@@ -1,2 +1,5 @@
|
|
| 1 |
gradio
|
| 2 |
-
requests
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
+
requests
|
| 3 |
+
|
| 4 |
+
langgraph
|
| 5 |
+
langchain_openai
|