@tambo-ai/react 0.25.0 → 0.25.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.
Files changed (2) hide show
  1. package/README.md +155 -116
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,75 +1,103 @@
1
- # tambo ai
1
+ # tambo-ai
2
2
 
3
- Build AI assistants and agents in React with a few lines of code.
3
+ A React package for adding generative React UI components to your AI assistant, copilot, or agent.
4
4
 
5
- <p align="center">
6
- <img src="../assets/tambo-animation.gif" alt="tambo ai Octo Juggling">
7
- </p>
5
+ ## Build with MCP and Generative UI
8
6
 
9
- ## What is tambo ai?
7
+ [![Watch the video](https://img.youtube.com/vi/6zDDPfr7Aoo/0.jpg)](https://youtu.be/6zDDPfr7Aoo)
10
8
 
11
- tambo ai is a React library that deals with the boring parts. Get started with an AI assistant in minutes.
9
+ [Source code](https://github.com/tambo-ai/mcp-template)
12
10
 
13
- We handle:
11
+ Create a new project using our MCP template:
14
12
 
15
- - Thread management
16
- - State persistence
17
- - Streaming responses
18
- - AI Orchestration
19
- - A Compatible React UI Library
13
+ ```bash
14
+ npx tambo create-app -t mcp tambo-mcp-app
15
+ ```
20
16
 
21
- You get clean React hooks that integrate seamlessly with your codebase.
17
+ ## How does tambo-ai work?
22
18
 
23
- [![npm version](https://img.shields.io/npm/v/@tambo-ai/react.svg)](https://www.npmjs.com/package/@tambo-ai/react)
24
- [![License](https://img.shields.io/github/license/tambo-ai/tambo.svg)](https://github.com/tambo-ai/tambo/blob/main/LICENSE)
25
- [![GitHub last commit](https://img.shields.io/github/last-commit/tambo-ai/tambo.svg)](https://github.com/tambo-ai/tambo/commits/main)
26
- [![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://discord.gg/dJNvPEHth6)
19
+ tambo-ai is a client-side registry of React components that can be used by an LLM.
27
20
 
28
- ## Installation
21
+ ### 1. Register your components
29
22
 
30
- ```bash
31
- npm install @tambo-ai/react
23
+ ```tsx
24
+ const components: TamboComponent[] = [
25
+ {
26
+ name: "Graph",
27
+ description:
28
+ "A component that renders various types of charts (bar, line, pie) using Recharts. Supports customizable data visualization with labels, datasets, and styling options.",
29
+ component: Graph,
30
+ propsSchema: graphSchema, // zod schema
31
+ },
32
+ // Add more components
33
+ ];
32
34
  ```
33
35
 
34
- ## Quick Start
36
+ ### 2. Wrap your app in a TamboProvider
35
37
 
36
- Use our template:
38
+ ```tsx
39
+ // In your chat page
40
+ <TamboProvider
41
+ apiKey={process.env.NEXT_PUBLIC_TAMBO_API_KEY!}
42
+ components={components}
43
+ >
44
+ <MessageThreadFull contextKey="tambo-template" />
45
+ </TamboProvider>
46
+ ```
37
47
 
38
- ```bash
39
- git clone https://github.com/tambo-ai/tambo-template.git && cd tambo-template && npm install && npx tambo init
48
+ ### 3. Submit user messages
40
49
 
41
- npm run dev
50
+ ```tsx
51
+ const { submit } = useTamboThreadInput(contextKey);
52
+
53
+ await submit({
54
+ contextKey,
55
+ streamResponse: true,
56
+ });
42
57
  ```
43
58
 
44
- or try adding it to your existing project:
59
+ ### 4. Render AI-generated components
45
60
 
46
- ```bash
47
- npx tambo full-send
61
+ ```tsx
62
+ const { message } = useMessageContext();
63
+
64
+ // Render the component
65
+ <div>{message.renderedComponent}</div>;
48
66
  ```
49
67
 
50
- ## Basic Usage
68
+ We provide components that use these hooks for you in our templates and in our component library at [ui.tambo.co](https://ui.tambo.co).
51
69
 
52
- 1. Add tambo ai to your React app with a simple provider pattern:
70
+ ## Getting Started
53
71
 
54
- ```jsx
55
- import { TamboProvider } from "@tambo-ai/react";
72
+ ### Quick Start
56
73
 
57
- function App() {
58
- return (
59
- <TamboProvider apiKey="your-api-key">
60
- <YourApp />
61
- </TamboProvider>
62
- );
63
- }
74
+ Create a new tambo app:
75
+
76
+ ```bash
77
+ npm create tambo-app my-tambo-app
78
+ cd my-tambo-app
79
+ npm run dev
64
80
  ```
65
81
 
66
- 2. Displaying a message thread:
82
+ ### Templates
83
+
84
+ | App | Description |
85
+ | ---------------------------------------------------------------------- | -------------------------------------- |
86
+ | [MCP](https://github.com/tambo-ai/mcp-template) (new!) | Get started with MCP + Generative UX |
87
+ | [Regular Tools](https://github.com/tambo-ai/tambo-template) | Get started with Generative UX |
88
+ | [Conversational Form](https://github.com/tambo-ai/conversational-form) | Collect information with generative UX |
89
+
90
+ Check out our UI library [tambo-ui](https://ui.tambo.co) for components that leverage tambo.
91
+
92
+ ### Basic Usage
93
+
94
+ #### 1. Displaying a message thread:
67
95
 
68
96
  ```jsx
69
97
  import { useTambo, useTamboThreadInput } from "@tambo-ai/react";
70
98
 
71
99
  function ChatInterface() {
72
- const { thread, sendThreadMessage } = useTambo();
100
+ const { thread } = useTambo();
73
101
  const { value, setValue, submit } = useTamboThreadInput();
74
102
 
75
103
  return (
@@ -105,26 +133,42 @@ function ChatInterface() {
105
133
  }
106
134
  ```
107
135
 
108
- ## Core Features
136
+ #### 2. Adding AI-Generated Components:
109
137
 
110
- - **Specialized hooks for specific needs:**
138
+ Create components that can be dynamically generated by the AI:
111
139
 
112
- - `useTambo` - Primary entrypoint for the Tambo React SDK
113
- - `useTamboThreadInput` - Input state and submission
114
- - `useTamboSuggestions` - AI-powered message suggestions
115
- - `useTamboThreadList` - Conversation management
116
- - `useTamboComponentState` - AI-generated component state
117
- - `useTamboThread` - Access to current thread context
140
+ ```jsx
141
+ // components/WeatherCard.jsx
142
+ import { useTamboComponentState } from "@tambo-ai/react";
143
+
144
+ export function WeatherCard() {
145
+ const [weatherState, setWeatherState, { isPending }] = useTamboComponentState(
146
+ "weather",
147
+ {
148
+ temperature: 0,
149
+ condition: "",
150
+ location: "",
151
+ },
152
+ );
118
153
 
119
- - **Component registration for AI-generated UI**
120
- - **Tool integration for your data sources**
121
- - **Streaming responses for real-time interactions**
154
+ if (isPending) {
155
+ return <div>Loading weather data...</div>;
156
+ }
122
157
 
123
- ## Component Registration
158
+ return (
159
+ <div>
160
+ <h3>{weatherState.location}</h3>
161
+ <div>{weatherState.temperature}°C</div>
162
+ <div>{weatherState.condition}</div>
163
+ </div>
164
+ );
165
+ }
166
+ ```
124
167
 
125
- Define which components your AI assistant can use to respond to users by passing them to the TamboProvider:
168
+ #### 3. Register your components:
126
169
 
127
170
  ```jsx
171
+ // App.jsx
128
172
  import { TamboProvider } from "@tambo-ai/react";
129
173
  import { WeatherCard } from "./components/WeatherCard";
130
174
  import { z } from "zod";
@@ -153,79 +197,70 @@ function App() {
153
197
  }
154
198
  ```
155
199
 
156
- You can also use `z.describe()` for extra prompting to the AI:
200
+ ### Adding Tools for the AI
157
201
 
158
- ```tsx
159
- import { z } from "zod";
160
-
161
- schema = z.object({
162
- data: z.object({
163
- labels: z.array(z.string()).describe("Use single words or short phrases."),
164
- values: z.array(z.number()).describe("Use whole numbers."),
165
- }),
166
- type: z
167
- .enum(["bar", "line", "pie"])
168
- .describe(
169
- "Use a chart type that is appropriate for the data. Only use pie charts when less than 5 values.",
170
- ),
171
- });
172
- ```
173
-
174
- ## Tool Integration
175
-
176
- Connect your data sources without writing complex integration code:
202
+ Register tools to make them available to the AI:
177
203
 
178
204
  ```jsx
179
- import { TamboProvider } from "@tambo-ai/react";
180
- import { WeatherCard } from "./components/WeatherCard";
181
- import { z } from "zod";
182
-
183
- // Define a tool with Zod schema
184
- const dataTool = {
185
- name: "fetchData",
186
- description: "Fetch data for visualization",
187
- tool: async ({ dataType }) => {
188
- /* fetch data */
189
- },
190
- toolSchema: z
191
- .function()
192
- .args(z.object({ dataType: z.string() }))
193
- .returns(z.any()),
194
- };
195
-
196
- // Define your components with associated tools
197
- const components = [
205
+ const tools: TamboTool[] = [
198
206
  {
199
- name: "WeatherCard",
200
- description: "A component that displays weather information",
201
- component: WeatherCard,
202
- propsSchema: z.object({
203
- temperature: z.number(),
204
- condition: z.string(),
205
- location: z.string(),
206
- }),
207
- associatedTools: [dataTool], // Associate the tool with the component
207
+ name: "getWeather",
208
+ description: "Fetches current weather data for a given location",
209
+ tool: async (location: string, units: string = "celsius") => {
210
+ // Example implementation
211
+ const weather = await fetchWeatherData(location);
212
+ return {
213
+ temperature: weather.temp,
214
+ condition: weather.condition,
215
+ location: weather.city,
216
+ };
217
+ },
218
+ toolSchema: z
219
+ .function()
220
+ .args(
221
+ z.string().describe("Location name (city)"),
222
+ z
223
+ .string()
224
+ .optional()
225
+ .describe("Temperature units (celsius/fahrenheit)"),
226
+ )
227
+ .returns(
228
+ z.object({
229
+ temperature: z.number(),
230
+ condition: z.string(),
231
+ location: z.string(),
232
+ }),
233
+ ),
208
234
  },
209
235
  ];
210
236
 
211
- // Pass them to the provider
212
- function App() {
213
- return (
214
- <TamboProvider apiKey="your-api-key" components={components}>
215
- <YourApp />
216
- </TamboProvider>
217
- );
218
- }
237
+ // Pass tools to the provider
238
+ <TamboProvider apiKey="your-api-key" tools={tools}>
239
+ <YourApp />
240
+ </TamboProvider>;
219
241
  ```
220
242
 
221
- ## Resources
243
+ ### Using MCP Servers
222
244
 
223
- - [Full Documentation](https://tambo.co/docs)
224
- - [Showcase Documentation](../showcase/README.md)
245
+ ```tsx
246
+ const mcpServers = [
247
+ {
248
+ url: "https://mcp-server-1.com",
249
+ transport: "http",
250
+ name: "mcp-server-1",
251
+ },
252
+ ];
225
253
 
226
- ## License
254
+ // Pass MCP servers to the provider
255
+ <TamboProvider
256
+ apiKey={process.env.NEXT_PUBLIC_TAMBO_API_KEY!}
257
+ components={components}
258
+ >
259
+ <TamboMcpProvider mcpServers={mcpServers}>{children}</TamboMcpProvider>
260
+ </TamboProvider>;
261
+ ```
227
262
 
228
- MIT License - see the [LICENSE](../LICENSE) file for details.
263
+ [Read our full documentation](https://tambo.co/docs)
229
264
 
230
265
  ## Join the Community
231
266
 
@@ -234,3 +269,7 @@ We're building tools for the future of user interfaces. Your contributions matte
234
269
  **[Star this repo](https://github.com/tambo-ai/tambo)** to support our work.
235
270
 
236
271
  **[Join our Discord](https://discord.gg/dJNvPEHth6)** to connect with other developers.
272
+
273
+ <p align="center">
274
+ <img src="../assets/tambo-animation.gif" alt="tambo ai Octo Juggling">
275
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tambo-ai/react",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "React client package for Tambo AI",
5
5
  "repository": {
6
6
  "type": "git",