Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

% with redirections. #135

Open
bicmane opened this issue Dec 3, 2019 · 2 comments
Open

% with redirections. #135

bicmane opened this issue Dec 3, 2019 · 2 comments
Labels

Comments

@bicmane
Copy link

bicmane commented Dec 3, 2019

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

@kirsle
Copy link
Member

kirsle commented Dec 3, 2019

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.

@kirsle kirsle added the question label Dec 3, 2019
@bicmane
Copy link
Author

bicmane commented Dec 7, 2019

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants