From cb0da5f76cab4be570589b7aa675cd484a57061b Mon Sep 17 00:00:00 2001 From: Ken Collins Date: Tue, 4 Jun 2024 23:14:59 -0400 Subject: [PATCH] New `skipUpdate` Deployment Option With Docs. --- CHANGELOG.md | 6 +++++- README.md | 20 +++++++++++++++++++- src/experts/assistant.js | 4 +++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a7fd52..ac040a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ See this http://keepachangelog.com link for information on how we want this docu **Major Assistant & Tool Constructor Changes** -Both Assistant & Tool have removed their (name, description, instructions) ordinal parameters in favor a single options object. +Both Assistant & Tool have removed their (name, description, instructions) ordinal parameters in favor a single options object. Now, the constructor signature is: ```javascript // Using Assistant.create() factory. @@ -31,6 +31,10 @@ class MyAssistant extends Assistant { }) ``` +## Added + +A new `skipUpdate` option to use for deployments such as staging where it might be desirable to use the Assistants remote resource instructions or other properties. + ## v1.1.0 ### Changed diff --git a/README.md b/README.md index 9039864..5599817 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,8 @@ const assistant = Assistant.create({ }); ``` -Creating assistants without an `id` parameter will always create a new assistant. +> [!IMPORTANT] +> Creating assistants without an `id` parameter will always create a new assistant. See our [deployment](#deployment) section for more information. ### Simple Ask Interface @@ -398,6 +399,23 @@ class MyAssistant extends Assistant { } ``` +## Deployments + +In order for an Assistant to be deployed to a production environment, we recommend the following configurations. First, create or find your assistant's id. The string will be in the format of `asst_abc123`. Then pass this id into the Assistant's or Tools's constructor. This will ensure that the same assistant is used across all deployments. + +```javascript +class MyAssistant extends Assistant { + constructor() { + super({ + // ... + id: process.env.MY_ASSISTANT_ID + }); + } +} +``` + +Once an Assistant or Tool is found by id, any remote configurations that are different present are overwritten by the local configurations. If required, for example in a staging environment, you can bypass this behavior by setting the `skipUpdate` option to `true`. + ## Environment Variables ### Global Model Configuration diff --git a/src/experts/assistant.js b/src/experts/assistant.js index 4d48814..ec6d33d 100644 --- a/src/experts/assistant.js +++ b/src/experts/assistant.js @@ -44,6 +44,8 @@ class Assistant { this._metadata = options.metadata; this.response_format = options.response_format || "auto"; this.run_options = options.run_options || {}; + this.skipUpdate = + options.skipUpdate !== undefined ? options.skipUpdate : false; this.emitter = new EventEmitter2({ maxListeners: 0, newListener: true }); this.emitter.on("newListener", this.#newListener.bind(this)); } @@ -298,7 +300,7 @@ class Assistant { } async #update(assistant) { - if (!assistant) return; + if (!assistant || this.skipUpdate) return; await openai.beta.assistants.update(assistant.id, { model: this.model, name: this.nameOrID,