
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@inferable/trpc-adapter
Advanced tools
Build your Inferable agent functions from your existing tRPC procedures.
The Inferable tRPC Adapter allows you to expose your existing tRPC router endpoints as Inferable functions. This enables AI agents to interact with your tRPC API while preserving all your existing middleware and type safety.
npm install @inferable/trpc-adapter
yarn add @inferable/trpc-adapter
pnpm add @inferable/trpc-adapter
Create your tRPC router with the Inferable plugin:
import { inferablePlugin } from "@inferable/trpc-adapter";
const t = initTRPC.create();
const withInferable = inferablePlugin();
const appRouter = t.router({
userById: t.procedure
.unstable_concat(withInferable) // It's safe to use unstable_concat - https://trpc.io/docs/faq#unstable
.input(z.object({ id: z.string() }))
.meta({ description: "Fetch a user by their ID" }) // This will be used to encrich the LLM context
.query(({ input }) => {
return users.find((user) => user.id === input.id);
}),
});
Create an Inferable service from your router:
import { createInferableService } from "@inferable/trpc-adapter";
import { Inferable } from "inferable";
const client = new Inferable({
apiSecret: process.env.INFERABLE_API_SECRET,
});
const service = createInferableService({
router: appRouter,
createCaller: t.createCallerFactory(appRouter),
name: "userService",
client,
});
// Start the service
await service.start();
const result = await client.run({
initialPrompt: "Get the user with id 1",
resultSchema: z.object({
id: z.string(),
name: z.string(),
email: z.string(),
}),
});
The plugin does two things:
meta
field to the procedures with { inferable: { enabled: true } }
. This is used to identify the procedures that should be exposed as Inferable functions.ctx
field to the tRPC procedure so you can validate the context that's passed by Inferable in your down stream procedures or middleware.Inferable documentation contains all the information you need to get started with Inferable.
For support or questions, please create an issue in the repository.
Contributions to the Inferable tRPC Connector are welcome. Please ensure that your code adheres to the existing style and includes appropriate tests.
FAQs
Build your Inferable agent functions from your existing tRPC procedures.
We found that @inferable/trpc-adapter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.