Skip to content

Commit

Permalink
Merge pull request #90 from bolna-ai/local_setup_updates_v1
Browse files Browse the repository at this point in the history
updating with latest local setup
  • Loading branch information
prateeksachan authored Mar 12, 2024
2 parents 3198e6e + d2acfde commit c8a0d14
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 398 deletions.
79 changes: 20 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,92 +33,53 @@ https://github.com/bolna-ai/bolna/assets/1313096/2237f64f-1c5b-4723-b7e7-d11466e
## Components
Bolna helps you create AI Voice Agents which can be instructed to do tasks beginning with:

1. Initiating a phone call using telephony providers like `Twilio`, etc.
1. Initiating a phone call using telephony providers like `Twilio`, `Exotel`, etc.
2. Transcribing the conversations using `Deepgram`, etc.
3. Using LLMs like `OpenAI`, etc to handle conversations
4. Synthesizing LLM responses back to telephony using `AWS Polly`, `XTTS`, etc.
3. Using LLMs like `OpenAI`, `Llama`, `Cohere`, `Mistral`, etc to handle conversations
4. Synthesizing LLM responses back to telephony using `AWS Polly`, `XTTS`, `ElevenLabs`, `Deepgram` etc.
5. Instructing the Agent to perform tasks like sending emails, text messages, booking calendar after the conversation has ended

Refer to the [docs](https://docs.bolna.dev) for a deepdive into all supported providers.


## Agents
This repo contains the following types of agents in the `agents/agent_types` directory which can be used to create conversational applications:

1. `contextual_conversational_agent`: LLM-based free flow agent
2. `graph_based_conversational_agent`: LLM-based agent with classification
3. `extraction_agent`: Currently WIP. [Feel free to contribute and open a PR](https://github.com/bolna-ai/bolna/compare)


## Local setup
A basic local setup uses Twilio for telephony. We have dockerized the setup in `local_setup/`. One will need to populate an environment `.env` file from `.env.sample`.
A basic local setup uses `Twilio` for telephony. We have dockerized the setup in `local_setup/`. One will need to populate an environment `.env` file from `.env.sample`.

The setup consists of four containers:

1. Twilio web server: for initiating the calls one will need to set up a [Twilio account]([https://www.twilio.com/docs/usage/tutorials/how-to-use-your-free-trial-account](https://www.twilio.com/docs/messaging/guides/how-to-use-your-free-trial-account))
2. Bolna server: for creating and handling agents
3. `ngrok`: for tunneling. One will need to add the `authtoken` to `ngrok-config.yml`
4. `redis`: for persisting agents & users contextual data
4. `redis`: for persisting agents & prompt data

Running `docker-compose up --build` will use the `.env` as the environment file and the `agent_data` to start all containers.
Running `docker-compose up --build` will use the `.env` as the environment file.

Once the docker containers are up, you can now start to create your agents and instruct them to initiate calls.


## Agent Examples
The repo contains examples as a reference for creating for application agents in the `agent_data` directory:

1. `airbnb_job`: A `streaming` `conversation` agent where the agent screens potential candidates for a job at AirBnB
2. `sorting_hat`: A `preprocessed` `conversation` agent which acts as a Sorting Hat for Hogwarts
3. `yc_screening`: A `streaming` `conversation` agent which acts as a Y Combinator partner asking questions around the idea/startup
4. `indian_elections_vernacular`: A `streaming` `conversation` agent which asks people for their outlook towards Indian elections in Hindi language
5. `sample_agent`: A boilerplate sample agent to start building your own agent!


## Anatomy of an agent
All agents are read from the `agent_data` directory. We have provided some samples for getting started. There's a dashboard coming up [still in WIP] which will easily facilitate towards creating agents.

General structure of the agents:

your-awesome-agent-name
├── conversation_details.json # Compiled prompt
└── users.json # List of users that the call would be made to

| Agent type | `streaming` agent | `preprocessed` agent |
|---------------|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Introduction | A streaming agent will work like a free-flow conversation following the prompt | Apart from following the prompt, a preprocessed agent will have all responses <br/>from the agent preprocessed in the form of audio which will be streamed <br/>as per the classification of human's response |
| Prompt | Required (defined in `conversation_details.json`) | Required (defined in `conversation_details.json`) |
| Preprocessing | Not required | Required (using `scripts/preprocessed.py`) |

## Creating your agent and invoking calls
Once you have the above docker setup and running, you can create agents and initiate calls.
1. Refer to the official [`Agent` API](https://docs.bolna.dev/api-reference/agent/create) to create an agent
2. Initiate a call via API similar to [`Call` API](https://docs.bolna.dev/api-reference/calls/make) to receive a call

> [!note]
> Currently, the `users.json` has the following user attributes which gets substituted in the prompt to make it customized for the call. More to be added soon!
> - first_name
> - last_name
> - honorific
>
>
>
> For instance, in the case of a preprocessed agent, the initial intro could be customized to have the user's name.
>
> Even the prompt could be customized to fill in user contextual details from users.json. For example, [{first_name} defined in prompt](https://github.com/bolna-ai/bolna/blob/master/agent_data/airbnb_job/conversation_details.json#L3) and [prompt intro](https://github.com/bolna-ai/bolna/blob/master/agent_data/sorting_hat/conversation_details.json#L10)

## Using your own providers
You can populate the `.env` file to use your own keys for providers.
<details>

## Setting up your agent
1. Create a directory under `agent_data` directory with the name for your agent
2. Create your prompt and save in a file called `conversation_details.json` using the example provided
3. Optional: In case if you are creating a `preprocessed` agent, generate the audio data used by using the script `scripts/preprocess.py`
<summary>LLM Providers</summary>

#### You can add a header

## Creating your agent and invoking calls
1. At this point, the docker containers should be up and running
2. Your agent prompt should be defined in the `agent_data/` directory with `conversation_details.json` with the user list in `users.json`
3. Create your agent using the [Bolna Create Agent API](https://docs.bolna.dev/api-reference/endpoint/create). An agent will get created with an `agent_id`
4. Instruct the agent to initiate call to users via `scripts/initiate_agent_call.py <agent_name> <agent_id>`
```ruby
puts "Hello World"
```
</details>


## Open-source v/s Paid
Though the repository is completely open source, you can connect with us if interested in managed offerings or more customized solutions.
Though the repository is completely open source, you can connect with us if interested in managed hosted offerings or more customized solutions.

<a href="https://calendly.com/bolna/30min"><img alt="Schedule a meeting" src="https://cdn.cookielaw.org/logos/122ecfc3-4694-42f1-863f-2db42d1b1e68/0bcbbcf4-9b83-4684-ba59-bc913c0d5905/c21bea90-f4f1-43d1-8118-8938bbb27a9d/logo.png" /></a>

Expand Down
5 changes: 0 additions & 5 deletions agent_data/airbnb_job/conversation_details.json

This file was deleted.

7 changes: 0 additions & 7 deletions agent_data/airbnb_job/users.json

This file was deleted.

105 changes: 0 additions & 105 deletions agent_data/indian_elections_vernacular/conversation_details.json

This file was deleted.

7 changes: 0 additions & 7 deletions agent_data/indian_elections_vernacular/users.json

This file was deleted.

5 changes: 0 additions & 5 deletions agent_data/sample_agent/conversaton_details.json.sample

This file was deleted.

7 changes: 0 additions & 7 deletions agent_data/sample_agent/users.json.sample

This file was deleted.

30 changes: 0 additions & 30 deletions agent_data/sorting_hat/conversation_details.json

This file was deleted.

7 changes: 0 additions & 7 deletions agent_data/sorting_hat/users.json

This file was deleted.

2 changes: 1 addition & 1 deletion local_setup/telephony_server/twilio_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def close_redis_connection():
await redis_client.aclose()


@app.post('/make_call')
@app.post('/call')
async def make_call(request: Request):
try:
call_details = await request.json()
Expand Down
46 changes: 0 additions & 46 deletions scripts/initiate_agent_call.py

This file was deleted.

Loading

0 comments on commit c8a0d14

Please sign in to comment.