TypeScript API / @laikacms/server/ai / AiSessionCallbacks
Interface: AiSessionCallbacks
Callbacks for session storage Consumer implements these to persist sessions to their storage (KV, D1, etc.)
Methods
createSession()
ts
createSession(session): Promise<void>;Create a new session
Parameters
| Parameter | Type |
|---|---|
session | AiSession |
Returns
Promise<void>
deleteSession()
ts
deleteSession(sessionId): Promise<void>;Delete a session
Parameters
| Parameter | Type |
|---|---|
sessionId | string |
Returns
Promise<void>
getSession()
ts
getSession(sessionId): Promise<AiSession | null>;Get a session by ID
Parameters
| Parameter | Type |
|---|---|
sessionId | string |
Returns
Promise<AiSession | null>
getSessionsByDocument()
ts
getSessionsByDocument(documentSlug, userId): Promise<AiSession[]>;Get all sessions for a document and user Used to show session history in the widget
Parameters
| Parameter | Type |
|---|---|
documentSlug | string |
userId | string |
Returns
Promise<AiSession[]>
updateSession()
ts
updateSession(sessionId, updates): Promise<void>;Update session messages
Parameters
| Parameter | Type |
|---|---|
sessionId | string |
updates | Partial<Pick<AiSession, "messages" | "title" | "updatedAt">> |
Returns
Promise<void>