Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,12 +7,20 @@ import pandas as pd
|
|
7 |
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
8 |
from huggingface_hub import InferenceClient
|
9 |
import json
|
10 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
11 |
|
12 |
api_url = "https://agents-course-unit4-scoring.hf.space"
|
13 |
questions_url = f"{api_url}/questions"
|
14 |
submit_url = f"{api_url}/submit"
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def load_questions_from_file(filepath="questions.json"):
|
18 |
try:
|
@@ -38,14 +46,16 @@ def load_questions_from_file(filepath="questions.json"):
|
|
38 |
|
39 |
#Model
|
40 |
|
|
|
41 |
#Agent
|
42 |
|
|
|
43 |
#
|
44 |
|
45 |
def run_and_submit_one():
|
46 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
47 |
try:
|
48 |
-
agent =
|
49 |
|
50 |
except Exception as e:
|
51 |
print(f"Error instantiating agent: {e}")
|
|
|
7 |
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
8 |
from huggingface_hub import InferenceClient
|
9 |
import json
|
|
|
10 |
|
11 |
api_url = "https://agents-course-unit4-scoring.hf.space"
|
12 |
questions_url = f"{api_url}/questions"
|
13 |
submit_url = f"{api_url}/submit"
|
14 |
|
15 |
+
class BasicAgent:
|
16 |
+
def __init__(self):
|
17 |
+
print("BasicAgent initialized.")
|
18 |
+
def __call__(self, question: str) -> str:
|
19 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
20 |
+
|
21 |
+
fixed_answer = "This is a default answer."
|
22 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
23 |
+
return fixed_answer
|
24 |
|
25 |
def load_questions_from_file(filepath="questions.json"):
|
26 |
try:
|
|
|
46 |
|
47 |
#Model
|
48 |
|
49 |
+
|
50 |
#Agent
|
51 |
|
52 |
+
|
53 |
#
|
54 |
|
55 |
def run_and_submit_one():
|
56 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
57 |
try:
|
58 |
+
agent = BasicAgent()
|
59 |
|
60 |
except Exception as e:
|
61 |
print(f"Error instantiating agent: {e}")
|