diff --git a/README.md b/README.md index 84bd081..f873299 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You can install the package via pip: pip install vapi_python ``` -On Mac, you might need to install `brew install portaudio` to satisfy `pyaudio`'s dependency requirement. +On Mac, you might need to install `brew install portaudio` to satisfy `pyaudio`'s dependency requirement. ## Usage @@ -31,7 +31,9 @@ You can start a new call by calling the `start` method and passing an `assistant ```python vapi.start(assistant_id='your-assistant-id') ``` + or + ```python assistant = { 'firstMessage': 'Hey, how are you?', @@ -45,7 +47,21 @@ assistant = { vapi.start(assistant=assistant) ``` -The `start` method will initiate a new call. +The `start` method will initiate a new call. + +You can override existing assistant parameters or set variables with the `assistant_overrides` parameter. +Assume the first message is `Hey, {{name}} how are you?` and you want to set the value of `name` to `John`: + +```python +assistant_overrides = { + "recordingEnabled": False, + "variableValues": { + "name": "John" + } +} + +vapi.start(assistant_id='your-assistant-id', assistant_overrides=assistant_overrides) +``` You can stop the session by calling the `stop` method: @@ -80,5 +96,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` - - diff --git a/README.rst b/README.rst index f27df0f..fe0672c 100644 --- a/README.rst +++ b/README.rst @@ -75,7 +75,21 @@ or vapi.start(assistant=assistant) -The `start` method will initiate a new call. +The `start` method will initiate a new call. + +You can override existing assistant parameters or set variables with the `assistant_overrides` parameter. +Assume the first message is `Hey, {{name}} how are you?` and you want to set the value of `name` to `John`: + +.. code-block:: python + + assistant_overrides = { + "recordingEnabled": False, + "variableValues": { + "name": "John" + } + } + + vapi.start(assistant_id='your-assistant-id', assistant_overrides=assistant_overrides) You can stop the session by calling the `stop` method: diff --git a/setup.py b/setup.py index ed5e1e5..1ed5194 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,6 @@ def read_requirements(file): test_suite='tests', tests_require=test_requirements, url='https://github.com/jordan.cde/vapi_python', - version='0.1.8', + version='0.1.9', zip_safe=False, ) diff --git a/vapi_python/vapi_python.py b/vapi_python/vapi_python.py index 44fe220..e081934 100644 --- a/vapi_python/vapi_python.py +++ b/vapi_python/vapi_python.py @@ -27,12 +27,24 @@ def __init__(self, *, api_key, api_url="https://api.vapi.ai"): self.api_key = api_key self.api_url = api_url - def start(self, *, assistant_id=None, assistant=None): + def start( + self, + *, + assistant_id=None, + assistant=None, + assistants=None, + assistant_override=None, + assistant_overrides=None, + ): # Start a new call if assistant_id: - assistant = {'assistantId': assistant_id} + assistant = {'assistantId': assistant_id, 'assistantOverride': assistant_override} elif assistant: - assistant = {'assistant': assistant} + assistant = {'assistant': assistant, 'assistantOverride': assistant_override} + elif assistants: + assistant = {'assistants': assistants, 'assistantOverride': assistant_overrides, 'assistantOverrides': assistant_overrides} + else: + raise Exception("Error: No assistant specified.") call_id, web_call_url = create_web_call( self.api_url, self.api_key, assistant)