Spaces:
Sleeping
Sleeping
Update helper_functions_api.py
Browse files- helper_functions_api.py +5 -3
helper_functions_api.py
CHANGED
@@ -183,7 +183,7 @@ def rephrase_content(data_format, content, query):
|
|
183 |
max_tokens=500,
|
184 |
)
|
185 |
|
186 |
-
|
187 |
def fetch_content(url):
|
188 |
try:
|
189 |
response = hrequests.get(url)
|
@@ -208,7 +208,8 @@ def extract_main_content(html):
|
|
208 |
return trafilatura.utils.sanitize(extracted)
|
209 |
else:
|
210 |
return ""
|
211 |
-
|
|
|
212 |
def process_content(data_format, url, query):
|
213 |
html_content = fetch_content(url)
|
214 |
if html_content:
|
@@ -231,7 +232,8 @@ def fetch_and_extract_content(data_format, urls, query):
|
|
231 |
all_text_with_urls = [future.result() for future in as_completed(future_to_url)]
|
232 |
|
233 |
return all_text_with_urls
|
234 |
-
|
|
|
235 |
def search_brave(query, num_results=5):
|
236 |
"""Fetch search results from Brave's API."""
|
237 |
|
|
|
183 |
max_tokens=500,
|
184 |
)
|
185 |
|
186 |
+
@cache(expire=604800)
|
187 |
def fetch_content(url):
|
188 |
try:
|
189 |
response = hrequests.get(url)
|
|
|
208 |
return trafilatura.utils.sanitize(extracted)
|
209 |
else:
|
210 |
return ""
|
211 |
+
|
212 |
+
@cache(expire=604800)
|
213 |
def process_content(data_format, url, query):
|
214 |
html_content = fetch_content(url)
|
215 |
if html_content:
|
|
|
232 |
all_text_with_urls = [future.result() for future in as_completed(future_to_url)]
|
233 |
|
234 |
return all_text_with_urls
|
235 |
+
|
236 |
+
@cache(expire=604800)
|
237 |
def search_brave(query, num_results=5):
|
238 |
"""Fetch search results from Brave's API."""
|
239 |
|