Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed May 1, 2024
1 parent 793f2c0 commit 86632c9
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 34 deletions.
14 changes: 0 additions & 14 deletions TODO.md

This file was deleted.

7 changes: 5 additions & 2 deletions src/experts/assistant.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { openai } from "../openai.js";
import { debug, formatToolOutputs } from "../helpers.js";
import { debug } from "../helpers.js";
import { Thread } from "./thread.js";
import { Run } from "./run.js";

Expand Down Expand Up @@ -32,6 +32,7 @@ class Assistant {
}

async init() {
await this.beforeInit();
if (!this.llm) return;
this.assistant =
(await this.findByID()) ||
Expand Down Expand Up @@ -62,6 +63,8 @@ class Assistant {
return await this.askAssistant(message, threadID);
}

async beforeInit() {}

// Run Event Overrides

onEvent(event) {}
Expand All @@ -82,7 +85,7 @@ class Assistant {
}
}

// Private
// Private (Ask)

async askAssistant(message, threadID) {
if (!this.llm) return;
Expand Down
13 changes: 1 addition & 12 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,4 @@ const messagesContent = (messages) => {
.join("\n\n");
};

const formatToolOutputs = (outputs) => {
const result = outputs.map((item) => {
if (typeof item === "string") {
return item;
} else {
return JSON.stringify(item);
}
});
return result.join("\n\n");
};

export { debug, isDebug, messagesContent, formatToolOutputs };
export { debug, isDebug, messagesContent };
2 changes: 1 addition & 1 deletion test/experts/assistant.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test("can configure various options", async () => {
file: fs.createReadStream(path),
purpose: "assistants",
});
const assistant = await TestAssistant.initWithOptions({
const assistant = await TestAssistant.createWithOptions({
metadata: { foo: "bar" },
temperature: 0.5,
top_p: 0.5,
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/dataTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class DataTool extends Tool {
});
}

async init() {
async beforeInit() {
await this._createDataFile();
await super.init();
}

async _createDataFile() {
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/oddFactsAssistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class OddFactsAssistant extends Assistant {
});
}

async init() {
async beforeInit() {
await this._createFileSearch();
await super.init();
}

async _createFileSearch() {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/testAssistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestAssistant extends Assistant {
this._name = value;
}

static async initWithOptions(options = {}) {
static async createWithOptions(options = {}) {
const asst = new this(options);
await asst.init();
return asst;
Expand Down

0 comments on commit 86632c9

Please sign in to comment.