Skip to content

Commit

Permalink
feat: Support restart a new Session
Browse files Browse the repository at this point in the history
  • Loading branch information
fengxxc committed Mar 21, 2023
1 parent 6383f6e commit 9c87118
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BUILD_ENV := CGO_ENABLED=0
APP=go-chatgpt
VERSION=v0.2.0
VERSION=v0.3.0

# linux or mac 环境编译
# make [cmd]
Expand Down
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func main() {

if content == "" {
fmt.Println("Welcome to ChatGpt CLI~ 😘 ")
fmt.Print("Start your show~ 😙 (Enter 'exit' to quit.)\n> ")
fmt.Println("(Enter 'exit' to quit; Enter 'new' to restart a new Session.)")
fmt.Print("> ")
chatOfSession(config)
}

Expand All @@ -67,7 +68,12 @@ func chatOfSession(config *chatgpt.GptConfig) {
scanner.Scan()
q = scanner.Text()
q = strings.TrimSpace(q)
if q == "exit" {
if q == "new" {
gptMessages = []*chatgpt.GptMessage{}
fmt.Println("-----Restart a new session-----")
fmt.Printf("\n> ")
continue
} else if q == "exit" {
fmt.Println("See you next time~ 🤗")
os.Exit(0)
return
Expand Down

0 comments on commit 9c87118

Please sign in to comment.