assistant-ui 0.0.99 → 0.0.100
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/package.json
CHANGED
|
@@ -124,33 +124,46 @@ const result = streamText({
|
|
|
124
124
|
|
|
125
125
|
### Frontend tool UI:
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
"use client";
|
|
127
|
+
Create a toolkit with a renderer for the tool. The tool executes on the backend, so the entry uses `externalTool()` and only attaches UI:
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
129
|
+
```tsx
|
|
130
|
+
// app/toolkit.tsx
|
|
131
|
+
"use generative";
|
|
132
|
+
|
|
133
|
+
import { defineToolkit, externalTool } from "@assistant-ui/react";
|
|
134
|
+
|
|
135
|
+
export default defineToolkit({
|
|
136
|
+
get_weather: {
|
|
137
|
+
execute: externalTool(),
|
|
138
|
+
render: ({ args, result }) => {
|
|
139
|
+
return (
|
|
140
|
+
<div>
|
|
141
|
+
<p>Weather for {args?.location}</p>
|
|
142
|
+
{result && <p>{result.temperature}F, {result.condition}</p>}
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
141
146
|
},
|
|
142
147
|
});
|
|
143
148
|
```
|
|
144
149
|
|
|
145
|
-
Register the
|
|
150
|
+
Register the toolkit in your assistant component:
|
|
146
151
|
|
|
147
152
|
```tsx
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
import { AssistantRuntimeProvider, Tools, useAui } from "@assistant-ui/react";
|
|
154
|
+
import toolkit from "@/app/toolkit";
|
|
155
|
+
|
|
156
|
+
const aui = useAui({
|
|
157
|
+
tools: Tools({ toolkit }),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
<AssistantRuntimeProvider aui={aui} runtime={runtime}>
|
|
150
161
|
<Thread />
|
|
151
162
|
</AssistantRuntimeProvider>
|
|
152
163
|
```
|
|
153
164
|
|
|
165
|
+
Do not use `makeAssistantToolUI`, `useAssistantToolUI`, `makeAssistantTool`, or `useAssistantTool`; they are deprecated in favor of toolkits.
|
|
166
|
+
|
|
154
167
|
## Key Packages
|
|
155
168
|
|
|
156
169
|
| Package | Purpose |
|