Are you an LLM? You can read better optimized documentation at /tools.md for this page in Markdown format
Liminal Tools beta
ts
import { AiTool } from "@effect/ai"
export const DadJokeTool = AiTool.make("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",
}),
},
})ts
import { AiToolkit } from "@effect/ai"
import { DadJokeTool } from "./DadJokeTools.ts"
import { ModelLive } from "./ModelLive.ts"
// Implement the `GetDadJoke` handler.
const HandlerLive = AiToolkit.make(DadJokeTool).toLayer(Effect.gen(function*() {
return {
GetDadJoke: Effect.fn(function*() {
return "Delish pish decaly dish!"
}),
}
}))
Effect.gen(function*() {
// Enable the tool.
yield* L.enable(DadJokeTool)
// Converse. The model will use the tool as it sees fit.
yield* L.user`Generate a dad joke about pirates.`
const reply = yield* L.assistant
reply satisfies string
}).pipe(
L.thread,
Effect.provide([ModelLive, HandlerLive]),
Effect.runFork,
)