mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
ed618e14aa
* Add multi-message sending via split marker * Add marker and length split integration tests Tests that SplitByMarker and SplitMessage work together correctly, and that code block boundaries are preserved during marker splitting. * Simplify message chunking logic in channel worker Extract splitByLength helper function and remove goto-based control flow. The logic now flows more naturally - try marker splitting first, then fall back to length-based splitting. * Update multi-message output instructions in agent context * Add split_on_marker to config defaults * Add split_on_marker config option * Rename 'Multi-Message Sending' setting to 'Chatty Mode' * Add SplitOnMarker config option
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// PicoClaw - Ultra-lightweight personal AI agent
|
|
// Inspired by and based on nanobot: https://github.com/HKUDS/nanobot
|
|
// License: MIT
|
|
//
|
|
// Copyright (c) 2026 PicoClaw contributors
|
|
|
|
package channels
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// MessageSplitMarker is the delimiter used to split a message into multiple outbound messages.
|
|
// When SplitOnMarker is enabled in config, the Manager will split messages on this marker
|
|
// and send each part as a separate message.
|
|
const MessageSplitMarker = "<|[SPLIT]|>"
|
|
|
|
// SplitByMarker splits a message by the MessageSplitMarker and returns the parts.
|
|
// Empty parts (including from consecutive markers) are filtered out.
|
|
// If no marker is found, returns a single-element slice containing the original content.
|
|
func SplitByMarker(content string) []string {
|
|
if content == "" {
|
|
return nil
|
|
}
|
|
parts := strings.Split(content, MessageSplitMarker)
|
|
result := make([]string, 0, len(parts))
|
|
for _, part := range parts {
|
|
trimmed := strings.TrimSpace(part)
|
|
if trimmed != "" {
|
|
result = append(result, trimmed)
|
|
}
|
|
}
|
|
if len(result) == 0 {
|
|
return []string{content}
|
|
}
|
|
return result
|
|
}
|