mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-13 23:45:08 -05:00
feat: add cmd -g to select the language would reply
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/danielmiessler/fabric/common"
|
||||
"github.com/jessevdk/go-flags"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
// Flags create flags struct. the users flags go into this, this will be passed to the chat struct in cli
|
||||
@@ -39,6 +40,7 @@ type Flags struct {
|
||||
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"`
|
||||
Language string `short:"g" long:"language" description:"Language of the chat" default:"en"`
|
||||
}
|
||||
|
||||
// Init Initialize flags. returns a Flags struct and an error
|
||||
@@ -105,5 +107,10 @@ func (o *Flags) BuildChatRequest() (ret *common.ChatRequest) {
|
||||
PatternVariables: o.PatternVariables,
|
||||
Message: o.Message,
|
||||
}
|
||||
langTag, err := language.Parse(o.Language)
|
||||
if err != nil {
|
||||
langTag = language.English
|
||||
}
|
||||
ret.Language = langTag.String()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user