Skip to content

Commit

Permalink
- updated test cases names
Browse files Browse the repository at this point in the history
- Updated openai prompt
- Added capability to get raw response from the api
- Udpated schemas with required fields
- Added info logs
- updated logic to fetch config
- Updated test cases
  • Loading branch information
mayurvir committed Mar 29, 2024
1 parent 9b1708c commit 514368c
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 1,445 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
jobs:
test-lint:
name: Test
name: API tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
jobs:
test-lint:
name: Test
name: Lint checks
runs-on: ubuntu-20.04
steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
jobs:
test-lint:
name: Test
name: Unit tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
Expand Down
5 changes: 1 addition & 4 deletions config/openai.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
"SCHEMA_TRANSLATION_CONTEXT": [
{ "role": "system", "content": "Your job is to identify the endpoint, method and request body from the given schema, based on the last user input and return the extracted details in the following JSON structure : \n\n {'url':'', 'method':'', 'body':''}'"},
{ "role": "system", "content": "A typical order flow should be search > select > init > confirm."},
{ "role": "system", "content": "Auto-generate uuid wherever required and should be a valid uuid such as ."},
{ "role": "system", "content": "Use the context to identify the transaction id returned in search api response and use it in subsequent api calls."},
{ "role": "system", "content": "Use the response of search request from assistant for filling transaction_id, bpp_id, bpp_uri in the context of all calls except `search`."},
{ "role": "system", "content": "Use the response from assistant to select items from the list of items provided by the assistant."}
{ "role": "system", "content": "Use the response of search from assistant to select items from the list of items provided by the assistant."}

]
}
6 changes: 3 additions & 3 deletions controllers/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const db = new DBService();

async function process_wa_webhook(req, res) {
try {
const message = req.
body.Body
const message = req.body.Body
const sender = req.body.From
const format = req.headers['content-type'] || 'text/xml';
const raw_yn = req.body.raw_yn || false;
const twiml = new MessagingResponse();

logger.info(`Received message from ${sender}: ${message}. Response format: ${format}`)
Expand Down Expand Up @@ -43,7 +43,7 @@ async function process_wa_webhook(req, res) {
res.type('text/xml').send(twiml.toString())
}
else{
res.send(process_response.formatted)
raw_yn ? res.send(process_response.raw) : res.send(process_response.formatted)
}

} catch (error) {
Expand Down
59 changes: 4 additions & 55 deletions schemas/core_1.1.0/confirm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,6 @@ info:
security:
- SubscriberAuth: []
paths:
/init:
post:
tags:
- Beckn Provider Platform (BPP)
description: Initialize an order by providing billing and/or shipping details
requestBody:
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- init
required:
- action
message:
type: object
properties:
order:
$ref: '#/components/schemas/Order'
required:
- order
required:
- context
- message
responses:
default:
description: Acknowledgement of message received after successful validation of schema and signature
content:
application/json:
schema:
type: object
properties:
message:
type: object
properties:
ack:
allOf:
- $ref: '#/components/schemas/Ack'
- properties:
status:
enum:
- ACK
- NACK
required:
- ack
error:
$ref: '#/components/schemas/Error'
required:
- message
/confirm:
post:
tags:
Expand Down Expand Up @@ -157,6 +102,10 @@ components:
Order:
description: Describes a legal purchase order. It contains the complete details of the legal contract created between the buyer and the seller.
type: object
required:
- items
- billing
- fulfillments
properties:
id:
type: string
Expand Down
3 changes: 3 additions & 0 deletions schemas/core_1.1.0/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ components:
Order:
description: Describes a legal purchase order. It contains the complete details of the legal contract created between the buyer and the seller.
type: object
required:
- items
- billing
properties:
id:
type: string
Expand Down
2 changes: 2 additions & 0 deletions schemas/core_1.1.0/search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ components:
Descriptor:
description: Physical description of something.
type: object
required:
- name
properties:
name:
type: string
Expand Down
Loading

0 comments on commit 514368c

Please sign in to comment.