Exercise

Putting it all together II

With your chitchat_response(message) function defined, the next step is to define a send_message() function. This function should first call chitchat_response(message) and only use the coffee bot policy if there is no matching message.

Instructions

100 XP
  • Define a send_message() function which takes in 3 arguments: state, pending, and message.
  • Call chitchat_response(message), storing the result in response. If there is a response, print it and return the state along with None.
  • Unpack the policy_rules dictionary into the variables new_state, response, and pending_state. To do this, pass in a tuple consisting of state and interpret(message).
  • If pending is not none, extract the new states and response by using pending as the key of policy_rules.