@firstlovecenter/ai-chat
v0.9.14
Published
Reusable AI chat module: agent loop, Vertex providers (Claude + Gemini), narrators, persistence schema, and chat UI components. Host injects auth, scope, tools, and credentials via configureAiChat().
Downloads
1,038
Maintainers
Readme
@firstlovecenter/ai-chat
Reusable AI chat module for Next.js apps. Ships:
- An agent tool loop that runs against Vertex AI (Claude or Gemini).
- Two chat UI components: a custom hand-rolled chat and a Vercel AI SDK chat.
- Persistence routes (sessions, messages, admin AI settings).
- ORM-agnostic persistence: bring your own Drizzle (
drizzle-orm) or Prisma (@prisma/client). - Registries for available tool-calling models and chat interfaces — your app picks which to expose.
The host app supplies its own auth, scope, tools, prompts, Vertex credentials, and settings UI. The package handles everything else.
Status
Pre-release. See the project plan for the current roadmap.
Install
pnpm add @firstlovecenter/ai-chat next react react-dom
# pick one persistence backend:
pnpm add drizzle-orm
# or:
pnpm add @prisma/clientQuick start
// src/lib/ai-chat.ts (host)
import { configureAiChat } from '@firstlovecenter/ai-chat/server';
import { createDrizzlePersistence } from '@firstlovecenter/ai-chat/server/drizzle';
// or: import { createPrismaPersistence } from '@firstlovecenter/ai-chat/server/prisma';
export const aiChat = configureAiChat({
persistence: createDrizzlePersistence(db),
auth: { requireAuth, isSuperAdmin },
scope: { resolveScopeLabel, buildScopeSummary },
tools: { tools: ALL_TOOLS, buildSystemBlocks },
vertex: {
projectId: process.env.GCP_PROJECT_ID!,
defaultLocation: process.env.GCP_LOCATION ?? 'us-east5',
auth: getVertexAuth(),
modelIds: { claude: process.env.GCP_CLAUDE_MODEL!, gemini: process.env.GCP_GEMINI_MODEL! }
}
});Detailed integration docs (Drizzle migrations, Prisma fragment paste, Vertex auth recipes, tool authoring, settings UI) ship with v0.1.0.
Database footprint
See DATABASE.md for the full footprint: which three tables the package adds, what it explicitly does not add (no FKs to the host, no users table, no triggers/views), MySQL-only and BIGINT-UNSIGNED user-id assumptions, table-name configurability per ORM, and the known independence gaps for hosts whose schema doesn't match FLC's.
