@@ -18,7 +18,7 @@ Genkit is a framework designed to help you build AI-powered applications and fea
18
18
19
19
This documentation covers Genkit for Node.js. If you're a Go developer, see the [ Genkit Go documentation] ( /docs/genkit-go/get-started-go ) .
20
20
21
- You can deploy and run Genkit libraries anywhere Node.js is supported. It's designed to work with any generative AI model API or vector database . While we offer integrations for Firebase and Google Cloud, you can use Genkit independently of any Google services.
21
+ You can deploy and run Genkit libraries anywhere Node.js is supported. It's designed to work with many AI model providers and vector databases . While we offer integrations for Firebase and Google Cloud, you can use Genkit independently of any Google services.
22
22
23
23
[ Get started] ( /docs/genkit/get-started ) {: .button}
24
24
@@ -65,19 +65,19 @@ See the following code samples for a concrete idea of how to use these capabilit
65
65
66
66
``` javascript
67
67
import { genkit } from ' genkit' ;
68
- import { googleAI , gemini15Flash } from ' @genkit-ai/googleai' ;
68
+ import { googleAI , gemini20Flash } from ' @genkit-ai/googleai' ;
69
69
70
70
const ai = genkit ({
71
71
plugins: [googleAI ()],
72
- model: gemini15Flash , // Set default model
72
+ model: gemini20Flash , // Set default model
73
73
});
74
74
75
75
// Simple generation
76
76
const { text } = await ai .generate (' Why is AI awesome?' );
77
77
console .log (text);
78
78
79
79
// Streamed generation
80
- const { stream } = await ai .generateStream (' Tell me a story' );
80
+ const { stream } = ai .generateStream (' Tell me a story' );
81
81
for await (const chunk of stream ) {
82
82
console .log (chunk .text );
83
83
}
@@ -87,11 +87,11 @@ See the following code samples for a concrete idea of how to use these capabilit
87
87
88
88
``` javascript
89
89
import { genkit , z } from ' genkit' ;
90
- import { googleAI , gemini15Flash } from ' @genkit-ai/googleai' ;
90
+ import { googleAI , gemini20Flash } from ' @genkit-ai/googleai' ;
91
91
92
92
const ai = genkit ({
93
93
plugins: [googleAI ()],
94
- model: gemini15Flash ,
94
+ model: gemini20Flash ,
95
95
});
96
96
97
97
const { output } = await ai .generate ({
@@ -110,15 +110,15 @@ See the following code samples for a concrete idea of how to use these capabilit
110
110
console .log (output);
111
111
```
112
112
113
- - {Function calling}
113
+ - {Tool calling}
114
114
115
115
``` javascript
116
116
import { genkit , z } from ' genkit' ;
117
- import { googleAI , gemini15Flash } from ' @genkit-ai/googleai' ;
117
+ import { googleAI , gemini20Flash } from ' @genkit-ai/googleai' ;
118
118
119
119
const ai = genkit ({
120
120
plugins: [googleAI ()],
121
- model: gemini15Flash ,
121
+ model: gemini20Flash ,
122
122
});
123
123
124
124
// Define tool to get current weather for a given location
@@ -129,7 +129,9 @@ See the following code samples for a concrete idea of how to use these capabilit
129
129
inputSchema: z .object ({
130
130
location: z .string ().describe (' The location to get the current weather for' )
131
131
}),
132
- outputSchema: z .string (),
132
+ outputSchema: z .object ({
133
+ weatherReport: z .string ().describe (' Weather report of a particular location' )
134
+ }),
133
135
},
134
136
async (input ) => {
135
137
// Here, we would typically make an API call or database query. For this
@@ -149,12 +151,12 @@ See the following code samples for a concrete idea of how to use these capabilit
149
151
- {Chat}
150
152
151
153
``` javascript
152
- import { genkit , z } from ' genkit' ;
153
- import { googleAI , gemini15Flash } from ' @genkit-ai/googleai' ;
154
+ import { genkit , z } from ' genkit/beta ' ;
155
+ import { googleAI , gemini20Flash } from ' @genkit-ai/googleai' ;
154
156
155
157
const ai = genkit ({
156
158
plugins: [googleAI ()],
157
- model: gemini15Flash ,
159
+ model: gemini20Flash ,
158
160
});
159
161
160
162
const chat = ai .chat ({ system: ' Talk like a pirate' });
@@ -169,52 +171,51 @@ See the following code samples for a concrete idea of how to use these capabilit
169
171
- {Agents}
170
172
171
173
``` javascript
172
- import { genkit , z } from ' genkit' ;
173
- import { googleAI , gemini15Flash } from ' @genkit-ai/googleai' ;
174
+ import { genkit , z } from ' genkit/beta ' ;
175
+ import { googleAI , gemini20Flash } from ' @genkit-ai/googleai' ;
174
176
175
177
const ai = genkit ({
176
178
plugins: [googleAI ()],
177
- model: gemini15Flash ,
179
+ model: gemini20Flash ,
178
180
});
179
181
180
- // Define prompts that represent specialist agents
181
- const reservationAgent = ai .definePrompt (
182
- {
183
- name: ' reservationAgent' ,
184
- description: ' Reservation Agent can help manage guest reservations' ,
185
- tools: [reservationTool, reservationCancelationTool, reservationListTool],
186
-
187
- },
188
- ` {% verbatim %}{{role "system"}}{% endverbatim %} Help guests make and manage reservations`
189
- );
182
+ // Define tools for your agents to use
183
+ const reservationTool = ai .defineTool ( ... );
184
+ const reservationCancelationTool = ai .defineTool ( ... );
185
+ const reservationListTool = ai .defineTool ( ... );
190
186
191
- const menuInfoAgent = ...
192
- const complaintAgent = ...
187
+ // Define prompts that represent specialist agents
188
+ const reservationAgent = ai .definePrompt ({
189
+ name: ' reservationAgent' ,
190
+ description: ' Reservation Agent can help manage guest reservations' ,
191
+ tools: [reservationTool, reservationCancelationTool, reservationListTool],
192
+ system: ` Help guests make and manage reservations`
193
+ });
194
+ const menuInfoAgent = ai .definePrompt ( ... );
195
+ const complaintAgent = ai .definePrompt ( ... );
193
196
194
197
// Define a triage agent that routes to the proper specialist agent
195
- const triageAgent = ai .definePrompt (
196
- {
197
- name: ' triageAgent' ,
198
- description: ' Triage Agent' ,
199
- tools: [reservationAgent, menuInfoAgent, complaintAgent],
200
- },
201
- ` {% verbatim %}{{role "system"}}{% endverbatim %} You are an AI customer service agent for Pavel's Cafe.
202
- Greet the user and ask them how you can help. If appropriate, transfer to an
203
- agent that can better handle the request. If you cannot help the customer with
204
- the available tools, politely explain so.`
205
- );
198
+ const triageAgent = ai .definePrompt ({
199
+ name: ' triageAgent' ,
200
+ description: ' Triage Agent' ,
201
+ tools: [reservationAgent, menuInfoAgent, complaintAgent],
202
+ system: ` You are an AI customer service agent for Pavel's Cafe.
203
+ Greet the user and ask them how you can help. If appropriate, transfer to an
204
+ agent that can better handle the request. If you cannot help the customer with
205
+ the available tools, politely explain so.`
206
+ });
206
207
207
- // Create a chat to enable multi-turn agent interactions
208
+ // Create a chat to enable conversational agent interactions
208
209
const chat = ai .chat (triageAgent);
209
210
210
- chat .send (' I want a reservation at Pavel\' s Cafe for noon on Tuesday.' );
211
+ chat .send (' I want a reservation at Pavel\' s Cafe for noon on Tuesday.' );
211
212
```
212
213
213
214
- {Data retrieval}
214
215
215
216
``` javascript
216
217
import { genkit } from ' genkit' ;
217
- import { googleAI , gemini15Flash , textEmbedding004 } from ' @genkit-ai/googleai' ;
218
+ import { googleAI , gemini20Flash , textEmbedding004 } from ' @genkit-ai/googleai' ;
218
219
import { devLocalRetrieverRef } from ' @genkit-ai/dev-local-vectorstore' ;
219
220
220
221
const ai = genkit ({
@@ -227,7 +228,7 @@ See the following code samples for a concrete idea of how to use these capabilit
227
228
},
228
229
]),
229
230
],
230
- model: gemini15Flash ,
231
+ model: gemini20Flash ,
231
232
});
232
233
233
234
// Reference to a local vector database storing Genkit documentation
0 commit comments