Spaces:
Starting
Starting
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,9 @@ import requests
|
|
8 |
from typing import List, Dict, Union
|
9 |
import pandas as pd
|
10 |
import wikipediaapi
|
11 |
-
from
|
|
|
|
|
12 |
|
13 |
load_dotenv()
|
14 |
|
@@ -34,10 +36,33 @@ class BasicAgent:
|
|
34 |
|
35 |
def __call__(self, question: str) -> str:
|
36 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
37 |
-
fixed_answer = self.
|
38 |
print(f"Agent returning answer: {fixed_answer}")
|
39 |
return fixed_answer
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def answer_question(self, prompt: str) -> str:
|
42 |
from google.genarativeai import genai
|
43 |
|
|
|
8 |
from typing import List, Dict, Union
|
9 |
import pandas as pd
|
10 |
import wikipediaapi
|
11 |
+
from typing import Optional
|
12 |
+
from termax.agent import Agent # Assuming you're using a specific agent framework
|
13 |
+
from termax.tool import google_search # Assuming this is your search tool import
|
14 |
|
15 |
load_dotenv()
|
16 |
|
|
|
36 |
|
37 |
def __call__(self, question: str) -> str:
|
38 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
39 |
+
fixed_answer = self.search_tool(question)
|
40 |
print(f"Agent returning answer: {fixed_answer}")
|
41 |
return fixed_answer
|
42 |
|
43 |
+
|
44 |
+
def search_tool(self, prompt: str) -> str:
|
45 |
+
"""
|
46 |
+
Searches for information using a Gemini-powered agent with Google Search capability.
|
47 |
+
|
48 |
+
Args:
|
49 |
+
prompt: The user's query to search for
|
50 |
+
|
51 |
+
Returns:
|
52 |
+
str: The response from the search agent
|
53 |
+
"""
|
54 |
+
root_agent = Agent(
|
55 |
+
name="search_assistant",
|
56 |
+
model="gemini-2.0-flash", # Or your preferred Gemini model
|
57 |
+
instruction="You are a helpful assistant. Answer user questions using Google Search when needed.",
|
58 |
+
description="An assistant that can search the web.",
|
59 |
+
tools=[google_search]
|
60 |
+
)
|
61 |
+
|
62 |
+
# Actually invoke the agent with the prompt
|
63 |
+
response = root_agent.run(prompt)
|
64 |
+
return response
|
65 |
+
|
66 |
def answer_question(self, prompt: str) -> str:
|
67 |
from google.genarativeai import genai
|
68 |
|