Feature Suggestion - Reply without commit|a2b|roy@wasystems.net|1222042221|a2b|xx|0|76.102.148.130|In some applications it would be beneficial to see what a reply would be without actually committing to that phrase. &nbsp;By this I mean, you could get a reply but the brain will not honor any variable changes or store the input into last reply. &nbsp;It will be as if it was never inputted as a reply. <br /><br />Now I am unsure if this causes issues where topics change and a reply is fetch from another topic. &nbsp;If this is a issue then this would require a rollback feature of some sort which may become a mess. &nbsp;Maybe it would require just storing the state before the reply and replacing it after the reply if inputted as a test reply. &nbsp;<br /><br />This could have powerful applications when trying to determine which phrase, with multiple input phrases, to reply to. &nbsp;There are still some other issues to overcome but this would be a great first step. &nbsp;Any thoughts on this?||||
Re: Feature Suggestion - Reply without commit|Kirsle|casey@cuvou.net|1222043032|Kirsle|xx|0|69.227.167.128|The old RiveScript module (up to version 1.04) had a search() function, which did something similarly to this... it would search every trigger in every topic for every trigger that matches the search string, and then provided file names and line numbers of where that trigger could be found.<br /><br />Like...<br />[code]@results = $rs-&gt;search(&quot;hello bot&quot;);[/code]<br /><br />might return<br /><br />[code]@results = (<br /> &nbsp; &quot;random: hello * (at brain/hello.rs line 12)&quot;,<br /> &nbsp; &quot;random: * (at brain/star.rs line 3)&quot;,<br /> &nbsp; &quot;apology: * (at brain/abusive.rs line 22)&quot;,<br />);[/code]<br /><br />It was useful as a technique of finding out &quot;why on earth did my bot just say that to that user, given their message?&quot; and then finding out what triggers the user could've matched.<br /><br />I just haven't programmed that method into the new module cuz I've been lazy (in the original module, the search function was almost exactly the same as the reply function, like it went through the same steps but just wasn't trying to find a reply or manipulate variables).<br /><br />Is this kinda what you were thinking of?||||
Re: Feature Suggestion - Reply without commit|a2b|roy@wasystems.net|1222043642|a2b|xx|0|76.102.148.130|I believe so. &nbsp;If I understand correctly the search function may need to be modified a bit. &nbsp;The output of search, or the test function, should be exactly what the next reply would be at all times. &nbsp;So if indeed you did want to use the reply that came from search, you would need to send the reply normally to ensure anything special is executed.<br /><br />||||
Re: Feature Suggestion - Reply without commit|Kirsle|casey@cuvou.net|1222043943|Kirsle|xx|0|69.227.167.128|So...<br /><br />[code]$test = $rs-&gt;testReply (&quot;soandso&quot;, &quot;my name is soandso&quot;);[/code]<br /><br />What would $test be? Given this code...<br /><br />[code]+ my name is *<br />- &lt;set name=&lt;formal&gt;&gt;Nice to meet you, &lt;get name&gt;.[/code]<br /><br />Would the reply look like...<br /><br />[code]$reply = &quot;&lt;set name=&lt;formal&gt;&gt;Nice to meet you, &lt;get name&gt;.&quot;;<br /><br />or<br /><br />$reply = &quot;Nice to meet you, .&quot;;<br /><br />or<br /><br />$reply = &quot;Nice to meet you, &lt;get name&gt;.&quot;;<br />$reply = &quot;Nice to meet you, [name].&quot;;[/code]<br /><br />And then what would be done after that? Tell the module to kinda jump back into the middle of the reply code and already know what the reply is to begin with and just proceed from there processing tags, or would you just go and get a normal reply() after that since you know what the result is gonna be?<br /><br />Or rather, what problem would you be solving by having a method like this?||||
Re: Feature Suggestion - Reply without commit|a2b|roy@wasystems.net|1222045152|a2b|xx|0|76.102.148.130|Well the fundamental issue here is if you are chatting with someone and they send 2 messages before you deliver a reply:<br /><br />You&gt; hey<br />You&gt; hows it going<br /><br />Using a normal implementation it would reply with a response for both messages. &nbsp;Rather than doing multiple junk replies I currently ignore everything after the first message. &nbsp;The disadvantage to this is that only the &quot;hey&quot; message would of gotten responded to. &nbsp;It would of been more beneficial to reply to the &quot;hows it going&quot; message. &nbsp;<br /><br />This is a really tough issue to solve but I think being able to &quot;see&quot; what the response would be for each, will allow the programmer to make a decision as to what reply should really take place.<br /><br /><br />The reply to what your examples would be is:<br />$reply = &quot;Nice to meet you, soandso.&quot;; <br /><br />This is an example: <br /><br />$test = $rs-&gt;testReply (&quot;soandso&quot;, &quot;my name is soandso&quot;); <br />$test = $rs-&gt;Reply (&quot;soandso&quot;, &quot;what is my name&quot;); <br />$test = $rs-&gt;Reply (&quot;soandso&quot;, &quot;my name is soandso&quot;); <br />$test = $rs-&gt;Reply (&quot;soandso&quot;, &quot;what is my name&quot;); <br /><br />would produce a result of:<br />$reply = &quot;Nice to meet you, soandso.&quot;; <br />$reply = &quot;I do not know your name&quot;; <br />$reply = &quot;Nice to meet you, soandso.&quot;; <br />$reply = &quot;Your name is soandso.&quot;; <br /><br /><br /><br />||||
Re: Feature Suggestion - Reply without commit|Kirsle|casey@cuvou.net|1222049068|Kirsle|xx|0|69.227.167.128|So, how about something like this...<br /><br />[code]my $reply = $rs-&gt;reply ($user, $message, commit =&gt; 0);[/code]<br /><br />And it would go through everything normally, any variables that get set would be restored before the reply is returned and no history is modified, so i.e. &quot;&lt;set name=&lt;star&gt;&gt;nice to meet you &lt;get name&gt;&quot; would work for that reply but then &quot;name&quot; wouldn't actually be saved, or it would be reverted to its original state just before the final reply is returned.<br /><br />Beyond that though, I don't really see how this applies. It seems like if your bot has a problem with people sending multiple messages, it should wait a bit before trying to get a reply to see if their message changes, or just reply to the first message and ignore any other ones, or reply to them both at the same time... like...<br /><br />1. User says &quot;hello&quot;<br />2. Start fetching a reply for &quot;hello&quot;<br />3. User says &quot;what's up?&quot;<br />4. Got a reply for &quot;hello&quot;, before sending it we see that the user said &quot;what's up?&quot; already, so go and get a reply for &quot;what's up?&quot;<br />5. Concatenate that reply to the first one, if the user hasn't interrupted us again, send the whole reply.<br /><br />So,<br />User: hi<br />User: what's up?<br />Bot: Hello there! Not much, what's up with you?||||
Re: Feature Suggestion - Reply without commit|a2b|roy@wasystems.net|1222051532|a2b|xx|0|76.102.148.130|I guess. During that waiting(typing) period, rather than getting a reply then waiting, I can wait and then get the reply right before it is needed. &nbsp;That would allow me to run 2nd or 3rd inputs.<br /><br />However, this brings me to the problem: which one is giving the best response. &nbsp;My solution for this is to tag the general responses &quot;+ *&quot; with a tag that is removed in Perl before being sent. &nbsp;Then I could test the 2nd and 3rd inputs to see if they come back without the tag. &nbsp;Without the tag would imply that it found a better match to something it said so its probably the more relevant thing to respond to. (an alternative to tagging would be to check what pattern the reply matched. &nbsp;ex &quot;+ *&quot; I don't believe there is a way to get this information though?)<br /><br />The problem with this method though, would require me to execute Reply for each incoming message which could potentially offset the conversation due to variables being set and topics changing and such. &nbsp;So if the first input changed the topic, when i test the second input, its lastreply and topic would not correctly use the same conditions and phrases for matching as the first input did.<br /><br />Does this make sense? ||||
Re: Feature Suggestion - Reply without commit|Kirsle|casey@cuvou.net|1228349259|Kirsle|xx|0|72.37.252.50|I've added the functions freezeUservars() and thawUservars() to be included in RiveScript 1.18. The freeze function will back up the user's current state (variables and history), and then the thaw function will revert the user's current state to the one last cached with the freeze method.<br /><br />I have the following code that illustrates how this works:<br /><br />[code]&#123;<br /> &nbsp; &nbsp; &nbsp;use Data::Dumper;<br /> &nbsp; &nbsp; &nbsp;my $reply = $rs-&gt;reply ('localuser',&quot;Hello bot!&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;Hello bot! =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;$reply = $rs-&gt;reply ('localuser',&quot;My name is Kirsle&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;My name is Kirsle =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;$reply = $rs-&gt;reply ('localuser',&quot;What is my name?&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;What is my name? =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;print &quot;## History: &quot; . Dumper($rs-&gt;&#123;client&#125;-&gt;&#123;localuser&#125;-&gt;&#123;__history__&#125;) . &quot;\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;print &quot;## Freezing Uservars ##\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;$rs-&gt;freezeUservars (&quot;localuser&quot;);<br /><br /> &nbsp; &nbsp; &nbsp;$reply = $rs-&gt;reply ('localuser',&quot;My name is Casey&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;My name is Casey =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;$reply = $rs-&gt;reply ('localuser',&quot;What is my name?&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;What is my name? =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;print &quot;## History: &quot; . Dumper($rs-&gt;&#123;client&#125;-&gt;&#123;localuser&#125;-&gt;&#123;__history__&#125;) . &quot;\n&quot;;<br /> &nbsp; &nbsp; &nbsp;print &quot;## Thawing Uservars ##\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;$rs-&gt;thawUservars (&quot;localuser&quot;);<br /><br /> &nbsp; &nbsp; &nbsp;$reply = $rs-&gt;reply ('localuser',&quot;What is my name?&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;What is my name? =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;$reply = $rs-&gt;reply ('localuser',&quot;Goodbye&quot;);<br /> &nbsp; &nbsp; &nbsp;print &quot;Goodbye =&gt; $reply\n&quot;;<br /><br /> &nbsp; &nbsp; &nbsp;print &quot;## History: &quot; . Dumper($rs-&gt;&#123;client&#125;-&gt;&#123;localuser&#125;-&gt;&#123;__history__&#125;) . &quot;\n&quot;;<br />&#125;[/code]<br /><br />[code]Hello bot! =&gt; Hi. What seems to be your problem?<br />My name is Kirsle =&gt; Kirsle, nice to meet you.<br />What is my name? =&gt; Your name is Kirsle.<br />## History: $VAR1 = &#123;<br />     'reply' =&gt; [<br />            'Your name is Kirsle.',<br />            'Kirsle, nice to meet you.',<br />            'Hi. What seems to be your problem?',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined'<br />           ],<br />     'input' =&gt; [<br />            'what is my name',<br />            'my name is kirsle',<br />            'hello bot',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined'<br />           ]<br />    &#125;;<br /><br />## Freezing Uservars ##<br />My name is Casey =&gt; Casey, nice to meet you.<br />What is my name? =&gt; Your name is Casey.<br />## History: $VAR1 = &#123;<br />     'reply' =&gt; [<br />            'Your name is Casey.',<br />            'Casey, nice to meet you.',<br />            'Your name is Kirsle.',<br />            'Kirsle, nice to meet you.',<br />            'Hi. What seems to be your problem?',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined'<br />           ],<br />     'input' =&gt; [<br />            'what is my name',<br />            'my name is casey',<br />            'what is my name',<br />            'my name is kirsle',<br />            'hello bot',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined'<br />           ]<br />    &#125;;<br /><br />## Thawing Uservars ##<br />What is my name? =&gt; Your name is Kirsle.<br />Goodbye =&gt; Please go on.<br />## History: $VAR1 = &#123;<br />     'reply' =&gt; [<br />            'Please go on.',<br />            'Your name is Kirsle.',<br />            'Your name is Kirsle.',<br />            'Kirsle, nice to meet you.',<br />            'Hi. What seems to be your problem?',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined'<br />           ],<br />     'input' =&gt; [<br />            'goodbye',<br />            'what is my name',<br />            'what is my name',<br />            'my name is kirsle',<br />            'hello bot',<br />            'undefined',<br />            'undefined',<br />            'undefined',<br />            'undefined'<br />           ]<br />    &#125;;[/code]||||
