@dudousxd/nestjs-agent-react 0.15.0 → 0.16.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 CHANGED
@@ -563,6 +563,35 @@ and patches a streamed title in place; `rename`/`remove` are optimistic and roll
563
563
  through `POST <base>/messages/:id/feedback`, and maps a message streamed in this session to the row
564
564
  its run persisted (the live message carries `metadata.runId`).
565
565
 
566
+ ### Picking a model and an agent
567
+
568
+ ```tsx
569
+ import { useAgents, useModels } from '@dudousxd/nestjs-agent-react';
570
+
571
+ const [model, setModel] = useState<string | undefined>();
572
+ const chat = useAgentChat({ backend, model }); // sent as the body's `model` on every turn
573
+ const { providers, find, defaultModel } = useModels({ backend: chat.backend, agent: 'support' });
574
+ const { agents } = useAgents({ backend: chat.backend });
575
+
576
+ <select value={model ?? defaultModel ?? ''} onChange={(e) => setModel(e.target.value)}>
577
+ {providers.map((p) => (
578
+ <optgroup key={p.id} label={p.label}>
579
+ {p.models.map((m) => (
580
+ <option key={m.id} value={m.id} disabled={!m.available}>
581
+ {m.label} {m.badges?.join(' · ')} {m.available ? '' : `(${m.unavailableReason ?? 'unavailable'})`}
582
+ </option>
583
+ ))}
584
+ </optgroup>
585
+ ))}
586
+ </select>
587
+ ```
588
+
589
+ `useModels` reads `GET <base>/models?agent=` (models grouped by provider, with badges and
590
+ availability; `models` is the same list flattened, `find(id)` looks one up). A single send can
591
+ override with `sendMessage(msg, { body: { model } })`; `chat.setThreadModel(id)` pins a model on
592
+ the thread (`null` unpins), so every later turn without its own runs on it. The server refuses a
593
+ model its catalog does not offer as available.
594
+
566
595
  ### The transport, standalone
567
596
 
568
597
  `AgentChatTransport` is a plain AI SDK v7 `ChatTransport` — wire it straight into `useChat` for the SSE