Commit
·
cfaacf9
1
Parent(s):
9d812dd
fix: try again
Browse files
app.py
CHANGED
@@ -33,11 +33,11 @@ class BasicAgent:
|
|
33 |
# self.llm = Ollama(model="qwen2.5:7b", request_timeout=500)
|
34 |
self.llm = Gemini(model_name="models/gemini-2.0-flash")
|
35 |
|
36 |
-
def
|
37 |
try:
|
38 |
loader = YoutubeTranscriptReader()
|
39 |
documents = loader.load_data(
|
40 |
-
ytlinks=[
|
41 |
)
|
42 |
|
43 |
text = documents[0].text_resource.text
|
@@ -46,21 +46,19 @@ class BasicAgent:
|
|
46 |
except Exception as e:
|
47 |
print("error", e)
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
name="
|
52 |
-
description="
|
53 |
)
|
54 |
|
55 |
-
def web_page_reader(url: str
|
56 |
try:
|
57 |
documents = SimpleWebPageReader(html_to_text=True).load_data(
|
58 |
[url]
|
59 |
)
|
60 |
-
|
61 |
-
|
62 |
-
response = query_engine.query(query)
|
63 |
-
return response.response
|
64 |
except Exception as e:
|
65 |
print("error in webpage", e)
|
66 |
|
@@ -105,7 +103,7 @@ class BasicAgent:
|
|
105 |
description="Searches wikipedia and converts results into a high quality answer."
|
106 |
)
|
107 |
|
108 |
-
self.agent = AgentWorkflow.from_tools_or_functions([duckduckgo_search_tool,
|
109 |
print("BasicAgent initialized.")
|
110 |
|
111 |
async def run_agent(self, question: str):
|
|
|
33 |
# self.llm = Ollama(model="qwen2.5:7b", request_timeout=500)
|
34 |
self.llm = Gemini(model_name="models/gemini-2.0-flash")
|
35 |
|
36 |
+
def load_video_transcript(video_link: str) -> str:
|
37 |
try:
|
38 |
loader = YoutubeTranscriptReader()
|
39 |
documents = loader.load_data(
|
40 |
+
ytlinks=[video_link]
|
41 |
)
|
42 |
|
43 |
text = documents[0].text_resource.text
|
|
|
46 |
except Exception as e:
|
47 |
print("error", e)
|
48 |
|
49 |
+
load_video_transcript_tool = FunctionTool.from_defaults(
|
50 |
+
load_video_transcript,
|
51 |
+
name="load_video_transcript",
|
52 |
+
description="Loads transcript of the given video using the link.",
|
53 |
)
|
54 |
|
55 |
+
def web_page_reader(url: str) -> str:
|
56 |
try:
|
57 |
documents = SimpleWebPageReader(html_to_text=True).load_data(
|
58 |
[url]
|
59 |
)
|
60 |
+
|
61 |
+
return { "web_page_read_reasult": "\n".join([doc.text for doc in documents]) }
|
|
|
|
|
62 |
except Exception as e:
|
63 |
print("error in webpage", e)
|
64 |
|
|
|
103 |
description="Searches wikipedia and converts results into a high quality answer."
|
104 |
)
|
105 |
|
106 |
+
self.agent = AgentWorkflow.from_tools_or_functions([duckduckgo_search_tool, load_video_transcript_tool, wikipedia_search_tool, web_page_reader_tool], llm=self.llm, system_prompt="You're an ai agent designed for question answering. Keep your answers concise or even one word when possible. You have access to a bunch of tools, utilise them well to reach answers.")
|
107 |
print("BasicAgent initialized.")
|
108 |
|
109 |
async def run_agent(self, question: str):
|