Skip to content

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 ​

ParameterType
sessionAiSession

Returns ​

Promise<void>


deleteSession() ​

ts
deleteSession(sessionId): Promise<void>;

Delete a session

Parameters ​

ParameterType
sessionIdstring

Returns ​

Promise<void>


getSession() ​

ts
getSession(sessionId): Promise<AiSession | null>;

Get a session by ID

Parameters ​

ParameterType
sessionIdstring

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 ​

ParameterType
documentSlugstring
userIdstring

Returns ​

Promise<AiSession[]>


updateSession() ​

ts
updateSession(sessionId, updates): Promise<void>;

Update session messages

Parameters ​

ParameterType
sessionIdstring
updatesPartial<Pick<AiSession, "messages" | "title" | "updatedAt">>

Returns ​

Promise<void>

Released under the MIT License.