From 8bc8443a9eeabf8e965c67e6a06106708ef3ec6b Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 23 May 2024 15:53:59 +0200 Subject: [PATCH] upgraded internet problem --- lollms/app.py | 12 ++++++++---- lollms/internet.py | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lollms/app.py b/lollms/app.py index fe2bd8c..8e50a9b 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -848,12 +848,16 @@ class LollmsApplication(LoLLMsCom): else: self.personality.step_start("Performing Internet search (advanced mode: slower but more advanced)") - internet_search_results=f"!@>instructions: Use the internet search results data to answer {self.config.user_name}. Try to extract information from the websearch and use it to perform the requested task or answer the question. Try to stick to the websearch results and clarify if your answer was based on the resuts or on your own culture. If you don't know how to perform the task, then tell the user politely that you need more data inputs.\n!@>Web search results:\n" + internet_search_results=f"!@>instructions: Use the web search results data to answer {self.config.user_name}. Try to extract information from the web search and use it to perform the requested task or answer the question. Do not come up with information that is not in the websearch results. Try to stick to the websearch results and clarify if your answer was based on the resuts or on your own culture. If you don't know how to perform the task, then tell the user politely that you need more data inputs.\n!@>Web search results:\n" docs, sorted_similarities, document_ids = self.personality.internet_search_with_vectorization(query, self.config.internet_quick_search) - for doc, infos,document_id in zip(docs, sorted_similarities, document_ids): - internet_search_infos.append(document_id) - internet_search_results += f"!@>search result chunk:\nchunk_infos:{document_id['url']}\nchunk_title:{document_id['title']}\ncontent:{doc}\n" + + if len(docs)>0: + for doc, infos,document_id in zip(docs, sorted_similarities, document_ids): + internet_search_infos.append(document_id) + internet_search_results += f"!@>search result chunk:\nchunk_infos:{document_id['url']}\nchunk_title:{document_id['title']}\ncontent:{doc}\n" + else: + internet_search_results += "The search response was empty!\nFailed to recover useful information from the search engine.\n" if self.config.internet_quick_search: self.personality.step_end("Performing Internet search (quick mode)") else: diff --git a/lollms/internet.py b/lollms/internet.py index 4c37729..cf8fe58 100644 --- a/lollms/internet.py +++ b/lollms/internet.py @@ -336,6 +336,7 @@ def internet_search_with_vectorization(query, chromedriver_path=None, internet_n ) for i, result in enumerate(results): + ASCIIColors.orange(f"Processing result:{result['title']}") title = result["title"] brief = result["brief"] href = result["href"]