Installation
⚠️ This library depends on tRPC v11 Beta, which is necessary to allow SSE-based subscriptions in NextJS, avoiding websockets entirely.
This means you'll need to use tRPC v11 Beta in your project.
- npm
- yarn
- pnpm
- bun
npm install @trpc-chat-agent/core
yarn add @trpc-chat-agent/core
pnpm add @trpc-chat-agent/core
bun add @trpc-chat-agent/core
Installing tRPC
Please install tRPC v11 Beta in your project. This package depends on
version 11.0.0-rc.718
, so for best results, install @trpc/[email protected]
and @trpc/[email protected]
.
Backend adapters
Backend adapters provide a bridge between your LLM and tRPC routers.
The adapter exposes:
- Configuring which backend to use
- Configuring the tools (backend-agnostic)
- Creating the chat agent (partly depends on the backend)
- Creating the tRPC router from the agent
Below is a simple example of what setting up the backend of tRPC Chat Agent might look like
Choose your backend
PRs welcome! 💙
Client adapters
Client adapters only require 3 arguments:
- The tRPC router to use
- The conversation ID (creates a new conversation if undefined)
- A callback to update the conversation ID (optional)
The client adapter mainly provides a list of messages to render, and some helper functions to interact with those messages. All state is handled automatically.
Here is a simple example of the React client adapter:
Under the hood, all state is managed by signals via @preact/signals-core. Any framework that can hook into signals can easily support tRPC Chat Agent.
Choose your client
PRs welcome! 💙
Tools
Tools are the core purpose of tRPC Chat Agent. Here is a simple overview of what defining a tool might look like: