Skip to content

Commit

Permalink
New skipUpdate Deployment Option With Docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Jun 5, 2024
1 parent e25638f commit cb0da5f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/experts/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cb0da5f

Please sign in to comment.