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. To summarize:
-
Ollama Framework: You're using Ollama, a local framework for running language models. It involves starting a server with
ollama servethat listens for HTTP commands and communicates in JSON format. -
Communication: You're using a custom Network class that employs
cpp-httplibto handle HTTP requests (GET, POST, DELETE) to interact with the Ollama server. -
Data Handling: You're using the
nlohmann/jsonlibrary to manage the JSON data exchanged between your application and the Ollama server. -
wxWidgets Application: You're building a GUI application using wxWidgets to provide an interface for users to interact with the language models via the Ollama server.
I've got the relevant libraries and functionalities you're using:
cpp-httplibfor HTTP communication andnlohmann/jsonfor JSON handling. This forms the basis of your wxWidgets application to interface with language models hosted by the Ollama framework.Feel free to continue with specifics, and I’ll assist you with your requirements.
-
- User
I need to add the model parameters, so create an struct with these fields:
System Message : wxstring Template : wxstring Seed : int Temperature : float Context Size : int Predict Tokens : int Repeat Last : int Repeat Penalty : float Top K : int Top P : float TFS Z : float Mirostat : int Mirostat Tau : float Mirostat Eta : float Keep Tokens : int Typical P : float Presence Penalty : float Frequency Penalty : float Penalize New Lines : bool
- Assistant
- User
Perfect, they will be used here, so make the json for this example, there are some that you must skip like the gpu, or the numa, check out there are some that aren't defined:
curl http://localhost:11434/api/chat -d '{ "model": "gemma:2b", "stream": false, "template": "NEW TEMPLATE", "options": { "num_keep": 5, "seed": 42, "num_predict": 100, "top_k": 20, "top_p": 0.9, "tfs_z": 0.5, "typical_p": 0.7, "repeat_last_n": 33, "temperature": 0.8, "repeat_penalty": 1.2, "presence_penalty": 1.5, "frequency_penalty": 1.0, "mirostat": 1, "mirostat_tau": 0.8, "mirostat_eta": 0.6, "penalize_newline": true, "stop": ["\n", "user:"], "numa": false, "num_ctx": 1024, "num_batch": 2, "num_gpu": 1, "main_gpu": 0, "low_vram": false, "f16_kv": true, "vocab_only": false, "use_mmap": true, "use_mlock": false, "num_thread": 8 } "messages": [ { "role": "system", "content": "NEW SYSTEM MESSAGE" } ] }'
- Assistant
- User
Perfect, how do I use it as a pointer?
I need to pass it as a pointer to a dialog so it can conserve the values and change if needed.
ModelParams* modelParams;
void FrameMain::InitializeModelParams() { if (!loadedModel.empty()) { if (modelParams) { delete modelParams; } modelParams = new ModelParams();
code - Assistant
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.