Пример #1
0
def main():
    """Simple implementation of nlu_cli."""
    args = parse_args()
    mood = args.mood

    # Create both Personas for the user and the system
    user_persona = Persona("user", mood, 5)
    simulated_persona = args.personality_profile
    #simulated_persona = Persona(args.personality_profile)

    # initiate conversation
    conversation_history = Conversation([user_persona, simulated_persona])

    ongoing_conversation = True
    while ongoing_conversation:
        # Query user for utterance
        utterance, mood = nlu_cli(mood)

        # update conversation history
        conversation_history.add_utterance(utterance)

        # update user persona
        if user_persona.personality.mood != mood:
            user_persona.personality.set_mood(mood)

        print("output NLU_CLI data:\n")
        utterance.print_out()
        print("\n", mood, "\n")

        print("output conversation_history updated\n")
        conversation_history.print_out()

        print("output user_persona.mood updated\n")
        user_persona.print_out()

        if utterance.dialogue_act == DA.farewell:
            ongoing_conversation = False
Пример #2
0
def main():
    args = parse_args()
    mood = args.mood

    # Ask user for their unique name: TODO have bot ask and parse this in convo
    username = input("Enter your name: ").strip()

    # Create both Personas for the user and the system
    user_persona = Persona(username, mood, 5)
    chatbot = args.personality_profile

    # personality dict:
    persona_dict = {user_persona.name: user_persona, chatbot.name: chatbot}

    # TODO Actually implement ConversationHistory, rather than one conversation
    conversation_history = Conversation({user_persona.name, chatbot.name})

    # TODO check if there exists a conversation history between the user and bot

    ongoing_conversation = True
    while ongoing_conversation:
        # Query user for utterance
        utterance, mood = nlu_cli(mood, user_persona.name)
        print("\n")

        # update conversation history
        conversation_history.add_utterance(utterance)

        # update user persona
        if user_persona.personality.mood != mood:
            user_persona.personality.set_mood(mood)
        # TODO Save topic sentiment for user_persona!

        # TODO update simulated persona(s) for future versions, non-prototype

        # Simulated Personality must determine how to respond and what to say
        # This is mostly outside of NLG, although the what to say part somewhat
        # overlaps with NLG task of content determination.

        try:
            response_utterance = intelligent_agent.decide_response(
                conversation_history, chatbot.name, persona_dict)
        except:
            response_utterance = tactic.psychiatrist(utterance, chatbot.name)

        # TODO ensure NLG expects meta text!
        #   TODO OR, make it so IA's tactics create the text.
        # Utterance text should never be none, it will instead be a string of
        # keywords for tactics to fill in their place.
        #   ie. greeting username, question_experience ?
        #       = "Hello Bob, how was your day?"

        # call NLG module to generate actual text, if needed.
        #response_utterance = nlg.generate_response_text(
        #    response_metadata, chatbot, conversation_history) \
        #        if response_metadata.text is None else response_metadata

        print(response_utterance)

        # update conversation history
        conversation_history.add_utterance(response_utterance)

        if response_utterance.dialogue_act == DA.farewell:
            ongoing_conversation = False