$request.generator. is not resolved in conditional response

I am building a well-being chatbot and when I match free-form input with @sys.any I want to check with a generator if user input contains any indication of self harm.

Here is my prompt:

"Act a binary classifier and reply "self_harm" or "no_self_harm". Reply "no_self_harm" if there is no indication of self-harm and "self_harm" if you detect indication of self-harm. Does $session contain any self-harm or suicidal intention?"

I store the response in $request.generative.self_harm.

All works great, however when I use conditional response, the condition doesn't work, as if $request.generator.self_harm is not defined or something, I tried all possible things.  What am I doing wrong?

Here is conditional response that I use:

if $request.generative.self_harm = "no_self_harm"
NO, |$request.generative.self_harm|
else
YES, |$request.generative.self_harm|
endif

It prints: YES, |no_self_harm|

This condition works:

if "no_self_harm" = "no_self_harm"
NO
else
YES
endif

Solved Solved
0 7 131
1 ACCEPTED SOLUTION

Hello, xavidop! Thank you for all your replies, I was finally able to figure out what I was doing wrong.

First of all, when I created generator I have saved the variable to $request.generative. and there is no need to do so, as the value is just added into the session parameters, I found it out by looking at original response. I think it's confusing, that by default a $request.generative is suggested, see the image:

Screenshot 2024-05-08 at 14.24.15.png

I just removed $request.generative and replaced it with normal name llm_output which later I could access through $session.params.llm_output.

Then I had some problems while creating conditional response because I used quotes and there is no need to to so. The following conditional response worked well for me:

if $session.params.llm_output : self_harm

yes!

elif $session.params.llm_output : no_self_harm

no

endif

View solution in original post

7 REPLIES 7

you will need to set that entity as mandatory in the form filling process: https://www.youtube.com/watch?v=Sa85lRuCEIs&themeRefresh=1

Thank you for the quick response, I've watched this video, I don't see how this is going to help. The value of $request.generative. doesn't seem to work in conditional responses or in routes as well. I tried to set it as parameter as well, I can print $request.generative. out but I don't know how to perform any conditional operations with it. Please help.

so the way that it helps is basically that if you set the parameter as mandatory, it will first try to first, get the parameter value by asking the user, then generator will be called. at that time you can set the paramater to the generator. with this approach you do not need any transition

Screenshot 2024-05-07 at 16.46.39.pngThank you for your reply, I tried that, maybe the image will help to explain what I am trying to accomplish. The response should have been "no_self_harm", great.

Could you please clarify, it would be great if you could provide an example, how can I give different response to the user based on the value of $request.generative. it doesn't seem to work in the conditional statements for some reason.

mmm, okay

try something like this:

xavidop_0-1715101451589.png

transition when the param status is final and call the generator in the new page

Hello, xavidop! Thank you for all your replies, I was finally able to figure out what I was doing wrong.

First of all, when I created generator I have saved the variable to $request.generative. and there is no need to do so, as the value is just added into the session parameters, I found it out by looking at original response. I think it's confusing, that by default a $request.generative is suggested, see the image:

Screenshot 2024-05-08 at 14.24.15.png

I just removed $request.generative and replaced it with normal name llm_output which later I could access through $session.params.llm_output.

Then I had some problems while creating conditional response because I used quotes and there is no need to to so. The following conditional response worked well for me:

if $session.params.llm_output : self_harm

yes!

elif $session.params.llm_output : no_self_harm

no

endif

thats awesome! great findings!