implemented /clear and Ctrl+D and thinking
This commit is contained in:
@@ -152,12 +152,14 @@ user's request and delegate tasks accordingly.
|
|||||||
./bin/sidekick-tui
|
./bin/sidekick-tui
|
||||||
```
|
```
|
||||||
* **Input:** Type your messages at the bottom prompt.
|
* **Input:** Type your messages at the bottom prompt.
|
||||||
|
* **Commands:** Type **`/clear`** and press `Enter` to reset the conversation history.
|
||||||
* **Markdown:** Agent responses are rendered as formatted Markdown.
|
* **Markdown:** Agent responses are rendered as formatted Markdown.
|
||||||
* **Send:** Press `Enter` to send a message.
|
* **Send:** Press `Enter` to send a message.
|
||||||
|
* **Cancel:** Press **`Ctrl+D`** while the agent is thinking to cancel the current request.
|
||||||
* **Newline:** Press `Ctrl+J` to insert a newline in your message.
|
* **Newline:** Press `Ctrl+J` to insert a newline in your message.
|
||||||
* **Scrolling:**
|
* **Scrolling:**
|
||||||
* Use **`Ctrl+U`** or **`PgUp`** to scroll up.
|
* Use **`Ctrl+U`** or **`PgUp`** to scroll up.
|
||||||
* Use **`Ctrl+D`** or **`PgDn`** to scroll down.
|
* Use **`PgDn`** to scroll down.
|
||||||
* Mouse wheel is also supported.
|
* Mouse wheel is also supported.
|
||||||
* **Quit:** Press `Ctrl+C` or `Esc` to exit.
|
* **Quit:** Press `Ctrl+C` or `Esc` to exit.
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ func (s *Sidekick) logIntermediate(msg Message) {
|
|||||||
if !s.Config.LogIntermediate || s.IntermediateHandler == nil {
|
if !s.Config.LogIntermediate || s.IntermediateHandler == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if msg.Reasoning != "" {
|
||||||
|
s.IntermediateHandler(fmt.Sprintf("Reasoning: %s", msg.Reasoning))
|
||||||
|
}
|
||||||
if msg.Content != "" {
|
if msg.Content != "" {
|
||||||
s.IntermediateHandler(fmt.Sprintf("LLM Output: %s", msg.Content))
|
s.IntermediateHandler(fmt.Sprintf("LLM Output: %s", msg.Content))
|
||||||
} else if len(msg.ToolCalls) > 0 {
|
} else if len(msg.ToolCalls) > 0 {
|
||||||
|
|||||||
@@ -426,12 +426,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *model) runAgent() tea.Cmd {
|
func (m *model) runAgent() tea.Cmd {
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
ctx, m.cancel = context.WithCancel(context.Background())
|
ctx, m.cancel = context.WithCancel(context.Background())
|
||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
res, err := m.agent.Run(ctx, m.history, m.pool)
|
res, err := m.agent.Run(ctx, m.history, m.pool)
|
||||||
return agentResponseMsg{response: res, err: err}
|
return agentResponseMsg{response: res, err: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) View() string {
|
func (m model) View() string {
|
||||||
|
|||||||
+14
-4
@@ -21,6 +21,16 @@ port = 8080
|
|||||||
max_tokens = 4096
|
max_tokens = 4096
|
||||||
timeout_secs = 360
|
timeout_secs = 360
|
||||||
|
|
||||||
|
[models.ollama]
|
||||||
|
# model_id = "Jackrong/Qwen3.5-2B-Claude-4.6-Opus-Reasoning-Distilled-GGUF:Q4_K_M"
|
||||||
|
model_id = "LiquidAI/LFM2.5-1.2B-Thinking-GGUF:Q4_K_M"
|
||||||
|
endpoint = "http://127.0.0.1:8080/v1"
|
||||||
|
api_key = ""
|
||||||
|
temperature = 0.6
|
||||||
|
max_tokens = 4096
|
||||||
|
timeout_secs = 600
|
||||||
|
|
||||||
|
|
||||||
[mcp_servers]
|
[mcp_servers]
|
||||||
[mcp_servers.context7]
|
[mcp_servers.context7]
|
||||||
transport = "http"
|
transport = "http"
|
||||||
@@ -33,7 +43,7 @@ port = 8080
|
|||||||
[agents]
|
[agents]
|
||||||
[agents.coordinator]
|
[agents.coordinator]
|
||||||
role = "COORDINATOR"
|
role = "COORDINATOR"
|
||||||
model_id = "default"
|
model_id = "ollama"
|
||||||
enable_shell_exec = true
|
enable_shell_exec = true
|
||||||
streaming = false
|
streaming = false
|
||||||
log_intermediate = true
|
log_intermediate = true
|
||||||
@@ -50,7 +60,7 @@ port = 8080
|
|||||||
|
|
||||||
[agents.coder]
|
[agents.coder]
|
||||||
role = "SPECIALIST"
|
role = "SPECIALIST"
|
||||||
model_id = "default"
|
model_id = "ollama"
|
||||||
enable_shell_exec = true
|
enable_shell_exec = true
|
||||||
streaming = false
|
streaming = false
|
||||||
log_intermediate = true
|
log_intermediate = true
|
||||||
@@ -66,7 +76,7 @@ port = 8080
|
|||||||
|
|
||||||
[agents.reviewer]
|
[agents.reviewer]
|
||||||
role = "SPECIALIST"
|
role = "SPECIALIST"
|
||||||
model_id = "fast"
|
model_id = "ollama"
|
||||||
streaming = false
|
streaming = false
|
||||||
log_intermediate = true
|
log_intermediate = true
|
||||||
system_prompt = "You are a Quality Assurance Specialist and Code Reviewer. Your role is to analyze code for potential bugs, security vulnerabilities, and style violations."
|
system_prompt = "You are a Quality Assurance Specialist and Code Reviewer. Your role is to analyze code for potential bugs, security vulnerabilities, and style violations."
|
||||||
@@ -81,7 +91,7 @@ port = 8080
|
|||||||
|
|
||||||
[agents.tester]
|
[agents.tester]
|
||||||
role = "SPECIALIST"
|
role = "SPECIALIST"
|
||||||
model_id = "fast"
|
model_id = "ollama"
|
||||||
enable_shell_exec = true
|
enable_shell_exec = true
|
||||||
streaming = false
|
streaming = false
|
||||||
log_intermediate = true
|
log_intermediate = true
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ func (s *standardLLMClient) handleStream(body io.ReadCloser, streamCallback,
|
|||||||
reasoningCallback func(string)) (Message, error) {
|
reasoningCallback func(string)) (Message, error) {
|
||||||
defer body.Close()
|
defer body.Close()
|
||||||
var fullContent strings.Builder
|
var fullContent strings.Builder
|
||||||
|
var fullReasoning strings.Builder
|
||||||
var finalMsg Message
|
var finalMsg Message
|
||||||
finalMsg.Role = MessageRoleAssistant
|
finalMsg.Role = MessageRoleAssistant
|
||||||
|
|
||||||
@@ -178,14 +179,26 @@ func (s *standardLLMClient) handleStream(body io.ReadCloser, streamCallback,
|
|||||||
var chunk struct {
|
var chunk struct {
|
||||||
Choices []struct {
|
Choices []struct {
|
||||||
Delta struct {
|
Delta struct {
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
ToolCalls []deltaToolCall `json:"tool_calls"`
|
ReasoningContent string `json:"reasoning_content"`
|
||||||
|
Reasoning string `json:"reasoning"`
|
||||||
|
ToolCalls []deltaToolCall `json:"tool_calls"`
|
||||||
} `json:"delta"`
|
} `json:"delta"`
|
||||||
} `json:"choices"`
|
} `json:"choices"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal([]byte(data), &chunk); err == nil && len(chunk.Choices) > 0 {
|
if err := json.Unmarshal([]byte(data), &chunk); err == nil && len(chunk.Choices) > 0 {
|
||||||
delta := chunk.Choices[0].Delta
|
delta := chunk.Choices[0].Delta
|
||||||
if delta.Content != "" {
|
|
||||||
|
rContent := delta.ReasoningContent
|
||||||
|
if rContent == "" {
|
||||||
|
rContent = delta.Reasoning
|
||||||
|
}
|
||||||
|
if rContent != "" && reasoningCallback != nil {
|
||||||
|
fullReasoning.WriteString(rContent)
|
||||||
|
reasoningCallback(rContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
if delta.Content != "" && streamCallback != nil {
|
||||||
fullContent.WriteString(delta.Content)
|
fullContent.WriteString(delta.Content)
|
||||||
streamCallback(delta.Content)
|
streamCallback(delta.Content)
|
||||||
}
|
}
|
||||||
@@ -206,6 +219,7 @@ func (s *standardLLMClient) handleStream(body io.ReadCloser, streamCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
finalMsg.Content = fullContent.String()
|
finalMsg.Content = fullContent.String()
|
||||||
|
finalMsg.Reasoning = fullReasoning.String()
|
||||||
if maxIndex >= 0 {
|
if maxIndex >= 0 {
|
||||||
for i := 0; i <= maxIndex; i++ {
|
for i := 0; i <= maxIndex; i++ {
|
||||||
if tc, ok := toolCallsMap[i]; ok {
|
if tc, ok := toolCallsMap[i]; ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user