GeezerVison is showing github.com — Update Python SDK to support assistant overrides (#6) · VapiAI/client-sdk-python@1ab8345
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: README.md +18-4Lines changed: 18 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ You can install the package via pip: | 10 | 10 | pip install vapi_python | 11 | 11 | ``` | 12 | 12 |
| 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. | 14 | 14 |
| 15 | 15 | ## Usage | 16 | 16 |
| @@ -31,7 +31,9 @@ You can start a new call by calling the `start` method and passing an `assistant | 31 | 31 | ```python | 32 | 32 | vapi.start(assistant_id='your-assistant-id') | 33 | 33 | ``` | | 34 | + | 34 | 35 | or | | 36 | + | 35 | 37 | ```python | 36 | 38 | assistant = { | 37 | 39 | 'firstMessage': 'Hey, how are you?', | @@ -45,7 +47,21 @@ assistant = { | 45 | 47 | vapi.start(assistant=assistant) | 46 | 48 | ``` | 47 | 49 |
| 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 | +``` | 49 | 65 |
| 50 | 66 | You can stop the session by calling the `stop` method: | 51 | 67 |
| @@ -80,5 +96,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 80 | 96 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 81 | 97 | SOFTWARE. | 82 | 98 | ``` | 83 | | - | 84 | | - | |
Collapse file Copy file name to clipboardExpand all lines: README.rst +15-1Lines changed: 15 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 75 | 75 |
| 76 | 76 | vapi.start(assistant=assistant) | 77 | 77 |
| 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) | 79 | 93 |
| 80 | 94 | You can stop the session by calling the `stop` method: | 81 | 95 |
| |
Collapse file Copy file name to clipboardExpand all lines: setup.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,6 +49,6 @@ def read_requirements(file): | 49 | 49 | test_suite='tests', | 50 | 50 | tests_require=test_requirements, | 51 | 51 | url='https://github.com/jordan.cde/vapi_python', | 52 | | - version='0.1.8', | | 52 | + version='0.1.9', | 53 | 53 | zip_safe=False, | 54 | 54 | ) |
Collapse file Copy file name to clipboardExpand all lines: vapi_python/vapi_python.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,12 +27,12 @@ def __init__(self, *, api_key, api_url="https://api.vapi.ai"): | 27 | 27 | self.api_key = api_key | 28 | 28 | self.api_url = api_url | 29 | 29 |
| 30 | | - def start(self, *, assistant_id=None, assistant=None): | | 30 | + def start(self, *, assistant_id=None, assistant=None, assistant_overrides=None): | 31 | 31 | # Start a new call | 32 | 32 | if assistant_id: | 33 | | - assistant = {'assistantId': assistant_id} | | 33 | + assistant = {'assistantId': assistant_id, 'assistantOverrides': assistant_overrides} | 34 | 34 | elif assistant: | 35 | | - assistant = {'assistant': assistant} | | 35 | + assistant = {'assistant': assistant, 'assistantOverrides': assistant_overrides} | 36 | 36 |
| 37 | 37 | call_id, web_call_url = create_web_call( | 38 | 38 | self.api_url, self.api_key, assistant) | |
|