diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 497e507..0000000 --- a/TODO.md +++ /dev/null @@ -1,14 +0,0 @@ -* Create a beforeInit event/hook vs. an override. -* Can citations be removed from vector store QnA? -* Remove the Assistant#messages. Is even `Message` needed? -* TODO: Revisit this and assistantsToolsOutputs. -* Is `addAssistantTool` the right name now? - - -```javascript -stream.on("event", (e) => { - if (e.event.startsWith("thread.run")) { - aRun = e.data; - } -}); -``` diff --git a/src/experts/assistant.js b/src/experts/assistant.js index 1b88a02..4e0a275 100644 --- a/src/experts/assistant.js +++ b/src/experts/assistant.js @@ -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"; @@ -32,6 +32,7 @@ class Assistant { } async init() { + await this.beforeInit(); if (!this.llm) return; this.assistant = (await this.findByID()) || @@ -62,6 +63,8 @@ class Assistant { return await this.askAssistant(message, threadID); } + async beforeInit() {} + // Run Event Overrides onEvent(event) {} @@ -82,7 +85,7 @@ class Assistant { } } - // Private + // Private (Ask) async askAssistant(message, threadID) { if (!this.llm) return; diff --git a/src/helpers.js b/src/helpers.js index f72d5f3..5d80628 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -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 }; diff --git a/test/experts/assistant.test.js b/test/experts/assistant.test.js index 86e0b27..882b309 100644 --- a/test/experts/assistant.test.js +++ b/test/experts/assistant.test.js @@ -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, diff --git a/test/fixtures/dataTool.js b/test/fixtures/dataTool.js index 7a1409f..dbcca6d 100644 --- a/test/fixtures/dataTool.js +++ b/test/fixtures/dataTool.js @@ -14,9 +14,8 @@ class DataTool extends Tool { }); } - async init() { + async beforeInit() { await this._createDataFile(); - await super.init(); } async _createDataFile() { diff --git a/test/fixtures/oddFactsAssistant.js b/test/fixtures/oddFactsAssistant.js index e3a6fb3..55b96d1 100644 --- a/test/fixtures/oddFactsAssistant.js +++ b/test/fixtures/oddFactsAssistant.js @@ -14,9 +14,8 @@ class OddFactsAssistant extends Assistant { }); } - async init() { + async beforeInit() { await this._createFileSearch(); - await super.init(); } async _createFileSearch() { diff --git a/test/fixtures/testAssistant.js b/test/fixtures/testAssistant.js index 2c13d7d..582b810 100644 --- a/test/fixtures/testAssistant.js +++ b/test/fixtures/testAssistant.js @@ -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;