Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -273,8 +273,8 @@ def generate_chunked_response(prompt, model, max_tokens=10000, num_calls=3, temp
|
|
273 |
|
274 |
class SimpleDDGSearch:
|
275 |
def search(self, query: str, num_results: int = 10):
|
276 |
-
results = DDGS().
|
277 |
-
return [res["
|
278 |
|
279 |
class TrafilaturaWebCrawler:
|
280 |
def get_website_content_from_url(self, url: str) -> str:
|
@@ -502,16 +502,13 @@ def create_web_search_vectors(search_results):
|
|
502 |
|
503 |
def get_response_with_search(query, model, num_calls=3, temperature=0.2):
|
504 |
searcher = SimpleDDGSearch()
|
505 |
-
|
506 |
-
search_results = searcher.search(query, use_chat=use_chat, model="claude-3-haiku" if use_chat else None, num_results=10)
|
507 |
|
|
|
508 |
context = ""
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
else:
|
513 |
-
crawler = TrafilaturaWebCrawler()
|
514 |
-
context += crawler.get_website_content_from_url(result['url']) + "\n"
|
515 |
|
516 |
prompt = f"""You are an expert AI named Sentinel and have been given a task to create a detailed and complete research article using the following context from web search results:
|
517 |
{context} that fulfills the following user request: '{query}'
|
|
|
273 |
|
274 |
class SimpleDDGSearch:
|
275 |
def search(self, query: str, num_results: int = 10):
|
276 |
+
results = DDGS().text(query, region='wt-wt', safesearch='off', max_results=num_results)
|
277 |
+
return [res["href"] for res in results]
|
278 |
|
279 |
class TrafilaturaWebCrawler:
|
280 |
def get_website_content_from_url(self, url: str) -> str:
|
|
|
502 |
|
503 |
def get_response_with_search(query, model, num_calls=3, temperature=0.2):
|
504 |
searcher = SimpleDDGSearch()
|
505 |
+
search_results = searcher.search(query, num_results=10)
|
|
|
506 |
|
507 |
+
crawler = TrafilaturaWebCrawler()
|
508 |
context = ""
|
509 |
+
|
510 |
+
for url in search_results:
|
511 |
+
context += crawler.get_website_content_from_url(url) + "\n"
|
|
|
|
|
|
|
512 |
|
513 |
prompt = f"""You are an expert AI named Sentinel and have been given a task to create a detailed and complete research article using the following context from web search results:
|
514 |
{context} that fulfills the following user request: '{query}'
|