A simple helper class for a chat box rendered in ImGui.
This is used, for example, to create interactive dialogues with large language models (LLMs). Users can input text in an input box, and answers can be shown in the main window above. This chatbox is intended to operate fully asynchronously:
- call get() to retrieve any new input messages entered by the user. This is non-blocking and returns immediately. The returned string will be empty except after the user presses [RETURN] in the input box, in which case the whole entered input will be returned.
- call writeString() to add to the text that is written out in the main window.
- call draw() on every video frame.
Note: because it is primarily intended for use in python, this class is not thread-safe (for example, calling writeString() and draw() concurrently might crash the system. In most applications, the ChatBox member functions would all be called sequentially from a single thread).
Definition at line 47 of file ChatBox.H.
|
| ChatBox (std::string title="JeVois-Pro ChatBox") |
| Constructor.
|
|
virtual | ~ChatBox () |
| Destructor.
|
|
std::string | get () |
| Get input string from user, or empty if no new input.
|
|
void | writeString (std::string const &out) |
| Update text that is displayed above input box (output from the underlying chat bot)
|
|
void | draw () |
| Render into an ImGui window.
|
|
void | freeze (bool doit, std::string const &waitmsg) |
| Freeze/unfreeze the input box, typically to prevent new inputs until current reply is done.
|
|
void | clear () |
| Clear all displayed text:
|
|
bool | wasCleared () |
| Returns true once after the user clicked the "Clear chat" button.
|
|
int | callback (ImGuiInputTextCallbackData *data) |
|