Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions chat-agent/dev/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# MongoDB connection string. Local dev defaults to
# mongodb://localhost:27017/chat-agent-dev when unset. For Vercel deployments
# point this at a MongoDB Atlas cluster (SRV URI).
DATABASE_URI=mongodb://127.0.0.1/chat-agent-dev

# Secret used to sign Payload tokens. Generate with `openssl rand -hex 32`.
PAYLOAD_SECRET=YOUR_SECRET_HERE

# Provider keys for the chat agent. Only the providers you actually use need
# to be set — resolveModel in payload.config.ts will throw a clear error if a
# selected model references a missing key.
ANTHROPIC_API_KEY=
OPENAI_API_KEY=
1 change: 1 addition & 0 deletions chat-agent/dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@payloadcms/next": "^3.83.0",
"@payloadcms/richtext-lexical": "^3.83.0",
"@payloadcms/ui": "^3.83.0",
"@vercel/functions": "^3.1.5",
"ai": "^6.0.164",
"next": "15.4.11",
"payload": "^3.83.0",
Expand Down
15 changes: 15 additions & 0 deletions chat-agent/dev/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
UnorderedListFeature,
UploadFeature,
} from '@payloadcms/richtext-lexical'
import { attachDatabasePool } from '@vercel/functions'
import path from 'path'
import { buildConfig } from 'payload'
import { fileURLToPath } from 'url'
Expand Down Expand Up @@ -321,6 +322,20 @@ export default buildConfig({
],
db: mongooseAdapter({
url: process.env.DATABASE_URI || 'mongodb://localhost:27017/chat-agent-dev',
connectOptions: {
// Close sockets quickly so Fluid Compute can drain the pool between
// invocations instead of keeping idle Atlas connections open.
maxIdleTimeMS: 5_000,
maxPoolSize: 10,
},
// On Vercel Fluid Compute, hand the underlying MongoClient to
// @vercel/functions so idle connections are released when the function
// suspends. Guarded by VERCEL so local dev/tests aren't affected.
afterOpenConnection: (adapter) => {
if (process.env.VERCEL) {
attachDatabasePool(adapter.connection.getClient())
}
},
}),
editor: lexicalEditor(),
endpoints: rootEndpoints,
Expand Down
12 changes: 12 additions & 0 deletions chat-agent/dev/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"framework": "nextjs",
"installCommand": "cd .. && pnpm install --frozen-lockfile",
"buildCommand": "pnpm build",
"outputDirectory": ".next",
"functions": {
"src/app/(payload)/api/[...slug]/route.ts": {
"maxDuration": 300
}
}
}
22 changes: 22 additions & 0 deletions chat-agent/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading