Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addAssistantTool object instead of interface #30

Open
noel-schenk opened this issue Aug 29, 2024 · 0 comments · May be fixed by #31
Open

addAssistantTool object instead of interface #30

noel-schenk opened this issue Aug 29, 2024 · 0 comments · May be fixed by #31

Comments

@noel-schenk
Copy link

It would be nice to be able to add the Tool itself after using Assistant.create instead of needing to create a class. Personally, I prefer not having to use any classes.

Something like this doesn't currently work:

const assistant = await Assistant.create(assistantData);
subAssistantsData.forEach(async (subAssistantData) => {
  const newAssistant = await Assistant.create(subAssistantData);

  newAssistant.on('endAsync', async (metadata) => {
    console.log(
      'endAsync',
      subAssistantData.name,
      await metadata.stream.finalMessages(),
    );
  });

  return assistant.addAssistantTool(newAssistant);
});

const thread = await Thread.create();

console.log('assistant ask', "Test prompt");

const output = await assistant.ask(
  await readFromFile(conversationId, jobId),
  thread.id,
);

console.log('output', output);

My current fix :) with an npm patch works, but is not nice.

addAssistantTool2(assistantTool) {
  assistantTool.parent = this;
  this.experts.push(assistantTool);
  if (assistantTool.isParentsTools) {
    for (const tool of assistantTool.parentsTools) {
      if (tool.type === "function") {
        this.tools.push(tool);
        this.expertsFunctionNames.push(tool.function.name);
      }
    }
  }
}
@noel-schenk noel-schenk linked a pull request Aug 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant