Skip to content

% with redirections. #135

Open
Open

Description

@bicmane

Example:

+ year
- Hello. What year were you born?

+ i was born in #
- <@>
 
+ #
% * what year were you born?{weight=20}
- In <star1>? OK.

I tried that way and it doesn't capture the %.
That way, doing redirections you lose the %. Is there any way to avoid losing the previous one? It's something I did sometimes when I used the AIML version

Activity

  1. kirsle commented on Dec 3, 2019

    @kirsle
    Member

    Maybe you can re-arrange your triggers to avoid the need for this:

    + year
    - Hello. What year were you born?
    
    + i was born in #
    - In <star1>? OK.
    
    + #
    % * what year were you born{weight=20}
    @ i was born in <star>
    

    You> year
    Bot> Hello. What year were you born?
    You> 1900
    Bot> In 1900? OK.
    You> I was born in 1800
    Bot> In 1800? OK.
    You> year
    Bot> Hello. What year were you born?
    You> I was born in 1700
    Bot> In 1700? OK.

    I typed a longer reply to this below:


    It looks like this was intended behavior.

    In rivescript.brain._getreply():

            # See if there were any %Previous's in this topic, or any topic related
            # to it. This should only be done the first time -- not during a
            # recursive redirection. This is because in a redirection, "lastreply"
            # is still gonna be the same as it was the first time, causing an
            # infinite loop!
            if step == 0:

    I tried disabling that check and see if the rivescript-python unit tests failed, but none of the tests actually exercise the bug described in that comment. I traced the git history back and this check was there since the beginning of rivescript-python; so I went and checked the original Perl version's history, and it goes back as far as when I switched from Subversion to Git so don't have much more context on why I programmed it this way.

    However, here is an example RiveScript use case that would trigger the bug being protected from:

    + google something for me
    - What do you want to search for?
    
    + *
    % what do you want to search for
    - Okay, getting that for you: {@google <star>}
    
    + google *
    - Results for "<star>" go here...
    
    You> google Python
    Bot> Results for "python" go here...
    You> google something for me
    Bot> What do you want to search for?
    You> javascript
    Bot> [ERR: Deep recursion detected]
    

    If a trigger with a %Previous redirected to another trigger that happened to match the same conditions as the original %Previous, an infinite loop occurs; RiveScript is programmed to break from infinite loops after 50 levels of recursion (by the ! global depth = 50 parameter).

    With the %Previous check in place as it currently is, this chain of triggers works as expected:

    You> google perl
    Bot> Results for "perl" go here...
    You> google something for me
    Bot> What do you want to search for?
    You> python
    Bot> Okay, getting that for you: Results for "python" go here...
    

    But admittedly for your use case, this behavior isn't adequate.


    I'd be willing to accept a pull request if you find a solution to this problem. Simply removing the step == 0 check won't do, as it would cause new bugs in existing bots where the behavior changes. Ideally there should be some way to do a redirect, keeping the "lastreply" and checking the %Previous's, but not re-triggering the same trigger as it did the first time around.

  2. bicmane commented on Dec 7, 2019

    @bicmane
    Author

    Yes, from the example you've made it worked for me even though that means making a few rules, that's not something I had in mind. But as long as it works, that's fine.
    At the moment I can't find another solution to that, except for your example. Greetings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions