mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-08 22:08:03 -05:00
## CHANGES - Add `--voice` flag for TTS voice selection - Add `--list-gemini-voices` command for voice discovery - Implement voice validation for Gemini TTS models - Update shell completions for voice options - Add comprehensive Gemini TTS documentation - Create voice samples directory structure - Extend spell checker dictionary with voice names
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package domain
|
|
|
|
import "github.com/danielmiessler/fabric/internal/chat"
|
|
|
|
const ChatMessageRoleMeta = "meta"
|
|
|
|
type ChatRequest struct {
|
|
ContextName string
|
|
SessionName string
|
|
PatternName string
|
|
PatternVariables map[string]string
|
|
Message *chat.ChatCompletionMessage
|
|
Language string
|
|
Meta string
|
|
InputHasVars bool
|
|
StrategyName string
|
|
}
|
|
|
|
type ChatOptions struct {
|
|
Model string
|
|
Temperature float64
|
|
TopP float64
|
|
PresencePenalty float64
|
|
FrequencyPenalty float64
|
|
Raw bool
|
|
Seed int
|
|
ModelContextLength int
|
|
MaxTokens int
|
|
Search bool
|
|
SearchLocation string
|
|
ImageFile string
|
|
ImageSize string
|
|
ImageQuality string
|
|
ImageCompression int
|
|
ImageBackground string
|
|
SuppressThink bool
|
|
ThinkStartTag string
|
|
ThinkEndTag string
|
|
AudioOutput bool
|
|
AudioFormat string
|
|
Voice string
|
|
}
|
|
|
|
// NormalizeMessages remove empty messages and ensure messages order user-assist-user
|
|
func NormalizeMessages(msgs []*chat.ChatCompletionMessage, defaultUserMessage string) (ret []*chat.ChatCompletionMessage) {
|
|
// Iterate over messages to enforce the odd position rule for user messages
|
|
fullMessageIndex := 0
|
|
for _, message := range msgs {
|
|
if message.Content == "" {
|
|
// Skip empty messages as the anthropic API doesn't accept them
|
|
continue
|
|
}
|
|
|
|
// Ensure, that each odd position shall be a user message
|
|
if fullMessageIndex%2 == 0 && message.Role != chat.ChatMessageRoleUser {
|
|
ret = append(ret, &chat.ChatCompletionMessage{Role: chat.ChatMessageRoleUser, Content: defaultUserMessage})
|
|
fullMessageIndex++
|
|
}
|
|
ret = append(ret, message)
|
|
fullMessageIndex++
|
|
}
|
|
return
|
|
}
|