Spaces:
Configuration error
Configuration error
oremaz
commited on
Commit
·
46264e6
1
Parent(s):
9c90ad3
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -44,7 +44,14 @@ from llama_index.readers.file import (
|
|
| 44 |
VideoAudioReader # Adding VideoAudioReader for handling audio/video without API
|
| 45 |
)
|
| 46 |
from pydantic import PrivateAttr
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Optional API-based imports (conditionally loaded)
|
| 50 |
try:
|
|
@@ -493,12 +500,8 @@ def search_and_extract_content_from_url(query: str) -> List[Document]:
|
|
| 493 |
Returns a list of Document objects containing the extracted content.
|
| 494 |
"""
|
| 495 |
# Get URL from search
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
if not results:
|
| 499 |
-
return []
|
| 500 |
-
|
| 501 |
-
url = results[0]['href']
|
| 502 |
|
| 503 |
documents = []
|
| 504 |
|
|
|
|
| 44 |
VideoAudioReader # Adding VideoAudioReader for handling audio/video without API
|
| 45 |
)
|
| 46 |
from pydantic import PrivateAttr
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
import requests
|
| 50 |
+
def search_ddg(query):
|
| 51 |
+
url = "https://api.duckduckgo.com/"
|
| 52 |
+
params = {"q": query, "format": "json"}
|
| 53 |
+
response = requests.get(url, params=params)
|
| 54 |
+
return response.json()
|
| 55 |
|
| 56 |
# Optional API-based imports (conditionally loaded)
|
| 57 |
try:
|
|
|
|
| 500 |
Returns a list of Document objects containing the extracted content.
|
| 501 |
"""
|
| 502 |
# Get URL from search
|
| 503 |
+
results = search_ddg(query)
|
| 504 |
+
url = results["AbstractURL"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
|
| 506 |
documents = []
|
| 507 |
|