I am making a C++ wxWidgets application, my desktop program is an interface for an LLM…
- User
I am making a C++ wxWidgets application, my desktop program is an interface for an LLM chat external command-line application, called Ollama.
Ollama is a lightweight, extensible framework for building and running language models on the local machine. It provides a simple API for creating, running, and managing models, as well as a library of pre-built models that can be easily used in a variety of applications.
It works like this,
- First, we run in one terminal: "ollama serve", which in that terminal starts a server that listen all the commands and works as a webserver inside localhost, and the only way to turn it off is by killing the process.
- Second, in another terminal, we can use "ollama run MODEL_NAME", to start a chat with said model, communicating with the server using HTTP and JSON.
I Have a Network class using cpp-httplib, with methods like HTTPGet, HTTPPost and HTTPDelete, to deal with the HTTP requests.
And for the JSON part I am using nlohmann/json library.
Here’s a quick recap to make sure we’re both on the same page:
-
Ollama Framework: I am using the Ollama framework to build and run language models locally. The framework starts a server when you run ollama serve and it listens for commands, which you then interact with using HTTP requests.
-
Communication: For communication with the Ollama server, I have a Network class utilizing the cpp-httplib library to make HTTP requests (GET, POST, DELETE).
-
Data Handling: I am using the nlohmann/json library to handle JSON data, which is used for communication with the Ollama server.
I am planning to build a wxWidgets application that acts as an interface to communicate with the Ollama server, allowing you to interact with language models via HTTP and JSON.
Tell me if you understand my setup so we can continue.
- Assistant
Yes, I understand your setup:
-
Ollama Framework: You are using Ollama, a framework for building and running local language models. It operates by starting a server with the command
ollama servewhich listens for HTTP requests onlocalhost. -
Communication: You interact with this server using HTTP and JSON. You have a
Networkclass that utilizes thecpp-httpliblibrary for making HTTP GET, POST, and DELETE requests. -
Data Handling: For managing JSON data, you are using the
nlohmann/jsonlibrary. -
wxWidgets Application: Your goal is to build a desktop GUI application using wxWidgets that will serve as an interface for interacting with the Ollama framework's server.
Here's a high-level plan to proceed:
-
Set up a basic wxWidgets application structure with a main frame and a few controls/buttons for interaction.
-
- User
I will be implementing markdown support in a wxRichTextCtrl, you can begin with a basic feature set and gradually expand the functionality. Here is a suggested order to implement features incrementally:
- Basic Markdown Features:
- Add support for basic markdown formatting such as bold, italic, and underline. Implement parsing logic to recognize and apply these formatting styles to the messages.
- Headers and Lists:
- Introduce support for headers and lists in markdown messages. Allow users to create structured content using headers and bullet/numbered lists.
- Code Blocks and Blockquotes:
- Add support for displaying code blocks and blockquotes in markdown messages. Implement formatting logic to differentiate code snippets and quoted text.
- Advanced Features (optional):
- Consider implementing more advanced markdown features such as tables, task lists, etc.
- Live Preview (optional - TBA):
- Provide a live preview option for users to see the formatted text as they type in the chat input. This can enhance the user experience by showing real-time markdown rendering.
Let me know if you understood this so we can move to my current code and how we can start dealing with the markdown support.
- Assistant
- User
- Assistant
- User
Can you rewrite it again, using escape characters, since the browser is showing me weird code formatting for your messages
- Assistant
- User
I can't read your code, I told you to escape every single markdown or html character, since my brwoser keeps converting your code into html or something, escape everything, for example:
this string "**" convert it like this "**", do the same for every single instance.
Also before doing that, leave the code block out of it yet, we will add it later, first let's focus on the others first.
Also answer me this question, does this while block iterate once and format everything as it sees first or it runs the string several times for each marker?
Now write code again following my requirements
- Assistant
- User
- Assistant
- User
the last code you posted is wrong, really bad.
- You made an if with the same condition as it's else if? Write hte code again but this time pay attention to these errors:
if (markerLength == 2) // Bold { ... else if (markerLength == 2) // Underline { ...
-
Why do you make the ordered list of a length of "11"? I don't think that is correct.
-
The ordered list should use this method:
BeginNumberedBullet() bool wxRichTextCtrl::BeginNumberedBullet ( int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD ) Begins a numbered bullet.
- Assistant
- User
- Assistant
- User
- Assistant
- User
- Assistant
- User
it works great, but I want to differenciate between valid links and other links like for example github links that represents images:
After this, we have to add the backstick for the code:
Code To denote a word or phrase as code, enclose it in backticks (`).
Markdown | HTML At the command prompt, type
nano. | At the command prompt, type nano.Maybe we can use something like this:
// Create a new text style for code formatting wxRichTextAttr codeAttr; codeAttr.SetFont(wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); codeAttr.SetForegroundColour(wxColour(0, 0, 0)); // Black codeAttr.SetBackgroundColour(wxColour(240, 240, 240)); // Light gray
- Assistant
- User
now it works let do some shades of my original colors, so we have to get the current color and apply a shade to it
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.