@zaikit/react 0.1.0 → 0.1.1
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 +45 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @zaikit/react
|
|
2
|
+
|
|
3
|
+
React hooks and components for building AI agent UIs — `AgentProvider`, `useAgent`, `useAgentChat`, and `useToolRenderer`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @zaikit/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { AgentProvider, useAgentChat } from "@zaikit/react";
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<AgentProvider api="/api/chat">
|
|
19
|
+
<Chat />
|
|
20
|
+
</AgentProvider>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function Chat() {
|
|
25
|
+
const { messages, input, setInput, submit } = useAgentChat();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
{messages.map((m) => (
|
|
30
|
+
<div key={m.id}>{m.content}</div>
|
|
31
|
+
))}
|
|
32
|
+
<input value={input} onChange={(e) => setInput(e.target.value)} />
|
|
33
|
+
<button onClick={submit}>Send</button>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Documentation
|
|
40
|
+
|
|
41
|
+
[https://zaikit.dev](https://zaikit.dev)
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|