From 8c53724037f9fbe6e0e2d6f5731db1e458e73faf Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 11 Apr 2025 11:49:29 -0500 Subject: [PATCH] curl opts go with perform --- modules/Ollama/src/Ollama.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/Ollama/src/Ollama.cpp b/modules/Ollama/src/Ollama.cpp index fdf5ee8..86b49c4 100644 --- a/modules/Ollama/src/Ollama.cpp +++ b/modules/Ollama/src/Ollama.cpp @@ -39,12 +39,6 @@ void Ollama::onLoad() { curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); - //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); - //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); - curl_easy_setopt(curl, CURLOPT_POST, 1L); - } } void Ollama::run() { @@ -73,6 +67,12 @@ void Ollama::run() { sendObj["model"] = "llama3.2"; sendObj["stream"] = false; sendObj["prompt"] = s; + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); + curl_easy_setopt(curl, CURLOPT_URL, (url + "/api/generate").c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &oss); + //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); + //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); + curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, sendObj.dump().c_str()); result = std::async(curl_easy_perform, curl); inFlight = true; @@ -84,8 +84,6 @@ void Ollama::run() { ImGui::End(); if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, (url + "/api/generate").c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &oss); } if(inFlight && result.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {