mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
feat(config): allow placeholder text to be string or list
Allow PlaceholderConfig.Text to accept either a single string or an array of strings, from which one is randomly selected at runtime. This maintains backward compatibility with existing single-string configs while enabling random placeholder selection. Changes: - Modify PlaceholderConfig.Text type from string to FlexibleStringSlice - Add GetRandomText() helper method for random selection - Update SendPlaceholder in all channels to use GetRandomText() - Update config.example.json with array placeholder examples - Update Matrix channel documentation
This commit is contained in:
+15
-2
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -381,8 +382,20 @@ type TypingConfig struct {
|
||||
|
||||
// PlaceholderConfig controls placeholder message behavior (Phase 10).
|
||||
type PlaceholderConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Text FlexibleStringSlice `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
// GetRandomText returns a random placeholder text, or default if none set.
|
||||
func (p *PlaceholderConfig) GetRandomText() string {
|
||||
if len(p.Text) == 0 {
|
||||
return "Thinking..."
|
||||
}
|
||||
if len(p.Text) == 1 {
|
||||
return p.Text[0]
|
||||
}
|
||||
idx := rand.Intn(len(p.Text))
|
||||
return p.Text[idx]
|
||||
}
|
||||
|
||||
type StreamingConfig struct {
|
||||
|
||||
@@ -62,7 +62,7 @@ func DefaultConfig() *Config {
|
||||
Typing: TypingConfig{Enabled: true},
|
||||
Placeholder: PlaceholderConfig{
|
||||
Enabled: true,
|
||||
Text: "Thinking... 💭",
|
||||
Text: FlexibleStringSlice{"Thinking... 💭"},
|
||||
},
|
||||
Streaming: StreamingConfig{Enabled: true, ThrottleSeconds: 3, MinGrowthChars: 200},
|
||||
UseMarkdownV2: false,
|
||||
@@ -111,7 +111,7 @@ func DefaultConfig() *Config {
|
||||
},
|
||||
Placeholder: PlaceholderConfig{
|
||||
Enabled: true,
|
||||
Text: "Thinking... 💭",
|
||||
Text: FlexibleStringSlice{"Thinking... 💭"},
|
||||
},
|
||||
CryptoDatabasePath: "",
|
||||
CryptoPassphrase: "",
|
||||
|
||||
Reference in New Issue
Block a user