JeVois
1.21
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/GPU/ChatBox.H>
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:
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).
Public Member Functions | |
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) |
Freeze/unfreeze the input box, typically to prevent new inputs until current reply is done. | |
void | clear () |
Clear all displayed text: | |
int | callback (ImGuiInputTextCallbackData *data) |
Protected Attributes | |
std::deque< std::pair< bool, std::string > > | itsData |
std::string | itsLastInput |
char | itsInputBuf [1024] |
std::vector< std::string > | itsHistory |
int | itsHistoryPos = 0 |
std::string const | itsTitle |
bool | itsFrozen = false |
int | itsWaitState = 10 |
jevois::ChatBox::ChatBox | ( | std::string | title = "JeVois-Pro ChatBox" | ) |
int jevois::ChatBox::callback | ( | ImGuiInputTextCallbackData * | data | ) |
void jevois::ChatBox::draw | ( | ) |
void jevois::ChatBox::freeze | ( | bool | doit | ) |
std::string jevois::ChatBox::get | ( | ) |
void jevois::ChatBox::writeString | ( | std::string const & | out | ) |
Update text that is displayed above input box (output from the underlying chat bot)
Definition at line 62 of file ChatBox.C.
References jevois::split().
|
protected |
|
protected |
|
protected |