mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-18 23:05:23 +00:00
Allow changing context size.
This commit is contained in:
@@ -122,7 +122,10 @@ void TracyLlm::Draw()
|
||||
m_cv.notify_all();
|
||||
}
|
||||
|
||||
if( ImGui::BeginCombo( "Model##model", m_models[m_modelIdx].name.c_str() ) )
|
||||
ImGui::AlignTextToFramePadding();
|
||||
TextDisabledUnformatted( "Model:" );
|
||||
ImGui::SameLine();
|
||||
if( ImGui::BeginCombo( "##model", m_models[m_modelIdx].name.c_str() ) )
|
||||
{
|
||||
for( size_t i = 0; i < m_models.size(); ++i )
|
||||
{
|
||||
@@ -139,6 +142,16 @@ void TracyLlm::Draw()
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
TextDisabledUnformatted( "Context size:" );
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth( 80 * scale );
|
||||
if( ImGui::InputInt( "##contextSize", &m_ctxPercent ) ) { m_ctxPercent = std::clamp( m_ctxPercent, 1, 100 ); }
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted( "%" );
|
||||
ImGui::SameLine();
|
||||
ImGui::TextDisabled( "(%s)", RealToString( m_models[m_modelIdx].ctxSize * m_ctxPercent / 100 ) );
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild( "##ollama", ImVec2( 0, -( ImGui::GetFrameHeight() + ImGui::GetStyle().ItemSpacing.y * 2 ) ), ImGuiChildFlags_Borders );
|
||||
if( m_chat->empty() )
|
||||
@@ -317,7 +330,7 @@ void TracyLlm::UpdateModels()
|
||||
void TracyLlm::SendMessage( ollama::messages&& messages )
|
||||
{
|
||||
ollama::options options;
|
||||
options["num_ctx"] = m_models[m_modelIdx].ctxSize;
|
||||
options["num_ctx"] = m_models[m_modelIdx].ctxSize * m_ctxPercent / 100;
|
||||
|
||||
// The chat() call will fire a callback right away, so the assistant message needs to be there already
|
||||
m_chat->emplace_back( ollama::message( "assistant", "" ) );
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
std::vector<LlmModel> m_models;
|
||||
|
||||
size_t m_modelIdx;
|
||||
size_t m_ctxSize;
|
||||
int m_ctxPercent = 100;
|
||||
|
||||
std::atomic<bool> m_exit;
|
||||
std::condition_variable m_cv;
|
||||
|
||||
Reference in New Issue
Block a user