diff --git a/main.py b/main.py index f6198e7..21fe220 100644 --- a/main.py +++ b/main.py @@ -67,7 +67,10 @@ "model": model, "prompt": prompt, "stream": False, - "max_tokens": 1000 + "max_tokens": 1000, + "options": { + "num_ctx": 16384 + } } try: @@ -87,7 +90,7 @@ # Prepare the context and prompt context = "\n".join([f"URL: {url}\nText: {text}" for url, text in texts_and_urls]) prompt = f"Summarize the following search results with regards to the original query: '{query}' \ - and include the full URLs as references where appropriate. Use markdown to format your response and unicode characters. \ + and include the full URLs as references where appropriate. Use markdown to format your response. Add unicode characters where it makes sense to make the summary colorful. \ \n\n{context}" # Create the payload for the POST request @@ -95,7 +98,10 @@ "model": model, "prompt": prompt, "stream": False, - "max_tokens": 1500 + "max_tokens": 1500, + "options": { + "num_ctx": 16384 + } } # Send the POST request to the Ollama server @@ -113,14 +119,14 @@ return None -def optimize_search_query(query, model, ollama_url="http://localhost:11434/api/generate"): +def optimize_search_query(query, query_model, ollama_url="http://localhost:11434/api/generate"): # 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. query: '{query}'" + Make it very concise. Return just the optimized query no explanations. Query: '{query}'" # Create the payload for the POST request payload = { - "model": model, + "model": query_model, "prompt": prompt, "stream": False, "max_tokens": 50 @@ -157,10 +163,13 @@ args = parser.parse_args() original_query = args.query - model = "qc" + model = "command-r" + #model = "qwq" + #model = "qwen2.5:32b" + query_model = model # Optimize the search query - optimized_query = optimize_search_query(original_query, model) + optimized_query = optimize_search_query(original_query, query_model) print(f"Original Query: {original_query}") print(f"Optimized Query: {optimized_query}") @@ -179,4 +188,4 @@ if final_summary: print("\nFinal Summary of search results:\n") - pretty_print_markdown(final_summary) \ No newline at end of file + pretty_print_markdown(final_summary)