Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ class BasicAgent:
|
|
35 |
# Wikipedia setup (with proper User-Agent)
|
36 |
self.wiki = wikipediaapi.Wikipedia(
|
37 |
language='en',
|
38 |
-
user_agent='SearchAgent/1.0 (
|
39 |
)
|
40 |
|
41 |
# SearxNG meta-search (replace with your instance)
|
@@ -44,16 +44,23 @@ class BasicAgent:
|
|
44 |
|
45 |
def __call__(self, question: str) -> str:
|
46 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
47 |
-
fixed_answer = self.
|
48 |
print(f"Agent returning answer: {fixed_answer}")
|
49 |
return fixed_answer
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def search_tool(self, prompt: str) -> str:
|
53 |
model = genai.GenerativeModel('gemini-pro')
|
54 |
response = model.generate_content(
|
55 |
f"Search the web for: {prompt}. Summarize the results."
|
56 |
-
|
57 |
return response.text
|
58 |
|
59 |
def search_tool(self, prompt: str) -> str:
|
|
|
35 |
# Wikipedia setup (with proper User-Agent)
|
36 |
self.wiki = wikipediaapi.Wikipedia(
|
37 |
language='en',
|
38 |
+
user_agent='SearchAgent/1.0 (example@gmail.com)' # CHANGE THIS!
|
39 |
)
|
40 |
|
41 |
# SearxNG meta-search (replace with your instance)
|
|
|
44 |
|
45 |
def __call__(self, question: str) -> str:
|
46 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
47 |
+
fixed_answer = self.basic_search(question)
|
48 |
print(f"Agent returning answer: {fixed_answer}")
|
49 |
return fixed_answer
|
50 |
|
51 |
+
|
52 |
+
|
53 |
+
def basic_search(query):
|
54 |
+
url = f"https://www.google.com/search?q={query}"
|
55 |
+
response = requests.get(url)
|
56 |
+
return response.text
|
57 |
+
|
58 |
+
|
59 |
def search_tool(self, prompt: str) -> str:
|
60 |
model = genai.GenerativeModel('gemini-pro')
|
61 |
response = model.generate_content(
|
62 |
f"Search the web for: {prompt}. Summarize the results."
|
63 |
+
)
|
64 |
return response.text
|
65 |
|
66 |
def search_tool(self, prompt: str) -> str:
|