This commit is contained in:
2025-04-11 11:41:32 -05:00
parent 326edbd84a
commit 14f60bde07

View File

@@ -49,7 +49,9 @@ void Ollama::onLoad() {
void Ollama::run() { void Ollama::run() {
static std::string s, url, response = ""; ImGuiIO& io = ImGui::GetIO();
static std::string s, url = "https://ollama.blunkall.us", response = "";
static nlohmann::json sendObj; static nlohmann::json sendObj;
@@ -77,16 +79,18 @@ void Ollama::run() {
} }
ImGui::Text("%s", jsonObj["response"].dump().c_str()); ImGui::Text("%s", jsonObj["response"].dump().c_str());
ImGui::Text("ms per frame: %f", 1000 / io.Framerate);
ImGui::End(); ImGui::End();
if(curl) { if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, (url + "/api/generate").c_str()); curl_easy_setopt(curl, CURLOPT_URL, (url + "/api/generate").c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &oss);
} }
if(inFlight && result.wait_for(std::chrono::seconds(0)) == std::future_status::ready) { if(inFlight && result.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
CURLcode code = result.get(); CURLcode code = result.get();
response = oss.str();
if(code != CURLE_OK) { if(code != CURLE_OK) {
std::cerr << "curl_easy_perform() failed!: " << curl_easy_strerror(code) << std::endl; std::cerr << "curl_easy_perform() failed!: " << curl_easy_strerror(code) << std::endl;
app->stopModule(getName()); app->stopModule(getName());