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 {
|
if currentFlags.DryRun {
|
||||||
fmt.Println("Dry run: Would send the following request:")
|
var patternContent string
|
||||||
fmt.Printf("Chat Request: %+v\n", currentFlags.BuildChatRequest())
|
var contextContent string
|
||||||
fmt.Printf("Chat Options: %+v\n", currentFlags.BuildChatOptions())
|
|
||||||
return
|
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
|
var chatter *core.Chatter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user