-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
✨ Access nlu properties in CoreRequest #1271
✨ Access nlu properties in CoreRequest #1271
Conversation
merge upstream
Oh, I was just wondering, would it make sense to change |
@@ -18,8 +25,12 @@ export class CoreRequest extends JovoRequest { | |||
return this.locale; | |||
} | |||
|
|||
getInput(): JovoInput { | |||
return new JovoInputBuilder(super.getInput()).set('nlu', this.input?.nlu).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain a bit further what this is doing here? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the idea behind this was that you can easily extend this.$input
by allowing inheriting request classes to build upon the JovoInputBuilder
. Here we get the input built in JovoRequest
and add the nlu
property, so you can access this.$input.nlu
in the handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I'm still not sure if I get it, to be honest. A bit confused why specifically nlu
needs to be set in this method and why we're not setting any other property. What is a use case here?
Could the reasoning be commented or documented somewhere? i think otherwise it could happen that we don't know why this is there if we look at the code in a few months
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so I guess this could be seen as being redundant, the original idea was to access the nlu properties in the handler, because if intents/entities were set in input.nlu
, you had no way of accessing it with this.$input
, but since this PR allows accessing them through getIntent()
and getEntities()
it can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rubenaeg How do we access other properties that we might add to $input.nlu?
This could be an output object with messages if the SLU/NLU provides dialog management or messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I now removed the code, but you can see in the code above how you could add properties to the input object that is returned by getInput()
. @jankoenig do you need more input on this PR? I can write some documentation if you'd like, something like "Extending the Input object", where I could also cover ambient declarations...
50ad568
to
c7adde6
Compare
Proposed Changes
This PR modifies the
JovoInputBuilder
to accept an input object, analogous toJovoInput
. This allows inheriting request classes to easily extend thegetInput()
function, as seen inCoreRequest
. Furthermore,CoreRequest.prototype.getIntents()
andCoreRequest.prototype.getEntities()
allow access to properties ininput.nlu
.Types of Changes
Checklist