Skip to content

Commit

Permalink
add model and embedding customization on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 5, 2024
1 parent 647abf2 commit 7a4e847
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ const runtime = new BgentRuntime({
evaluators: [
/* your custom evaluators */
],
model: "gpt-3.5-turbo", // whatever model you want to use
embeddingModel: "text-embedding-3-large", // whatever model you want to use
});
```

Expand Down
9 changes: 9 additions & 0 deletions docs/docs/classes/BgentRuntime.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Creates an instance of BgentRuntime.
| `opts` | `Object` | The options for configuring the BgentRuntime. |
| `opts.actions?` | [`Action`](../interfaces/Action.md)[] | Optional custom actions. |
| `opts.debugMode?` | `boolean` | If true, debug messages will be logged. |
| `opts.embeddingModel?` | `string` | The model to use for embedding. |
| `opts.evaluators?` | [`Evaluator`](../interfaces/Evaluator.md)[] | Optional custom evaluators. |
| `opts.model?` | `string` | The model to use for completion. |
| `opts.providers?` | [`Provider`](../interfaces/Provider.md)[] | Optional context providers. |
Expand Down Expand Up @@ -62,6 +63,14 @@ Store and recall descriptions of users based on conversations.

___

### embeddingModel

**embeddingModel**: `string` = `"text-embedding-3-large"`

The model to use for embedding.

___

### evaluators

**evaluators**: [`Evaluator`](../interfaces/Evaluator.md)[] = `[]`
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ const runtime = new BgentRuntime({
evaluators: [
/* your custom evaluators */
],
model: "gpt-3.5-turbo", // whatever model you want to use
embeddingModel: "text-embedding-3-large", // whatever model you want to use
});
```

Expand Down
10 changes: 9 additions & 1 deletion src/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export class BgentRuntime {
*/
model = "gpt-3.5-turbo-0125";

/**
* The model to use for embedding.
*/
embeddingModel = "text-embedding-3-large";

/**
* Store messages that are sent and received by the agent.
*/
Expand Down Expand Up @@ -129,6 +134,7 @@ export class BgentRuntime {
* @param opts.evaluators - Optional custom evaluators.
* @param opts.providers - Optional context providers.
* @param opts.model - The model to use for completion.
* @param opts.embeddingModel - The model to use for embedding.
*/
constructor(opts: {
recentMessageCount?: number; // number of messages to hold in the recent message cache
Expand All @@ -140,13 +146,15 @@ export class BgentRuntime {
evaluators?: Evaluator[]; // Optional custom evaluators
providers?: Provider[];
model?: string; // The model to use for completion
embeddingModel?: string; // The model to use for embedding
}) {
this.#recentMessageCount =
opts.recentMessageCount ?? this.#recentMessageCount;
this.debugMode = opts.debugMode ?? false;
this.supabase = opts.supabase;
this.serverUrl = opts.serverUrl ?? this.serverUrl;
this.model = opts.model ?? this.model;
this.embeddingModel = opts.embeddingModel ?? this.embeddingModel;
if (!this.serverUrl) {
console.warn("No serverUrl provided, defaulting to localhost");
}
Expand Down Expand Up @@ -269,7 +277,7 @@ export class BgentRuntime {
* @returns The embedding of the input.
*/
async embed(input: string) {
const embeddingModel = "text-embedding-3-large";
const embeddingModel = this.embeddingModel;
const requestOptions = {
method: "POST",
headers: {
Expand Down

0 comments on commit 7a4e847

Please sign in to comment.