|
|
@@ -98,7 +98,7 @@ def process_url(args):
|
|
|
max_tokens=1000
|
|
|
).choices.pop().message.content
|
|
|
return (url, remove_tags(response))
|
|
|
- except requests.RequestException as e:
|
|
|
+ except Exception as e:
|
|
|
print(
|
|
|
f"An error occurred at summarization for {url}: {e}"
|
|
|
)
|
|
|
@@ -143,7 +143,7 @@ def summarize(texts_and_urls, query, model, api_base, token):
|
|
|
max_tokens=2000
|
|
|
).choices.pop().message.content
|
|
|
return remove_tags(response)
|
|
|
- except requests.RequestException as e:
|
|
|
+ except Exception as e:
|
|
|
print(
|
|
|
f"An error occurred at summarization for {url}: {e}"
|
|
|
)
|
|
|
@@ -152,7 +152,7 @@ def summarize(texts_and_urls, query, model, api_base, token):
|
|
|
def optimize_search_query(query, query_model, api_base):
|
|
|
# Prepare the prompt for optimizing the search query
|
|
|
prompt = f"Optimize the following natural language query to improve its effectiveness in a web search.\
|
|
|
- Make it very concise. Return only the optimized query text no additional texts, quotations or thoughts. Query: '{query}'"
|
|
|
+ Make it very concise. Return only exactly the optimized query text no additional texts, quotations or thoughts. Query: '{query}'"
|
|
|
|
|
|
# Create the payload for the POST request
|
|
|
payload = {
|
|
|
@@ -173,7 +173,7 @@ def optimize_search_query(query, query_model, api_base):
|
|
|
print(
|
|
|
f"Failed to optimize search query from the server. Status code: {response.status_code}")
|
|
|
return query
|
|
|
- except requests.RequestException as e:
|
|
|
+ except Exception as e:
|
|
|
print(
|
|
|
f"An error occurred while sending request to the server for optimizing the search query: {e}")
|
|
|
return query
|
|
|
@@ -188,6 +188,8 @@ def pretty_print_markdown(markdown_text):
|
|
|
if __name__ == "__main__":
|
|
|
load_dotenv()
|
|
|
token = os.getenv("OVH_AI_ENDPOINTS_ACCESS_TOKEN")
|
|
|
+ api_base = os.getenv("API_BASE")
|
|
|
+ summary_model = os.getenv("SUMMARY_MODEL")
|
|
|
|
|
|
# Set up argument parser
|
|
|
parser = argparse.ArgumentParser(
|
|
|
@@ -200,10 +202,9 @@ if __name__ == "__main__":
|
|
|
# Parse arguments
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
- api_base = "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/"
|
|
|
+
|
|
|
original_query = args.query
|
|
|
- summary_model = "Qwen3-32B"
|
|
|
-
|
|
|
+
|
|
|
print(f"Query: {original_query}")
|
|
|
|
|
|
n = args.num_results # Number of results to extract
|
|
|
@@ -232,5 +233,4 @@ if __name__ == "__main__":
|
|
|
token)
|
|
|
|
|
|
if final_summary:
|
|
|
- print("\n################################# Final Summary of search results ################################# \n")
|
|
|
pretty_print_markdown(final_summary)
|