curl opts go with perform

This commit is contained in:
2025-04-11 11:49:29 -05:00
parent 14f60bde07
commit 8c53724037

View File

@@ -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) {