Enha: avoid \n\n in tool collapse
This commit is contained in:
4
bot.go
4
bot.go
@@ -1207,11 +1207,11 @@ func chatToTextSlice(messages []models.RoleMsg, showSys bool) []string {
|
|||||||
// This is a tool call indicator - show collapsed
|
// This is a tool call indicator - show collapsed
|
||||||
if toolCollapsed {
|
if toolCollapsed {
|
||||||
toolName := messages[i].ToolCall.Name
|
toolName := messages[i].ToolCall.Name
|
||||||
resp[i] = fmt.Sprintf("%s\n%s\n[yellow::i][tool call: %s (press Ctrl+T to expand)][-:-:-]\n", icon, messages[i].GetText(), toolName)
|
resp[i] = strings.ReplaceAll(fmt.Sprintf("%s\n%s\n[yellow::i][tool call: %s (press Ctrl+T to expand)][-:-:-]\n", icon, messages[i].GetText(), toolName), "\n\n", "\n")
|
||||||
} else {
|
} else {
|
||||||
// Show full tool call info
|
// Show full tool call info
|
||||||
toolName := messages[i].ToolCall.Name
|
toolName := messages[i].ToolCall.Name
|
||||||
resp[i] = fmt.Sprintf("%s\n%s\n[yellow::i][tool call: %s][-:-:-]\nargs: %s\nid: %s\n", icon, messages[i].GetText(), toolName, messages[i].ToolCall.Args, messages[i].ToolCall.ID)
|
resp[i] = strings.ReplaceAll(fmt.Sprintf("%s\n%s\n[yellow::i][tool call: %s][-:-:-]\nargs: %s\nid: %s\n", icon, messages[i].GetText(), toolName, messages[i].ToolCall.Args, messages[i].ToolCall.ID), "\n\n", "\n")
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
4
tools.go
4
tools.go
@@ -763,7 +763,6 @@ func executeCommand(args map[string]string) []byte {
|
|||||||
logger.Error(msg)
|
logger.Error(msg)
|
||||||
return []byte(msg)
|
return []byte(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle commands passed as single string with spaces (e.g., "go run main.go" or "cd /tmp")
|
// Handle commands passed as single string with spaces (e.g., "go run main.go" or "cd /tmp")
|
||||||
// Split into base command and arguments
|
// Split into base command and arguments
|
||||||
parts := strings.Fields(commandStr)
|
parts := strings.Fields(commandStr)
|
||||||
@@ -774,18 +773,15 @@ func executeCommand(args map[string]string) []byte {
|
|||||||
}
|
}
|
||||||
command := parts[0]
|
command := parts[0]
|
||||||
cmdArgs := parts[1:]
|
cmdArgs := parts[1:]
|
||||||
|
|
||||||
if !isCommandAllowed(command, cmdArgs...) {
|
if !isCommandAllowed(command, cmdArgs...) {
|
||||||
msg := fmt.Sprintf("command '%s' is not allowed", command)
|
msg := fmt.Sprintf("command '%s' is not allowed", command)
|
||||||
logger.Error(msg)
|
logger.Error(msg)
|
||||||
return []byte(msg)
|
return []byte(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special handling for cd command - update FilePickerDir
|
// Special handling for cd command - update FilePickerDir
|
||||||
if command == "cd" {
|
if command == "cd" {
|
||||||
return handleCdCommand(cmdArgs)
|
return handleCdCommand(cmdArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute with timeout for safety
|
// Execute with timeout for safety
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user