Spaces:
Running
Running
UPdate app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import requests
|
|
8 |
from typing import List, Dict, Union
|
9 |
import pandas as pd
|
10 |
import wikipediaapi
|
11 |
-
from
|
12 |
|
13 |
load_dotenv()
|
14 |
|
@@ -19,26 +19,23 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
19 |
|
20 |
# --- Basic Agent Definition ---
|
21 |
|
|
|
|
|
22 |
class BasicAgent:
|
23 |
def __init__(self):
|
24 |
print("BasicAgent initialized.")
|
25 |
|
26 |
def __call__(self, question: str) -> str:
|
27 |
-
print(f"Agent received question
|
28 |
-
|
29 |
-
print(f"
|
30 |
-
return
|
31 |
-
|
32 |
|
33 |
-
|
34 |
def basic_search(self, query):
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
return f"Search error: {str(e)}"
|
40 |
-
|
41 |
-
|
42 |
|
43 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
44 |
"""
|
|
|
8 |
from typing import List, Dict, Union
|
9 |
import pandas as pd
|
10 |
import wikipediaapi
|
11 |
+
from googlesearch import search
|
12 |
|
13 |
load_dotenv()
|
14 |
|
|
|
19 |
|
20 |
# --- Basic Agent Definition ---
|
21 |
|
22 |
+
|
23 |
+
|
24 |
class BasicAgent:
|
25 |
def __init__(self):
|
26 |
print("BasicAgent initialized.")
|
27 |
|
28 |
def __call__(self, question: str) -> str:
|
29 |
+
print(f"Agent received question: {question[:50]}...")
|
30 |
+
answer = self.basic_search(question)
|
31 |
+
print(f"Answer: {answer}")
|
32 |
+
return answer
|
|
|
33 |
|
|
|
34 |
def basic_search(self, query):
|
35 |
+
from duckduckgo_search import ddg
|
36 |
+
results = ddg(query, max_results=3)
|
37 |
+
|
38 |
+
|
|
|
|
|
|
|
39 |
|
40 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
41 |
"""
|