From 4006f3f417d25ee686aa99f300020137f47d00bf Mon Sep 17 00:00:00 2001 From: Azwar Tamim Date: Wed, 28 Aug 2024 21:50:06 +0700 Subject: [PATCH] Add dry run --- README.md | 1 + cli/cli.go | 7 +++++++ cli/flags.go | 1 + 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index eddcf16..1be0c35 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,7 @@ Application Options: -u, --url= Choose ollama url (default: http://127.0.0.1:11434) -o, --output= Output to file -n, --latest= Number of latest patterns to list (default: 0) + --dry-run Show what would be sent to the model without actually sending it Help Options: -h, --help Show this help message diff --git a/cli/cli.go b/cli/cli.go index f8178de..5fa856d 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -142,6 +142,13 @@ 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 chatter *core.Chatter if chatter, err = fabric.GetChatter(currentFlags.Model, currentFlags.Stream); err != nil { return diff --git a/cli/flags.go b/cli/flags.go index ee8bdd4..1980a56 100644 --- a/cli/flags.go +++ b/cli/flags.go @@ -37,6 +37,7 @@ type Flags struct { YouTube string `short:"y" long:"youtube" description:"YouTube video url to grab transcript, comments from it and send to chat"` YouTubeTranscript bool `long:"transcript" description:"Grab transcript from YouTube video and send to chat"` YouTubeComments bool `long:"comments" description:"Grab comments from YouTube video and send to chat"` + DryRun bool `long:"dry-run" description:"Show what would be sent to the model without actually sending it"` } // Init Initialize flags. returns a Flags struct and an error