Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Reuben committed Nov 9, 2022
1 parent 64889e6 commit def6e75
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ var userInputs string
type GoBot struct {
Intent interface{} //This defines user intention
Story interface{} //This drives conversational flow (dialog)
State interface{}
}

func NewGoBot(intents interface{}, stories interface{}) *GoBot {
func NewGoBot(intents interface{}, stories interface{}, state interface{}) *GoBot {
return &GoBot{
Intent: intents,
Story: stories,
State: state,
}
}

Expand Down Expand Up @@ -105,8 +107,8 @@ func (gobot *GoBot) Playground() {
if len(text) != 0 {
// fmt.Println(text)
userInputs = text
_, response := gobot.Chat(text)
fmt.Println(response)
key, response := gobot.Chat(text)
fmt.Println("Intent: " + key + " ----- " + "Response: " + response)
} else {
// exit if user entered an empty string
break
Expand Down Expand Up @@ -150,6 +152,7 @@ func (gobot *GoBot) Chat(message string) (string, string) {
} else {
// fmt.Println("Key when no interface: ", key)
if strings.Contains(key, "choices") {
choice_key := key
key := key[:len(key)-8]
story := goBotStories[key].(map[string]interface{})
next := story["next"]
Expand Down Expand Up @@ -179,8 +182,7 @@ func (gobot *GoBot) Chat(message string) (string, string) {

for _, choice := range choices {
if strings.Contains(strings.ToLower(choice), message) {
// fmt.Println(choice)
return key, choice
return choice_key, choice
}
}

Expand All @@ -202,7 +204,7 @@ func (gobot *GoBot) Chat(message string) (string, string) {
}

} else {
// fmt.Println("Key: ", key)
fmt.Println("Fallback Key: ", key)
fallbackObject := goBotStories["fallback"].(map[string]interface{})

//Check message type (string or []string{})
Expand Down

0 comments on commit def6e75

Please sign in to comment.