mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-08 07:11:06 +00:00
Fix dry run
This commit is contained in:
parent
4006f3f417
commit
7d3bf8c3a2
36
cli/cli.go
36
cli/cli.go
@ -143,10 +143,38 @@ func Cli() (message string, err error) {
|
||||
}
|
||||
|
||||
if currentFlags.DryRun {
|
||||
fmt.Println("Dry run: Would send the following request:")
|
||||
fmt.Printf("Chat Request: %+v\n", currentFlags.BuildChatRequest())
|
||||
fmt.Printf("Chat Options: %+v\n", currentFlags.BuildChatOptions())
|
||||
return
|
||||
var patternContent string
|
||||
var contextContent string
|
||||
|
||||
if currentFlags.Pattern != "" {
|
||||
pattern, patternErr := fabric.Db.Patterns.GetPattern(currentFlags.Pattern)
|
||||
if patternErr != nil {
|
||||
fmt.Printf("Error getting pattern content: %v\n", patternErr)
|
||||
return "", patternErr
|
||||
}
|
||||
patternContent = pattern.Pattern // Assuming the content is stored in the 'Pattern' field
|
||||
}
|
||||
|
||||
if currentFlags.Context != "" {
|
||||
context, contextErr := fabric.Db.Contexts.GetContext(currentFlags.Context)
|
||||
if contextErr != nil {
|
||||
fmt.Printf("Error getting context content: %v\n", contextErr)
|
||||
return "", contextErr
|
||||
}
|
||||
contextContent = context.Content
|
||||
}
|
||||
|
||||
systemMessage := strings.TrimSpace(contextContent) + strings.TrimSpace(patternContent)
|
||||
userMessage := strings.TrimSpace(currentFlags.Message)
|
||||
|
||||
fmt.Println("Dry run: Would send the following request:\n")
|
||||
if systemMessage != "" {
|
||||
fmt.Printf("System:\n%s\n\n", systemMessage)
|
||||
}
|
||||
if userMessage != "" {
|
||||
fmt.Printf("User:\n%s\n", userMessage)
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var chatter *core.Chatter
|
||||
|
Loading…
Reference in New Issue
Block a user