Skip to content

Commit 1ab8345

Browse files
authored
Update Python SDK to support assistant overrides (#6)
- Bump version to 0.1.9 - Add docs for assistant_overrides field - Add assistant_overrides to start
1 parent 774cdca commit 1ab8345

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can install the package via pip:
1010
pip install vapi_python
1111
```
1212

13-
On Mac, you might need to install `brew install portaudio` to satisfy `pyaudio`'s dependency requirement.
13+
On Mac, you might need to install `brew install portaudio` to satisfy `pyaudio`'s dependency requirement.
1414

1515
## Usage
1616

@@ -31,7 +31,9 @@ You can start a new call by calling the `start` method and passing an `assistant
3131
```python
3232
vapi.start(assistant_id='your-assistant-id')
3333
```
34+
3435
or
36+
3537
```python
3638
assistant = {
3739
'firstMessage': 'Hey, how are you?',
@@ -45,7 +47,21 @@ assistant = {
4547
vapi.start(assistant=assistant)
4648
```
4749

48-
The `start` method will initiate a new call.
50+
The `start` method will initiate a new call.
51+
52+
You can override existing assistant parameters or set variables with the `assistant_overrides` parameter.
53+
Assume the first message is `Hey, {{name}} how are you?` and you want to set the value of `name` to `John`:
54+
55+
```python
56+
assistant_overrides = {
57+
"recordingEnabled": False,
58+
"variableValues": {
59+
"name": "John"
60+
}
61+
}
62+
63+
vapi.start(assistant_id='your-assistant-id', assistant_overrides=assistant_overrides)
64+
```
4965

5066
You can stop the session by calling the `stop` method:
5167

@@ -80,5 +96,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8096
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8197
SOFTWARE.
8298
```
83-
84-

README.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,21 @@ or
7575
7676
vapi.start(assistant=assistant)
7777
78-
The `start` method will initiate a new call.
78+
The `start` method will initiate a new call.
79+
80+
You can override existing assistant parameters or set variables with the `assistant_overrides` parameter.
81+
Assume the first message is `Hey, {{name}} how are you?` and you want to set the value of `name` to `John`:
82+
83+
.. code-block:: python
84+
85+
assistant_overrides = {
86+
"recordingEnabled": False,
87+
"variableValues": {
88+
"name": "John"
89+
}
90+
}
91+
92+
vapi.start(assistant_id='your-assistant-id', assistant_overrides=assistant_overrides)
7993
8094
You can stop the session by calling the `stop` method:
8195

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def read_requirements(file):
4949
test_suite='tests',
5050
tests_require=test_requirements,
5151
url='https://github.com/jordan.cde/vapi_python',
52-
version='0.1.8',
52+
version='0.1.9',
5353
zip_safe=False,
5454
)

vapi_python/vapi_python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def __init__(self, *, api_key, api_url="https://api.vapi.ai"):
2727
self.api_key = api_key
2828
self.api_url = api_url
2929

30-
def start(self, *, assistant_id=None, assistant=None):
30+
def start(self, *, assistant_id=None, assistant=None, assistant_overrides=None):
3131
# Start a new call
3232
if assistant_id:
33-
assistant = {'assistantId': assistant_id}
33+
assistant = {'assistantId': assistant_id, 'assistantOverrides': assistant_overrides}
3434
elif assistant:
35-
assistant = {'assistant': assistant}
35+
assistant = {'assistant': assistant, 'assistantOverrides': assistant_overrides}
3636

3737
call_id, web_call_url = create_web_call(
3838
self.api_url, self.api_key, assistant)

0 commit comments

Comments
 (0)