Effect CommunityEC
Effect Community5mo ago
7 replies
harrysolovay

Discussion on the Design Choice of `AiToolkit` vs. `AiTool`

I'm curious about the reasoning behind AiToolkit? Seems that AiTool should be enough?

AiTool could behave like a context tag.

class DadJokeTool extends AiTool.Tag("GetDadJoke", {
  description: "Get a hilarious dad joke from the ICanHazDadJoke API",
  success: Schema.String,
  failure: Schema.Never,
  parameters: {
    searchTerm: Schema.String.annotations({
      description: "The search term to use to find dad jokes",
    }),
  },
}) {}


One could pass these tags into generateText.

yield* model.generateText({
  prompt: messages,
  toolkit: [DadJokeTool],
})


The generateText-produced effect would contain the DadJokeTool as a requirement (not Handler<"GetDadJoke">). This might be a little nicer from a signature standpoint.

Finally, developers would provide the DadJokeTool just as they would any other requirement.
Was this page helpful?