mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-31 21:15:27 +00:00
Add chat UI elements.
This commit is contained in:
@@ -13,8 +13,11 @@ namespace tracy
|
||||
|
||||
extern double s_time;
|
||||
|
||||
constexpr size_t InputBufferSize = 1024;
|
||||
|
||||
TracyLlm::TracyLlm()
|
||||
: m_exit( false )
|
||||
, m_input( nullptr )
|
||||
{
|
||||
if( !s_config.llm ) return;
|
||||
|
||||
@@ -33,6 +36,9 @@ TracyLlm::TracyLlm()
|
||||
return;
|
||||
}
|
||||
|
||||
m_input = new char[InputBufferSize];
|
||||
*m_input = 0;
|
||||
|
||||
m_jobs.emplace_back( WorkItem {
|
||||
.task = Task::LoadModels,
|
||||
.callback = [this] { UpdateModels(); }
|
||||
@@ -42,6 +48,8 @@ TracyLlm::TracyLlm()
|
||||
|
||||
TracyLlm::~TracyLlm()
|
||||
{
|
||||
delete[] m_input;
|
||||
|
||||
if( m_thread.joinable() )
|
||||
{
|
||||
{
|
||||
@@ -124,6 +132,17 @@ void TracyLlm::Draw()
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild( "##ollama", ImVec2( 0, -( ImGui::GetFrameHeight() + ImGui::GetStyle().ItemSpacing.y * 2 ) ), ImGuiChildFlags_Borders );
|
||||
ImGui::EndChild();
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::PushItemWidth( -1 );
|
||||
if( ImGui::InputTextWithHint( "##ollama_input", "Write your question here...", m_input, InputBufferSize, ImGuiInputTextFlags_EnterReturnsTrue ) )
|
||||
{
|
||||
*m_input = 0;
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ private:
|
||||
std::vector<WorkItem> m_jobs;
|
||||
bool m_busy;
|
||||
|
||||
char* m_input;
|
||||
|
||||
ImFont* m_font;
|
||||
ImFont* m_smallFont;
|
||||
ImFont* m_bigFont;
|
||||
|
||||
Reference in New Issue
Block a user