mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-08 07:11:06 +00:00
feat: split tools messages from use message
This commit is contained in:
parent
f2fdd6e6d3
commit
38406ee586
20
cli/cli.go
20
cli/cli.go
@ -134,6 +134,8 @@ func Cli(version string) (err error) {
|
||||
|
||||
// if none of the above currentFlags are set, run the initiate chat function
|
||||
|
||||
var messageTools string
|
||||
|
||||
if currentFlags.YouTube != "" {
|
||||
if registry.YouTube.IsConfigured() == false {
|
||||
err = fmt.Errorf("YouTube is not configured, please run the setup procedure")
|
||||
@ -158,8 +160,7 @@ func Cli(version string) (err error) {
|
||||
if transcript, err = registry.YouTube.GrabTranscript(videoId, language); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
currentFlags.AppendMessage(transcript)
|
||||
messageTools = AppendMessage(messageTools, transcript)
|
||||
}
|
||||
|
||||
if currentFlags.YouTubeComments {
|
||||
@ -170,12 +171,12 @@ func Cli(version string) (err error) {
|
||||
|
||||
commentsString := strings.Join(comments, "\n")
|
||||
|
||||
currentFlags.AppendMessage(commentsString)
|
||||
messageTools = AppendMessage(messageTools, commentsString)
|
||||
}
|
||||
|
||||
if !currentFlags.IsChatRequest() {
|
||||
// if the pattern flag is not set, we wanted only to grab the transcript or comments
|
||||
fmt.Println(currentFlags.Message)
|
||||
fmt.Println(messageTools)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -187,8 +188,7 @@ func Cli(version string) (err error) {
|
||||
if website, err = registry.Jina.ScrapeURL(currentFlags.ScrapeURL); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
currentFlags.AppendMessage(website)
|
||||
messageTools = AppendMessage(messageTools, website)
|
||||
}
|
||||
|
||||
// Check if the scrape_question flag is set and call ScrapeQuestion
|
||||
@ -198,16 +198,20 @@ func Cli(version string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
currentFlags.AppendMessage(website)
|
||||
messageTools = AppendMessage(messageTools, website)
|
||||
}
|
||||
|
||||
if !currentFlags.IsChatRequest() {
|
||||
// if the pattern flag is not set, we wanted only to grab the url or get the answer to the question
|
||||
fmt.Println(currentFlags.Message)
|
||||
fmt.Println(messageTools)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if messageTools != "" {
|
||||
currentFlags.AppendMessage(messageTools)
|
||||
}
|
||||
|
||||
var chatter *core.Chatter
|
||||
if chatter, err = registry.GetChatter(currentFlags.Model, currentFlags.Stream, currentFlags.DryRun); err != nil {
|
||||
return
|
||||
|
17
cli/flags.go
17
cli/flags.go
@ -182,15 +182,20 @@ func (o *Flags) BuildChatRequest(Meta string) (ret *common.ChatRequest, err erro
|
||||
}
|
||||
|
||||
func (o *Flags) AppendMessage(message string) {
|
||||
if o.Message != "" {
|
||||
o.Message = o.Message + "\n" + message
|
||||
} else {
|
||||
o.Message = message
|
||||
}
|
||||
o.Message = AppendMessage(o.Message, message)
|
||||
return
|
||||
}
|
||||
|
||||
func (o *Flags) IsChatRequest() (ret bool) {
|
||||
ret = o.Message != "" || o.Context != "" || o.Session != "" || o.Pattern != "" || len(o.Attachments) > 0
|
||||
ret = o.Message != "" || len(o.Attachments) > 0 || o.Context != "" || o.Session != "" || o.Pattern != ""
|
||||
return
|
||||
}
|
||||
|
||||
func AppendMessage(message string, newMessage string) (ret string) {
|
||||
if message != "" {
|
||||
ret = message + "\n" + newMessage
|
||||
} else {
|
||||
ret = newMessage
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user