Skip to content

Commit

Permalink
Test assistant <-> tool thread metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Apr 30, 2024
1 parent f85722c commit c876da3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
* Can citations be removed from vector store QnA?
* Make sure the assistant find by id works using something like a `process.env.ID`
* Remove the Assistant#messages. Is even `Message` needed?
* Test 2 panel split knowledge. Test the default tool using its thread.
* TODO: Revisit this and assistantsToolsOutputs.
* Is `addAssistantTool` the right name now?
* Add Contributors
6 changes: 6 additions & 0 deletions test/experts/assistant.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { openai } from "../../src/openai.js";
import {
helperName,
helperPath,
helperThread,
helperThreadID,
helperFindAssistant,
} from "../helpers.js";
Expand All @@ -20,6 +21,11 @@ test("assistant as tool", async () => {
expect(output).toMatch(/unrouteable/);
const output2 = await assistant.ask("/echo 123 hello", threadID);
expect(output2).toMatch(/123 hello/);
// Ensure each has own tread using metadata links.
const thread = await helperThread(threadID);
expect(thread.metadata.echo).toMatch(/thread_/);
const thread2 = await helperThread(thread.metadata.echo);
expect(thread2.metadata.tool).toMatch(/Experts\.js \(EchoTool\)/);
});

describe("with vector store", () => {
Expand Down
5 changes: 5 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const helperPath = (filePath) => {
return path.join(base, filePath);
};

const helperThread = async (threadID) => {
return await openai.beta.threads.retrieve(threadID);
};

const helperThreadID = async () => {
const thread = await openai.beta.threads.create();
return thread.id;
Expand Down Expand Up @@ -66,6 +70,7 @@ const helperDeleteAllVectorStores = async () => {
export {
helperName,
helperPath,
helperThread,
helperThreadID,
helperDeleteAllAssistants,
helperFindAssistant,
Expand Down

0 comments on commit c876da3

Please sign in to comment.