-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add a simple quantity to cart item tracking #8
base: master
Are you sure you want to change the base?
Conversation
Imported words-to-num package for conversions Decided to accept 'the', 'a' and 'an' as synonymous with 'one' Added validation for QUANTITY slot Updated abilities to parse and save cart with updated quantities
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.
Please see inline comments for clarifications.
Nonblocking review as I am still updating myself with the codebase.
name: 'None', | ||
traces: [ | ||
{ | ||
slotName: 'END_OF_ORDER' | ||
slotName: 'AFFIRMATIVE' |
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.
What are examples of the NLU model returning AFFIRMATIVE
? Trying to understand why this is mapping to "None" ability.
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.
There was a subtle difference between Michael's NLU and Arman's -- for single-word utterances last week, such as "done", Michael's would return intent:"None", entity:"END_OF_ORDER", and Arman's returned intent:"None", entity:"AFFIRMATIVE". Your question is valid though
}, | ||
{ | ||
name: 'TARGET', | ||
query: () => { return 'What item would you like to target?' } | ||
query: () => { return 'What item would you like to replace?' } |
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.
I know this was existing and for uniformity we should keep this..
but just an fyi short hand tip:
`query: () => 'What item would you like to replace?'
if (productQuantity > 0 || (existingProduct && productQuantity + existingProduct.quantity > 0)) { | ||
retProducts = [ | ||
...remainingProducts, | ||
{ name: productName, quantity: (existingProduct ? existingProduct.quantity + productQuantity : productQuantity) } |
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.
This will not update the product in place. The newly "updated" product will be added onto the array at the end of the array. Just making sure this is the desired result.
Yeah, not updating in place was my goal – to always create a new object rather than mutate the existing. Was my attempt to ensure storage.save acts on a new obj.
Dan
Microsoft > Commercial Software Engineering (CSE)
From: Kevin Leung <[email protected]>
Sent: Friday, March 29, 2019 8:50 AM
To: conversational-pipeline/reusable-pipeline <[email protected]>
Cc: Dan Balma <[email protected]>; Author <[email protected]>
Subject: Re: [conversational-pipeline/reusable-pipeline] Add a simple quantity to cart item tracking (#8)
@KSLHacks commented on this pull request.
________________________________
In bot/src/abilities.ts<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fconversational-pipeline%2Freusable-pipeline%2Fpull%2F8%23discussion_r270470041&data=02%7C01%7Cdbalma%40microsoft.com%7C44a25e48bc804e51916808d6b45e3e16%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636894714197517263&sdata=0x2Zb5D3RaFEWojpCiAjLHmew5nY7yNuegAj0N5rcq4%3D&reserved=0>:
@@ -18,6 +22,31 @@ export const getDefaultOrderState = (): OrderState => {
}
}
+const updateProducts =
+ (prevProducts: Product[], productName: string, productQuantity: number): Product[] => {
+ // find existing product, if present
+ const existingProduct = prevProducts.find(x => x.name === productName)
+
+ // remove existing from array
+ const remainingProducts = prevProducts.filter((x: Product) => x.name !== productName)
+
+ let retProducts
+
+ // check if any Product with productName will still be in cart
+ if (productQuantity > 0 || (existingProduct && productQuantity + existingProduct.quantity > 0)) {
+ retProducts = [
+ ...remainingProducts,
+ { name: productName, quantity: (existingProduct ? existingProduct.quantity + productQuantity : productQuantity) }
This will not update the product in place. The newly "updated" product will be added onto the array at the end of the array. Just making sure this is the desired result.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fconversational-pipeline%2Freusable-pipeline%2Fpull%2F8%23pullrequestreview-220619912&data=02%7C01%7Cdbalma%40microsoft.com%7C44a25e48bc804e51916808d6b45e3e16%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636894714197517263&sdata=lvkTVxTfHO3Vu8Euhm9o4DgeJY9OpUfsnD2Wm62ow3w%3D&reserved=0>, or mute the thread<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAmh0O-CLbDn6wMf4qP5fPAZNSwLAIU3Yks5vbjY5gaJpZM4cARxm&data=02%7C01%7Cdbalma%40microsoft.com%7C44a25e48bc804e51916808d6b45e3e16%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636894714197527259&sdata=jwrTfesA%2BScTlFvR6az1549yGLukxhM0FKjk4h0oPCE%3D&reserved=0>.
|
Track a simple quantity, as string value, for items in the cart.