metaskills / experts

Experts.js is the easiest way to create and deploy OpenAI's Assistants and link them together as Tools to create advanced Multi AI Agent Systems with expanded memory and attention to detail.
https://www.unremarkable.ai/experts/
MIT License
973 stars 54 forks source link

Why use classes in documentation? #15

Closed heymartinadams closed 3 months ago

heymartinadams commented 3 months ago

Just curious. I’ve never used them, and was never taught how to use them. For example, how would this code below look like in a regular serverless function?

class MainAssistant extends Assistant {
  constructor() {
    super({
      name: "Company Assistant",
      instructions: "...",
    });
    this.addAssistantTool(ProductsTools);
  }
}
heymartinadams commented 3 months ago

Btw, I’m super intrigued by your concept and would love to use it. What’s stopping me so far is the documentation — specifically the class code (super confusing), and the confusion I get when reading about how you’re handling streaming (what the heck is process.stdout.write for?).

What would be super helpful are clear, concise, start-to-finish examples.

metaskills commented 3 months ago

Hey @heymartinadams 👋🏼

For example, how would this code below look like in a regular serverless function?

Great question. I'll share what I've been doing. It really depends on the type of project. For example, if you are building a chatbot backend with Express, you would most likely instantiate the assistant in app.js or a router, such as this.

https://github.com/metaskills/experts?tab=readme-ov-file#streaming-from-express

The idea is that you have a single instance you create and all messages are routed thru that single assistant. Just as you would with the SDK. I think the only diff is the constructor pattern. You can also see in that example you could organize your experts into a directory. This allows you to easily test them too by just importing them where you need. Were you expecting something more like?

import { experts } from "experts";

const assistant = experts.assistant.create({
  instructions: "...",
  model: "gpt-4o",
});

That could easily be supported.

What’s stopping me so far is the documentation...

Heard. I understand. Always a WIP there. Would be fun to get some contributions and a community site going. A Docusaurus site would be cool 🦖 🎉

what the heck is process.stdout.write for?

Ah, we should modernize that with something more contextual for deployed agents. I used the OpenAI Assistants documentation example there as inspiration.

https://platform.openai.com/docs/assistants/overview

It made sense to me because I think they assumed a command line interface. Writing to stdout is classic doc example tho. But agreed it makes less sense here.

The biggest use I've seen for the server send events (SSE) is token usage.

https://github.com/metaskills/experts?tab=readme-ov-file#token-usage-metrics

heymartinadams commented 3 months ago

Hi @metaskills 👋🏼 thanks for the detailed reply!

Yes, definitely was looking for something like this 😅 My brain somehow doesn’t freeze when I see this familiar pattern.

import { experts } from "experts";

const assistant = experts.assistant.create({
  instructions: "...",
  model: "gpt-4o",
});

Currently integrating OpenAI’s Assistants streaming into our app, OneTask. I could imagine an integration using your tools for AI agents on this platform ☺️

Will use OpenAI’s node package for now, but watching this space to see how things develop.

metaskills commented 3 months ago

Appreciate it @heymartinadams, I love the idea of exposing a global constructor. Created a issue here to track it. https://github.com/metaskills/experts/issues/16