コード例 #1
0
ファイル: __init__.py プロジェクト: ro-boy/ravestate
 def akinator_play_ask(ctx):
     """
     Asks if interlocutor wants to play 20 question / akinator
     Triggered when nlp:play property is changed by "i want to play a game" or a similar input
     """
     ctx["rawio:out"] = "Do you want to play 20 questions?"
     return Emit()
コード例 #2
0
ファイル: __init__.py プロジェクト: ro-boy/ravestate
 def akinator_is_it(ctx):
     """
     Outputs the solution guess of akinator: "Is this your character? ..."
     Triggers the is_it_answer state
     """
     global akinator_api
     guess = akinator_api.guess_get_request()
     ctx["rawio:out"] = "Is this your character? \n" + guess['name'] + "\n" + guess['desc'] \
                        + "\nPlease answer with 'yes' or 'no'."
     return Emit()
コード例 #3
0
ファイル: __init__.py プロジェクト: WiktorJ/ravestate
    def store_face_and_name(ctx: ContextWrapper):
        tokens = ctx["nlp:tokens"]
        triples = ctx["nlp:triples"]
        if len(tokens) == 1:
            name = tokens[0]
        elif triples[0].get_object().text and triples[0].match_either_lemma(pred={"be"}):
            name = triples[0].get_object().text
        else:
            ctx["rawio:out"] = "Sorry, what was the name?"
            return Emit()
        ctx["rawio:out"] = f"Got it, I'm sure I'll remember {name} next time I see that face!"

        # Create memory entry
        sess: Session = ravestate_ontology.get_session()
        onto: Ontology = ravestate_ontology.get_ontology()
        query = Node(metatype=onto.get_type("Person"))
        query.set_properties({"name": name})
        node_list = sess.retrieve(query)
        if not node_list:
            node = sess.create(query)
            logger.info(f"Created new Node in scientio session: {node}")
        elif len(node_list) == 1:
            node = node_list[0]
        else:
            logger.error(f'Failed to create or retrieve Scientio Node for {name}!')
            return
        logger.info(f"Node ID for {name} in picture is {node.get_id()}!")

        # Store face vector with node id in redis
        try:
            redis_conn = redis.Redis(
                host=ctx.conf(key=REDIS_HOST_CONF),
                port=ctx.conf(key=REDIS_PORT_CONF),
                password=ctx.conf(key=REDIS_PASS_CONF))
            redis_conn.set(node.get_id(), ctx["sendpics:face_vec"])
        except redis.exceptions.ConnectionError as e:
            err_msg = "Looks like the redis connection is unavailable :-("
            logger.error(err_msg)
            ctx['rawio:out'] = err_msg
コード例 #4
0
 def nlp_intent_play_signal(ctx):
     nlp_triples = ctx["nlp:triples"]
     if nlp_triples[0].match_either_lemma(pred={"play"}, obj={"game"}):
         return Emit()
     return False
コード例 #5
0
 def nlp_yes_no_signal(ctx):
     if ctx["nlp:yesno"] != "_":
         return Emit()
     return False
コード例 #6
0
 def nlp_is_question_signal(ctx):
     if ctx["nlp:triples"][0].is_question():
         return Emit()
     return False
コード例 #7
0
 def nlp_contains_roboy_signal(ctx):
     if ctx["nlp:roboy"]:
         return Emit()
     return False
コード例 #8
0
ファイル: __init__.py プロジェクト: ro-boy/ravestate
 def am_i_impatient(ctx: ContextWrapper):
     return Emit(wipe=True)
コード例 #9
0
ファイル: __init__.py プロジェクト: ro-boy/ravestate
 def am_i_bored(ctx: ContextWrapper):
     """
     Emits idle:bored signal if no states are currently partially fulfilled
     """
     if ctx[":activity"] == 0:
         return Emit(wipe=True)
コード例 #10
0
 def signal_b(ctx):
     return Emit()