@dudousxd/nestjs-agent-react 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/index.cjs +285 -216
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -2
- package/dist/index.d.ts +45 -2
- package/dist/index.js +114 -47
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -592,6 +592,23 @@ override with `sendMessage(msg, { body: { model } })`; `chat.setThreadModel(id)`
|
|
|
592
592
|
the thread (`null` unpins), so every later turn without its own runs on it. The server refuses a
|
|
593
593
|
model its catalog does not offer as available.
|
|
594
594
|
|
|
595
|
+
### Quota
|
|
596
|
+
|
|
597
|
+
```tsx
|
|
598
|
+
import { QuotaBlockedError, useQuota } from '@dudousxd/nestjs-agent-react';
|
|
599
|
+
|
|
600
|
+
const quota = useQuota({ backend }); // GET <base>/quota
|
|
601
|
+
const chat = useAgentChat({ backend, blocked: quota.blocked });
|
|
602
|
+
|
|
603
|
+
<meter value={quota.month?.usedUsd} max={quota.month?.limitUsd} />
|
|
604
|
+
{quota.blocked ? <p>{quota.blocked.reason}</p> : null}
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
`useQuota` returns every window (`day`, `month`, …) with its usage and ceilings, and `blocked` when
|
|
608
|
+
one is exhausted; it re-reads after every run a chat on the same backend settles (`pollMs` to poll
|
|
609
|
+
as well). With `blocked` passed in, `sendMessage`/`regenerate` reject with `QuotaBlockedError`
|
|
610
|
+
instead of starting a turn the server would refuse with `429`.
|
|
611
|
+
|
|
595
612
|
### The transport, standalone
|
|
596
613
|
|
|
597
614
|
`AgentChatTransport` is a plain AI SDK v7 `ChatTransport` — wire it straight into `useChat` for the SSE
|