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

Conversation

mayurvir
Copy link
Contributor

@mayurvir mayurvir commented Apr 16, 2024

Description

Note: This is a slightly bigger PR so please raise as many questions as possible.

This PR, changes the way a beck transaction is identified and performed. It adds a few more improvements such as improved transaction time from ~2 minutes to under 1 min., added retries on failed responses and code cleanup.

Old flow : identify action > (If beckn action) > get context > get message > call api > compress response > format response

New flow : get response or perform action > perform actions > repeat

Features covered

  • Added function calling as a first step to identify if the given use input is a general query or a request to initiate one of the actions. Supported actions as of now are :
    • get_routes
    • select_route
    • perform_beckn_action

These actions are configured under config/GPT/tools.js. More actions can be added to this if required.

  • Added retries to performing a beckn action till a non-empty response is achieved. This is to impove reliability
  • Improved server logs for better visibility on whats going on behind the scenes
  • With the new structure in place, the average response time for each beckn action has come down to below one minute with less number of token usage
  • Code cleanup : removed unused files and test cases
  • improved test cases

Screenshots/recordings

simple_booking.mp4
search_along_a_route.mp4

Testing

Testing with the whatsapp agent

Try it out yourself by interacting with the agent directly:
https://wa.me/+919335513882

Testing locally

  1. Setup the code locally and run your service. The instructions are given in the README.md file
  2. Once you have the server running at http://localhost:3001, use the following commands to send messages to the agent to receive responses:
curl --location 'http://localhost:3001/webhook' \
--header 'Content-Type: application/json' \
--data '{
    "From": "<YOUR_PHONE_NUMBER>",
    "Body": "I’m hitting Yellowstone National Park on April 12th for 2 days. Can you find some places to stay?"
}'

Self checks

  • Code follows coding style guidelines.
  • All tests pass successfully.
  • No new linting errors or warnings.
  • Documentation is updated, if necessary.
  • Dependencies are updated, if required.
  • There are no merge conflicts.

Reviewer Suggestions

This PR brings a new structure to the agent to improve reliability and speed. A few things may not work from the older version such as :

  1. Static images are not sent
  2. It may not ask for billing details while initiating the order
  3. Status messages while processing a beckn action
  4. clearall cheatcode is not working
  5. Exceptions have not been tested as its no longer storing the orders

All of these pieces need to be added. Issues will be created for each one of them soon.

@mayurvir mayurvir marked this pull request as draft April 16, 2024 19:22
Copy link
Contributor Author

@mayurvir mayurvir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all the changes.

@mayurvir mayurvir self-assigned this Apr 17, 2024
@mayurvir mayurvir added the enhancement New feature or request label Apr 17, 2024
@mayurvir mayurvir marked this pull request as ready for review April 17, 2024 09:34
@mayurvir mayurvir merged commit ccf24c5 into main May 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant