Skip to content

Commit

Permalink
add questionDone to hey model (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Sep 2, 2023
1 parent 4dfe9e8 commit ad78dbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/cmd/hey/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Model struct {
spotifyClient *spotify.Client
openaiClient *openai.Client
questionIndex int
questionDone bool
functionCall any
chatCompMessages []openai.ChatCompletionMessage
functions []openai.FunctionDefinition
Expand Down
7 changes: 7 additions & 0 deletions ui/cmd/hey/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "ctrl+c", "q":
return m, tea.Quit
case "tab":
if m.questionDone {
m.state = recommendationView
}
m.state = m.state.Switch()
case "enter":
if m.err != nil {
Expand Down Expand Up @@ -83,6 +86,10 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.chatCompMessages = append(m.chatCompMessages, msg.msg)
m.functionCall = "auto"
m.questionIndex++
if m.questionIndex == len(functions.List) {
m.questionDone = true
m.state = recommendationView
}
return m, tea.Batch(m.generate, m.recommend)
case recommendMsg:
m.recommendItems = msg.items
Expand Down

0 comments on commit ad78dbf

Please sign in to comment.