text wrapping
This commit is contained in:
@@ -61,6 +61,22 @@ void Ollama::run() {
|
|||||||
|
|
||||||
ImGui::InputText("url: ", &url);
|
ImGui::InputText("url: ", &url);
|
||||||
|
|
||||||
|
static const std::string replace = "\\n";
|
||||||
|
static const std::string replace_by = "\n";
|
||||||
|
static std::string print = jsonObj["response"].dump(); print = jsonObj["response"].dump();
|
||||||
|
static auto pos = print.find(replace); pos = print.find(replace);
|
||||||
|
|
||||||
|
while (pos != std::string::npos) {
|
||||||
|
// Replace the substring with the specified string
|
||||||
|
print.replace(pos, replace.size(), replace_by);
|
||||||
|
|
||||||
|
// Find the next occurrence of the substring
|
||||||
|
pos = print.find(replace,
|
||||||
|
pos + replace_by.size());
|
||||||
|
}
|
||||||
|
print = "\n\n\n" + print + "\n\n\n";
|
||||||
|
ImGui::TextWrapped("%s", print.c_str());
|
||||||
|
|
||||||
ImGui::InputTextMultiline("prompt: ", &s);
|
ImGui::InputTextMultiline("prompt: ", &s);
|
||||||
|
|
||||||
if(ImGui::Button("send")) {
|
if(ImGui::Button("send")) {
|
||||||
@@ -78,7 +94,6 @@ void Ollama::run() {
|
|||||||
inFlight = true;
|
inFlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("%s", jsonObj["response"].dump().c_str());
|
|
||||||
ImGui::Text("ms per frame: %f", 1000 / io.Framerate);
|
ImGui::Text("ms per frame: %f", 1000 / io.Framerate);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@@ -90,6 +105,8 @@ void Ollama::run() {
|
|||||||
CURLcode code = result.get();
|
CURLcode code = result.get();
|
||||||
response = oss.str();
|
response = oss.str();
|
||||||
oss.str("");
|
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());
|
||||||
|
|||||||
Reference in New Issue
Block a user