الصفحات · Laravilt
Sessions
Persist chat conversations with the AISession model.
Conversations are stored in the ai_sessions table through Laravilt\AI\Models\AISession. The primary key is a UUID string.
| Column | Type | Description |
|---|---|---|
id | string (UUID) | Session ID |
user_id | integer | Owner (relation user() uses auth.providers.users.model) |
title | string | Session title |
provider | string | Provider name |
model | string | Model name |
messages | array | Message list (role, content) |
metadata | array | Extra data |
Working with sessions
php
Endpoints
| Method | URI | Description |
|---|---|---|
| GET | /laravilt-ai/sessions | Latest 50 sessions for the current user |
| POST | /laravilt-ai/sessions | Create (title, provider, model) |
| GET | /laravilt-ai/sessions/{id} | Show a session |
| PATCH | /laravilt-ai/sessions/{id} | Update title or messages |
| DELETE | /laravilt-ai/sessions/{id} | Delete a session |
When session_id is passed to /laravilt-ai/chat or /laravilt-ai/stream, the last user message and the assistant reply are appended to the session.
Pruning old sessions
php