LogoLogo
Github
  • 🚀Getting Started
    • About Jugalbandi Manager
  • Introduction
    • About OpenyAI
    • What is Jugalbandi?
    • Why dive in: How will this playbook help you?
    • Importance and Relevance of Jugalbandi
    • Key Principles powering Jugalbandi
    • Demystifying Jugalbandi: What Jugalbandi isn’t?
  • Breaking Down Jugalbandi's Anatomy
    • Jugalbandi Manager: Your companion for building and managing AI services
    • Jugalbandi’s Key Services
    • Key Features for Enhancing Security and Privacy
  • Building with Jugalbandi
    • Technical Guide
      • explanations
        • JB Manager Architecture
        • Explanations
      • how-tos
        • Local Development
        • Write Your Own Bot
        • How to Guides
      • references
        • Dependencies
        • FSMOutput
        • References
        • Speech and Translation
        • Azure Storage
        • Whatsapp
        • Telegram
        • example-grievance-bot
          • Example Grievance Bots
      • tutorials
        • Tutorials
        • Quickstart
    • Getting Started
    • Local Development / Writing your own bot
    • Dependencies
    • Configuring the FSM to modify flows
    • Cost of building with Jugalbandi
    • Tips and Best Practices / FAQs (Including best practices for creating a knowledge base)
  • Use cases of Jugalbandi
    • Jugalbandi for Access to Legal Information
    • Jugalbandi for Govt. Schemes
    • Accessing Legal Services
    • Jugalbandi for Grievance Redressal
    • Climate Action with Wildlife First
    • Affordable Housing with Bandhu
    • Paralegal Services with Nyaya Mitra
    • UNESCO X Jugalbandi
  • Is Jugalbandi Manager Applicable to your Use case?
    • The versatile applications of Jugalbandi
    • Some other example use cases
  • Possibilities and Future Directions
    • Potential Technological Advancements
    • Jugalbandi Studio: Building with AI has never been more accessible
  • Community and Collaboration
    • Understanding the community-led spirit of our mission
    • Our current collaborators and community
  • Get Involved
    • How can volunteers contribute?
    • How can maintenance of the stack be open-sourced?
    • Technical Support and Contact Information
Powered by GitBook
On this page
  • Develop and Test Locally
  • Setting up Local DB
  • Data Contracts
  • API
  • Indexer
  • Steps
  • Reseting Dev Environment

Was this helpful?

Edit on GitHub
Export as PDF
  1. Building with Jugalbandi
  2. Technical Guide
  3. how-tos

Local Development

Previoushow-tosNextWrite Your Own Bot

Last updated 9 months ago

Was this helpful?

If you are new here, read everything and follow the steps the end.

Develop and Test Locally

We have written a script that makes it easy to run this on any local machine (Mac, WSL2). Only deploy the services you need. This script depends on the env values in .env-dev.

$ ./scripts/run.sh <one or more service names that you are testing>
# names of the services - api, channel, language, flow, retriver, indexer

It's important that we test the data contracts (input / output JSONs) for our service. Run the service in one window, send JSON message to Kafka via another and read the messages generated by your service in another.

# create topics (queues) on kafka
./scripts/create-topic.sh topic_name

# send message to your service
./scripts/send-message.sh topic <json>

# read messages from your service
./scripts/read-message.sh topic

Setting up Local DB

# Updating your local database
./scripts/upgrade-db.sh

# Adding an alembic migration
./scripts/create-migration.sh <description of the changes>

Connecting to database

sudo apt-get install -y postgresql-client
psql -Upostgres -hlocalhost

It will prompt for password.

  • flow - adding a user

 insert into jb_users (pid,first_name, last_name) values ('test4','a','b');
  • flow - checking state stored in the db

select * from jb_fsm_state;

Data Contracts

API

curl http://localhost:8000/callback -H 'content-type:application/json' -d '{"object": "whatsapp_business_account", "entry": [{"id": "112776635030672", "changes": [{"value": {"messaging_product": "whatsapp", "metadata": {"display_phone_number": "919711028566", "phone_number_id": "116346771524855"}, "contacts": [{"profile": {"name": "Test User"}, "wa_id": "919999999999"}], "messages": [{"from": "919999999999", "id": "wamid.HBgMOTE5ODg2Njg5NzU0FQIAEhgUM0E0RjQ2QzQyMUUxREYyODcxNjQA", "timestamp": "1705550692", "text": {"body": "Hey"}, "type": "text"}]}, "field": "messages"}]}]}'

Indexer

topic: indexer message:

'{"collection_name":"KB_Law_Files", "files":["combine.pdf", "Property Law.xlsx", "Information Technology Laws.xlsx", "Family Laws for Succession and Inheritance.xlsx", "Senior Citizens Rights.xlsx", "Motor Vehicles Act.xlsx", "Income Tax Compliance.xlsx", "Cyber Crimes.xlsx", "Disability Rights.xlsx", "Women Rights.xlsx", "Law related to SC and ST.xlsx", "Medical Termination of Pregnancy.xlsx", "Mental Health.xlsx", "Narcotics and Psycotropic Substances.xlsx", "Formation of Company and Corporate Social Responsibility.xlsx", "POCSO Act.xlsx", "SEBI Regulations.xlsx", "Legal Services in India.xlsx", "Transgender Rights.xlsx", "Farmer Rights.xlsx", "Arbitration Conciliation.xlsx", "Labour Laws.xlsx"]}'

Steps

  1. Create environment by copying .env-dev.template to .env-dev. Update the values if required. You can look at the larger list of constants in .env

  2. Bring up the service e.g. api

$ ./scripts/run.sh -e .env-dev api
  1. Make any modifications to the database

$ ./scripts/upgrade-db.sh
  1. Setup a listener to the queue

$ ./scripts/read-message.sh <topic name>
  1. Test the data contracts by sending a message to the queue or api

# For API
$ curl http://localhost:8000/callback ....

# For all
$ ./scripts/send-message.sh <topic> <JSON message>

Reseting Dev Environment

Often there are times when it's better to start from scratch.

# bring down whatever is running
$ docker compose down

# following will delete all your containers - be careful
$ docker volume ls | awk '{print $2}' | xargs docker volume rm

# if you don't want clutter, you can delete all containers
$ docker ps -a | awk '{print $1}' | xargs docker rm

See the Pydantic models

Check the database by using

lib/data_models.py
DBeaver