react-ai-avatar 0.1.1 → 0.1.2
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 +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/banner.png" alt="react-ai-avatar — A face for your AI" width="100%" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# react-ai-avatar
|
|
2
6
|
|
|
3
7
|
> A presentational React avatar for realtime LLM voice UIs — **you bring the connection, it brings the face.**
|
|
@@ -24,6 +28,7 @@ One thing, done well, embeddable in a few lines, no backend, MIT. The library ha
|
|
|
24
28
|
- 🦺 **Graceful degradation** — `analyser={null}` while `state="speaking"`? The mouth animates with a synthetic speech-like pattern instead of freezing. Perfect for demos and non-WebRTC apps.
|
|
25
29
|
- ⌨️ **Text-streaming LLMs too** — no audio? Drive the mouth from *token cadence* with `createSpeechActivity()`. A text-only assistant (OpenAI-style `/chat/completions` or `/responses` with `stream: true`) gets a face that visibly tracks the stream — busy while tokens arrive, settling on pauses.
|
|
26
30
|
- 🧠 **A visible `thinking` state** — pulsing thought bubble + upward gaze. Your users *see* the LLM thinking, not just a color change.
|
|
31
|
+
- 🛠️ **A `working` state for tool use** — the fifth state, for agentic UIs. While the LLM runs a tool, the face goes amber and the state pill reads `Working: {tool}` (pass the tool name via the `tool` prop). Your users see *which* tool is running, not just a spinner.
|
|
27
32
|
- 🎨 **Own-design avatar catalog** — `geometric`, `memoji`, `pixelart`, `doodle`: four MIT, CC0-safe SVG presets. No third-party assets, no attribution headaches.
|
|
28
33
|
- 🎲 **DiceBear avatars (`dicebear`)** — generate deterministic [DiceBear](https://www.dicebear.com) avatars client-side, from a curated **CC0-only** style set (still no attribution). Animated with an audio-reactive bounce.
|
|
29
34
|
- 🔌 **Bring your own SVG (`byos`)** — any SVG implementing the small layer contract gets the full animation runtime for free. Your avatar, your license.
|
|
@@ -52,7 +57,7 @@ import 'react-ai-avatar/style.css';
|
|
|
52
57
|
|
|
53
58
|
export default function App() {
|
|
54
59
|
// You resolve this in your app (Gemini, OpenAI Realtime, WebRTC, anything)
|
|
55
|
-
const aiState = 'speaking'; // 'idle' | 'listening' | 'thinking' | 'speaking'
|
|
60
|
+
const aiState = 'speaking'; // 'idle' | 'listening' | 'thinking' | 'speaking' | 'working'
|
|
56
61
|
|
|
57
62
|
return <RealtimeAvatar state={aiState} />;
|
|
58
63
|
}
|
|
@@ -71,7 +76,7 @@ Every default is overridable. Opt into as much as you need:
|
|
|
71
76
|
size={300} // default 280
|
|
72
77
|
variant="geometric" // 'geometric' | 'memoji' | 'pixelart' | 'doodle' | 'dicebear' | 'vrm' | 'glb' | 'byos'
|
|
73
78
|
customization={{ skinColor: '#f5c7a9', hairColor: '#2c2c2c', glasses: true, headphones: true }}
|
|
74
|
-
stateColors={{ idle: '#4b5563', listening: '#3b82f6', thinking: '#8b5cf6', speaking: '#10b981' }}
|
|
79
|
+
stateColors={{ idle: '#4b5563', listening: '#3b82f6', thinking: '#8b5cf6', speaking: '#10b981', working: '#f59e0b' }}
|
|
75
80
|
/>
|
|
76
81
|
```
|
|
77
82
|
|
|
@@ -155,7 +160,8 @@ Optional data attributes: `data-base-x`/`data-base-y` (pupil rest position), `da
|
|
|
155
160
|
|
|
156
161
|
### `<RealtimeAvatar />`
|
|
157
162
|
|
|
158
|
-
- `state` (`'idle' | 'listening' | 'thinking' | 'speaking'`) — required. You resolve it; it is never inferred.
|
|
163
|
+
- `state` (`'idle' | 'listening' | 'thinking' | 'speaking' | 'working'`) — required. You resolve it; it is never inferred. `working` is the tool-use state for agentic UIs (amber).
|
|
164
|
+
- `tool` (`string`) — optional. The name of the tool currently running. While `state="working"`, the state pill reads `Working: {tool}` instead of the generic label.
|
|
159
165
|
- `analyser` (`AnalyserNode | null`) — optional. Drives the mouth from audio. Omitted or `null`, speaking falls back to the synthetic pattern.
|
|
160
166
|
- `streamingText` (`string`) — optional. Declarative mouth driver: pass the accumulated assistant text (e.g. from `useChat`) and the avatar diffs its growth to drive the mouth. Takes precedence over `analyser`. See [Text-streaming LLMs](#text-streaming-llms-no-audio).
|
|
161
167
|
- `speechActivity` (`SpeechActivitySource`) — optional. Imperative token-rate mouth driver, from `createSpeechActivity()`. Takes precedence over both `streamingText` and `analyser` when set.
|
|
@@ -183,6 +189,7 @@ Everything the runtime uses is exported, so you can compose your own:
|
|
|
183
189
|
- `useStreamingTextActivity(text)` — declarative wrapper: diffs accumulated streaming text into a `SpeechActivitySource` for you (what the `streamingText` prop uses).
|
|
184
190
|
- `useReducedMotion()` — SSR-safe `prefers-reduced-motion` hook.
|
|
185
191
|
- `GeometricAvatar`, `MemojiAvatar`, `PixelArtAvatar`, `DoodleAvatar` — the raw presets.
|
|
192
|
+
- `SquirrelAvatar` — a full branded character (red-squirrel dev face) built on the `#rra-*` contract; the worked `byos` example, shipped so the demos render it from one source. See [`examples/08-character-avatar-squirrel.tsx`](examples/08-character-avatar-squirrel.tsx).
|
|
186
193
|
- `AudioVisualizer` — Siri-style waveform telemetry strip.
|
|
187
194
|
- `AvatarCaption` / `AvatarThought` — host-placed caption + thought widgets. In-flow (not `absolute`), so they fit your own layout slot without overflow; both flatten markdown to spoken prose and roll a trailing window.
|
|
188
195
|
- `toPlainText(md)` / `tailWindow(text, { maxChars })` — the pure text helpers behind those widgets, for building your own caption.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-ai-avatar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A presentational React avatar for realtime LLM voice UIs — you bring the connection, it brings the face.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ariel A. <ariel.a.deibe@gmail.com>",
|