Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,12 +48,12 @@ def get_file_path(question: str) -> str:
|
|
| 48 |
|
| 49 |
def get_ref_content(path: str) -> str | object:
|
| 50 |
"""Retrieves content from the reference path provided."""
|
| 51 |
-
if path.
|
| 52 |
-
file = requests.get(path).content
|
| 53 |
-
elif path.endswith('mp3'):
|
| 54 |
file = librosa.load(path)
|
| 55 |
-
elif path.endswith('xlsx') or path.endswith('xls'):
|
| 56 |
file = pd.read_excel(path).to_json()
|
|
|
|
|
|
|
| 57 |
else:
|
| 58 |
with open(path, "rb") as f:
|
| 59 |
file = f.read()
|
|
@@ -63,7 +63,7 @@ def search_web(topic: str) -> str:
|
|
| 63 |
"""Retrieves information about the topic."""
|
| 64 |
results = DuckDuckGoSearchRun().invoke(topic)
|
| 65 |
if results:
|
| 66 |
-
return "\n\n".join([doc.text for doc in results[:
|
| 67 |
else:
|
| 68 |
return "No matching content found."
|
| 69 |
|
|
|
|
| 48 |
|
| 49 |
def get_ref_content(path: str) -> str | object:
|
| 50 |
"""Retrieves content from the reference path provided."""
|
| 51 |
+
if path.endswith('mp3'):
|
|
|
|
|
|
|
| 52 |
file = librosa.load(path)
|
| 53 |
+
elif path.endswith('.xlsx') or path.endswith('.xls'):
|
| 54 |
file = pd.read_excel(path).to_json()
|
| 55 |
+
elif path.startswith('http'):
|
| 56 |
+
file = requests.get(path).text
|
| 57 |
else:
|
| 58 |
with open(path, "rb") as f:
|
| 59 |
file = f.read()
|
|
|
|
| 63 |
"""Retrieves information about the topic."""
|
| 64 |
results = DuckDuckGoSearchRun().invoke(topic)
|
| 65 |
if results:
|
| 66 |
+
return "\n\n".join([doc.text for doc in results[:5]])
|
| 67 |
else:
|
| 68 |
return "No matching content found."
|
| 69 |
|