Skip to content

Commit

Permalink
added preprompt to text generation (#210)
Browse files Browse the repository at this point in the history
added preprompt to text generation
  • Loading branch information
guhitb authored Feb 8, 2024
1 parent 535474d commit a7f3522
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ func main() {
fmt.Fprintln(os.Stderr, `Example: tgpt -w "What is encryption?"`)
os.Exit(1)
}
getWholeText(trimmedPrompt + pipedInput)
getWholeText(*preprompt + trimmedPrompt + pipedInput)
} else {
formattedInput := getFormattedInputStdin()
fmt.Println()
getWholeText(formattedInput + cleanPipedInput)
getWholeText(*preprompt + formattedInput + cleanPipedInput)
}
} else if *isQuiet {
if len(prompt) > 1 {
Expand All @@ -155,11 +155,11 @@ func main() {
fmt.Fprintln(os.Stderr, `Example: tgpt -q "What is encryption?"`)
os.Exit(1)
}
getSilentText(trimmedPrompt + pipedInput)
getSilentText(*preprompt + trimmedPrompt + pipedInput)
} else {
formattedInput := getFormattedInputStdin()
fmt.Println()
getSilentText(formattedInput + cleanPipedInput)
getSilentText(*preprompt + formattedInput + cleanPipedInput)
}
} else if *isShell {
if len(prompt) > 1 {
Expand All @@ -170,7 +170,7 @@ func main() {
fmt.Fprintln(os.Stderr, `Example: tgpt -s "How to update system"`)
os.Exit(1)
}
shellCommand(trimmedPrompt + pipedInput)
shellCommand(*preprompt + trimmedPrompt + pipedInput)
} else {
fmt.Fprintln(os.Stderr, "You need to provide some text")
fmt.Fprintln(os.Stderr, `Example: tgpt -s "How to update system"`)
Expand Down Expand Up @@ -228,6 +228,10 @@ func main() {
}
os.Exit(0)
}
// Use preprompt for first message
if previousMessages == "" {
input = *preprompt + input
}
responseJson, responseTxt := getData(input, true, structs.ExtraOptions{
PrevMessages: previousMessages,
ThreadID: threadID,
Expand Down Expand Up @@ -325,6 +329,8 @@ func initialModel() model {
ti.CharLimit = 200000
ti.ShowLineNumbers = false
ti.Placeholder = "Enter your prompt"
ti.SetValue(*preprompt)
*preprompt = ""
ti.Focus()

return model{
Expand Down

0 comments on commit a7f3522

Please sign in to comment.