Skip to content

Commit 287450b

Browse files
kaihaaseclaude
andcommitted
docs(ai): document AI assistant composables in the README
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 18bed9f commit 287450b

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,45 @@ const base64 = ltArrayBufferToBase64Url(buffer);
344344
const uint8 = ltBase64UrlToUint8Array(base64String);
345345
```
346346

347+
## AI Assistant
348+
349+
Headless, provider-agnostic composables for the `@lenne.tech/nest-server` **AI module**
350+
(REST + SSE). All requests use the same auth-aware `ltAuthFetch` (Cookie/JWT) and URL
351+
resolution as the rest of the library. Configure via `ltExtensions.ai`:
352+
353+
```typescript
354+
// nuxt.config.ts
355+
ltExtensions: {
356+
ai: { enabled: true, basePath: '/ai' }, // basePath must match the nest-server AI controller
357+
}
358+
```
359+
360+
### Chat (streaming, multi-turn)
361+
362+
```vue
363+
<script setup lang="ts">
364+
const { budget, confirm, messages, requiresConfirmation, send, streaming } = useLtAiChat();
365+
</script>
366+
```
367+
368+
`useLtAiChat()` streams the answer token-by-token, tracks the `conversationId`, exposes
369+
the per-response `budget` summary, and drives the confirmation flow for mutating/
370+
destructive actions (`requiresConfirmation``confirm()`).
371+
372+
### Lower-level + supporting composables
373+
374+
| Composable | Purpose |
375+
|------------|---------|
376+
| `useLtAi()` | One-shot `prompt(input)` and streaming `promptStream(input, handlers)` (POST `/ai/stream`) |
377+
| `useLtAiChat()` | Multi-turn chat state, streaming, budget, confirmation, `stop()`/`clear()` |
378+
| `useLtAiConnections()` | User self-service: available connections + `select()` (`selected`/`locked`) |
379+
| `useLtAiUsage()` | Full token/prompt usage breakdown (`GET /ai/usage`) |
380+
| `useLtAiAdmin()` | Admin CRUD: connections (+ `detectCapabilities`), preferences, budget-limits, interactions |
381+
382+
Helpers: `buildLtAiUrl(path)`, `ltAiRequest(method, path, body?)`, `parseLtAiSseStream(response, onEvent)`.
383+
All AI DTOs are exported as `LtAi*` types. The streaming endpoint is consumed via a
384+
`fetch` + `ReadableStream` SSE reader (not `EventSource`, since it is a `POST` with auth).
385+
347386
## i18n Support
348387

349388
The package works **with or without** `@nuxtjs/i18n`:

0 commit comments

Comments
 (0)