Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -430,6 +430,17 @@ def create_web_search_vectors(search_results):
|
|
430 |
|
431 |
return FAISS.from_documents(documents, embed)
|
432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
def get_response_with_search(query, model, num_calls=3, temperature=0.2):
|
434 |
search_results = duckduckgo_search(query)
|
435 |
web_search_database = create_web_search_vectors(search_results)
|
@@ -469,6 +480,7 @@ After writing the document, please provide a list of sources used in your respon
|
|
469 |
main_content += chunk
|
470 |
yield main_content, "" # Yield partial main content without sources
|
471 |
|
|
|
472 |
def get_response_from_pdf(query, model, selected_docs, num_calls=3, temperature=0.2):
|
473 |
logging.info(f"Entering get_response_from_pdf with query: {query}, model: {model}, selected_docs: {selected_docs}")
|
474 |
|
|
|
430 |
|
431 |
return FAISS.from_documents(documents, embed)
|
432 |
|
433 |
+
def create_web_search_vectors(search_results):
|
434 |
+
embed = get_embeddings()
|
435 |
+
|
436 |
+
documents = []
|
437 |
+
for result in search_results:
|
438 |
+
if 'body' in result:
|
439 |
+
content = f"{result['title']}\n{result['body']}\nSource: {result['href']}"
|
440 |
+
documents.append(Document(page_content=content, metadata={"source": result['href']}))
|
441 |
+
|
442 |
+
return FAISS.from_documents(documents, embed)
|
443 |
+
|
444 |
def get_response_with_search(query, model, num_calls=3, temperature=0.2):
|
445 |
search_results = duckduckgo_search(query)
|
446 |
web_search_database = create_web_search_vectors(search_results)
|
|
|
480 |
main_content += chunk
|
481 |
yield main_content, "" # Yield partial main content without sources
|
482 |
|
483 |
+
|
484 |
def get_response_from_pdf(query, model, selected_docs, num_calls=3, temperature=0.2):
|
485 |
logging.info(f"Entering get_response_from_pdf with query: {query}, model: {model}, selected_docs: {selected_docs}")
|
486 |
|