dmsc 9 месяцев назад
Родитель
Сommit
433840d9da
1 измененных файлов с 18 добавлено и 9 удалено
  1. 18 9
      main.py

+ 18 - 9
main.py

@@ -67,7 +67,10 @@ def summarize_individual_texts(texts_and_urls, query, model, ollama_url="http://
             "model": model,
             "prompt": prompt,
             "stream": False,
-            "max_tokens": 1000
+            "max_tokens": 1000,
+	    "options": {
+		"num_ctx": 16384
+	    }	
         }
         
         try:
@@ -87,7 +90,7 @@ def summarize_with_ollama(texts_and_urls, query, model, ollama_url="http://local
     # 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 @@ def summarize_with_ollama(texts_and_urls, query, model, ollama_url="http://local
         "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 @@ def summarize_with_ollama(texts_and_urls, query, model, ollama_url="http://local
         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 @@ if __name__ == "__main__":
     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 __name__ == "__main__":
     
     if final_summary:
         print("\nFinal Summary of search results:\n")
-        pretty_print_markdown(final_summary)
+        pretty_print_markdown(final_summary)