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

[Feature] Added new structure with function calling to reduce flakiness and reduce transaction time #81

Merged
merged 11 commits into from
May 3, 2024
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ models/*
package*.json
LICENSE
*.md
schemas/*
config/schemas/*
1 change: 0 additions & 1 deletion config/GPT/becknGPT_instructions.txt

This file was deleted.

64 changes: 0 additions & 64 deletions config/GPT/becknGPT_schema.yml

This file was deleted.

59 changes: 59 additions & 0 deletions config/GPT/tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export const TOOLS = [
{
type: "function",
function: {
name: "get_routes",
description: "This function should only be used if the user specifically asks to get routes between a source and destination using google maps.",
parameters: {
type: "object",
properties: {
source:{
type:"string",
description: "Source location in the format 'latitude,longitude' or 'text' from which route is to be fetched"
},
destination:{
type:"string",
description: "Destination location in the format 'latitude,longitude' or 'text' to which route is to be fetched"
}
}
}
}
},
{
type: "function",
function: {
name: "select_route",
description: "This function should only be used if the user has selected one of the routes shared by the assistant in the previous step. This function must not be used if the last response from assistant was not a list of routes between two points.",
parameters: {
type: "object",
properties: {
index:{
type:"number",
description: "Index of the selected route."
}
}
}
}
},
{
type: "function",
function: {
name: "perform_beckn_action",
description: "If the user has indicated to search/find a product, select an item or add to cart, initialize an order or confirm on order.",
parameters: {
type: "object",
properties: {
action : {
type: "string",
description: "Action for which payload is to be fetched",
enum: ["search", "select", "init", "confirm"]
},
instruction: {
type: "string",
description: "Complete instructions about the action to be performed."
}
}
}
}
}
];
4 changes: 4 additions & 0 deletions config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export const BECKN_STATUS_CALL = {
export const EMPTY_BECKN_TRANSACTION = {
id: false,
responses: {
search: {},
select: {},
init: {},
confirm: {},
on_search: {},
on_select: {},
on_init: {},
Expand Down
67 changes: 12 additions & 55 deletions config/language.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
{
"FULFILLMENT_STATUS_CODES": {
"order-picked-up": {
"message": "Your order's on its way!"
},
"order-on-the-way": {
"message": "Hang tight! Your order's cruising over to you."
},
"order-delivered": {
"message": "Package alert! Your order's been delivered."
},
"ticket-issued": {
"message": "All set! Your ticket's ready to go."
},
"ticket-validated": {
"message": "You're all good! Your ticket's been validated."
},
"charging-started": {
"message": "Juice up! Your charging session's begun."
},
"charging-stopped": {
"message": "Heads up! Your charging session's been paused."
},
"charger-not-working": {
"message": "Uh-oh, looks like there's a glitch with your charger ⚡😓. Need help finding another spot? 📍🔍"
},
"charging-completed": {
"message": "Charged and ready! Your battery's full."
},
"checked-in": {
"message": "Welcome! You've successfully checked in."
},
"checked-out": {
"message": "Safe travels! You've checked out."
}
"order-picked-up": "Your order's on its way!",
"order-on-the-way": "Hang tight! Your order's cruising over to you.",
"order-delivered": "Package alert! Your order's been delivered.",
"ticket-issued": "All set! Your ticket's ready to go.",
"ticket-validated": "You're all good! Your ticket's been validated.",
"charging-started": "Juice up! Your charging session's begun.",
"charging-stopped": "Heads up! Your charging session's been paused.",
"charger-not-working": "Uh-oh, looks like there's a glitch with your charger ⚡😓. Need help finding another spot? 📍🔍",
"charging-completed": "Charged and ready! Your battery's full.",
"checked-in": "Welcome! You've successfully checked in.",
"checked-out": "Safe travels! You've checked out."
},
"ALL_MESSAGES": {
"session_cleared": "Your session has been cleared! You're all set to start a new one.",
Expand All @@ -49,26 +27,5 @@
"missing_source": "Mind sharing the starting point for your journey?",
"missing_destination": "Could you let us know your destination?",
"route_list_description": "Here are some route options for you. Which one do you prefer?"
},
"TEST_MESSAGES_USER": [
"---Days before the travel---",
"Adam: Hey Alfred, you around?",
"Adam: I’m hitting Yellowstone National Park on April 12th for 2 days. Got any places to stay?",
"Adam: First one sounds awesome. Lets go with that",
"Adam: You got it - John A. Smith, [email protected], (555) 123-4567.",
"Adam: Sure, lets confirm!",

"---On the date of travel---",
"Adam: Alfred, can you find the best route to Yellowstone national park from Denver?",
"Adam: lets go with Route 1",
"Adam: Can you find ev chargers on the route?",
"Adam: Lets go with Tesla Supercharger",


"---Charging stopped due to an error---",
"Adam: Yeah, let’s find another charger",
"Adam: Let’s go with the second one.",
"Adam: Sure thing, lets book it",
"Adam: Yeah, let’s do it."
]
}
}
17 changes: 0 additions & 17 deletions config/openai.json

This file was deleted.

4 changes: 2 additions & 2 deletions config/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"rules": [
"item.descriptor should not be used in search intent for this domain",
"search should have fulfillment for this domain. fulfillment should only contain location for this domain.",
"fulfillment should contain only 1 stop for this domain",
"fulfillment must have only 1 stop for this domain",
"If a route polygon has been shared, fulfillment.stops[i].location should have the polygon field."
]
},
"hospitality": {
"rules": [
"item.descriptor should not be used in search intent for this domain",
"item must not be used in search intent for this domain",
"search must have two stops for this domain.",
"Supported stop.type : check-in, check-out",
"fulfillment.stops[i].time should be an object and contain timestamp",
Expand Down
60 changes: 60 additions & 0 deletions config/schemas/confirm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export default {
type: "object",
properties: {
order: {
type: "object",
description: "Describes a legal purchase order. It contains the complete details of the legal contract created between the buyer and the seller.",
properties: {
fulfillments: {
description: "The fulfillments involved in completing this order.",
type: "array",
items: {
type: "object",
description: "Describes how a an order will be rendered/fulfilled to the end-customer.",
properties: {
id: {
type: "string",
description: "Unique reference ID to the fulfillment of an order based on fulfillments provided in the init response."
},
customer: {
type: "object",
description: "The person that will ultimately receive the order",
properties: {
person: {
type: "object",
description: " Describes a person as any individual ",
properties: {
name: {
type: "string",
description: "Name of the person"
}
},
required: ["name"]
},
contact: {
type: "object",
description: "Describes the contact information of an entity",
properties: {
phone: {
type: "string",
description: "Phone number of the contact person"
},
email: {
type: "string",
description: "Email address of the contact person"
}
},
required: ["phone", "email"]
}
},
required: ["person", "contact"]
}
},
required: ["customer"]
}
}
},
required: ["items", "billing", "fulfillments"]
}
}
}
2 changes: 1 addition & 1 deletion schemas/jsons/context.js → config/schemas/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
properties: {
action:{
type:"string",
description: "action that the user wants to perform. This should be one of th actions defined by supported actions. If its not one of teh actions, its value should be null."
description: "action that the user wants to perform. This should be one of th actions defined by supported actions. If its not one of the actions, its value should be null."
},
transaction_id:{
type:"string",
Expand Down
31 changes: 31 additions & 0 deletions config/schemas/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default {
type: "object",
properties: {
order: {
type: "object",
description: "Describes a legal purchase order. It contains the complete details of the legal contract created between the buyer and the seller.",
properties: {
billing: {
description: "Describes the billing details of an entity.<br>This has properties like name,organization,address,email,phone,time,tax_number, created_at,updated_at",
type: "object",
properties: {
name: {
type: "string",
description: "Name of the billable entity"
},
email: {
type: "string",
description: "Email address where the bill is sent to"
},
phone: {
type: "string",
description: "Phone number of the billable entity"
}
},
required: ["name", "email", "phone"]
}
},
required: ["items", "billing"]
}
}
}
4 changes: 2 additions & 2 deletions schemas/jsons/search.js → config/schemas/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ export default {
},
polygon: {
type: "string",
description: "This describes the route on which the item needs to be searched. This should be used if the request is to search along a route"
description: "This describes the route on which the item needs to be searched. This should be used if the instruction is to search along a route and there is a selelected route in user profile."
}
},
required: ['gps']
required: []
},
time: {
type: "object",
Expand Down
Loading
Loading