Skip to content

Commit 3069383

Browse files
authored
Merge branch 'firebase:main' into main
2 parents 8cad6af + 5cd76f8 commit 3069383

File tree

151 files changed

+13314
-4198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+13314
-4198
lines changed

.github/ISSUE_TEMPLATE/py-runtime-bug-report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ A clear and concise description of what you expected to happen.
2020
If applicable, add screenshots to help explain your problem.
2121

2222
**Runtime (please complete the following information):**
23-
- OS: [e.g. Linux, MacOS]
24-
- Genkit Version [e.g. 0.3.1]
23+
- OS: [e.g. Linux, macOS]
24+
- Genkit Version: [e.g. 0.3.1]
2525

26-
** Node version
27-
- run `python3 --version` at paste here
26+
**Python version**
27+
- Run `python3 --version` at paste here
2828

2929
**Additional context**
3030
Add any other context about the problem here.

bin/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function genkit::install_go_cli_tools_ci() {
222222
# Install all the required tools that have been written in Go.
223223
function genkit::install_go_cli_tools_eng() {
224224
go install github.com/Gelio/go-global-update@latest
225-
go install github.com/captainhook-go/captainhook/cmd/captainhook@latest
225+
go install github.com/captainhook-git/captainhook-bin/cmd/captainhook@latest
226226
go install github.com/google/addlicense@latest
227227
go install github.com/google/go-licenses@latest
228228
go install github.com/jesseduffield/lazygit@latest

genkit-tools/cli/context/GENKIT.go.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Genkit Go API Rules (v1.0.0)
1+
# Genkit Go API Rules (v1.20.0)
22

33
This document provides rules and examples for building with the Genkit API in Go.
44

genkit-tools/cli/context/GENKIT.js.md

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Genkit Node.js API Rules (v1.17.1)
1+
# Genkit Node.js API Rules (v1.20.0)
22

33
This document provides rules and examples for building with the Genkit API in Node.js.
44

@@ -102,41 +102,6 @@ export const basicInferenceFlow = ai.defineFlow(
102102
103103
### Text-to-Speech (TTS) Generation
104104
105-
This helper function converts PCM audio data from the TTS model into a WAV-formatted data URI.
106-
107-
```ts
108-
import { Buffer } from 'buffer';
109-
import { PassThrough } from 'stream';
110-
import { Writer as WavWriter } from 'wav';
111-
112-
...
113-
114-
async function pcmToWavDataUri(
115-
pcmData: Buffer,
116-
channels = 1,
117-
sampleRate = 24000,
118-
bitDepth = 16
119-
): Promise<string> {
120-
return new Promise((resolve, reject) => {
121-
const chunks: Buffer[] = [];
122-
const passThrough = new PassThrough();
123-
124-
passThrough.on('data', (chunk) => chunks.push(chunk as Buffer));
125-
passThrough.on('end', () => {
126-
const wavBuffer = Buffer.concat(chunks);
127-
const dataUri = `data:audio/wav;base64,${wavBuffer.toString('base64')}`;
128-
resolve(dataUri);
129-
});
130-
passThrough.on('error', reject);
131-
132-
const writer = new WavWriter({ channels, sampleRate, bitDepth });
133-
writer.pipe(passThrough);
134-
writer.write(pcmData);
135-
writer.end();
136-
});
137-
}
138-
```
139-
140105
#### Single-Speaker TTS
141106
142107
```ts
@@ -147,17 +112,12 @@ const TextToSpeechInputSchema = z.object({
147112
.optional()
148113
.describe('The voice name to use. Defaults to Algenib if not specified.'),
149114
});
150-
const TextToSpeechOutputSchema = z.object({
151-
audioDataUri: z
152-
.string()
153-
.describe('The generated speech in WAV format as a base64 data URI.'),
154-
});
155115
156116
export const textToSpeechFlow = ai.defineFlow(
157117
{
158118
name: 'textToSpeechFlow',
159119
inputSchema: TextToSpeechInputSchema,
160-
outputSchema: TextToSpeechOutputSchema,
120+
outputSchema: z.string().optional().describe('The generated audio URI'),
161121
},
162122
async (input) => {
163123
const response = await ai.generate({
@@ -175,16 +135,7 @@ export const textToSpeechFlow = ai.defineFlow(
175135
},
176136
});
177137
178-
const audioUrl = response.media?.url;
179-
if (!audioUrl)
180-
throw new Error('Audio generation failed: No media URL in response.');
181-
182-
const base64 = audioUrl.split(';base64,')[1];
183-
if (!base64) throw new Error('Invalid audio data URI format from Genkit.');
184-
185-
const pcmBuffer = Buffer.from(base64, 'base64');
186-
const audioDataUri = await pcmToWavDataUri(pcmBuffer);
187-
return { audioDataUri };
138+
return response.media?.url;
188139
}
189140
);
190141
```
@@ -204,7 +155,7 @@ export const multiSpeakerTextToSpeechFlow = ai.defineFlow(
204155
{
205156
name: 'multiSpeakerTextToSpeechFlow',
206157
inputSchema: MultiSpeakerInputSchema,
207-
outputSchema: TextToSpeechOutputSchema,
158+
outputSchema: z.string().optional().describe('The generated audio URI'),
208159
},
209160
async (input) => {
210161
const response = await ai.generate({
@@ -233,16 +184,7 @@ export const multiSpeakerTextToSpeechFlow = ai.defineFlow(
233184
},
234185
});
235186
236-
const audioUrl = response.media?.url;
237-
if (!audioUrl)
238-
throw new Error('Audio generation failed: No media URL in response.');
239-
240-
const base64 = audioUrl.split(';base64,')[1];
241-
if (!base64) throw new Error('Invalid audio data URI format from Genkit.');
242-
243-
const pcmBuffer = Buffer.from(base64, 'base64');
244-
const audioDataUri = await pcmToWavDataUri(pcmBuffer);
245-
return { audioDataUri };
187+
return response.media?.url;
246188
}
247189
);
248190
```
@@ -254,18 +196,13 @@ export const multiSpeakerTextToSpeechFlow = ai.defineFlow(
254196
### Image Generation
255197
256198
```ts
257-
import * as fs from 'fs/promises';
258-
import parseDataURL from 'data-urls';
259-
260-
...
261-
262199
export const imageGenerationFlow = ai.defineFlow(
263200
{
264201
name: 'imageGenerationFlow',
265202
inputSchema: z
266203
.string()
267204
.describe('A detailed description of the image to generate'),
268-
outputSchema: z.string().describe('Path to the generated .png image file'),
205+
outputSchema: z.string().optional().describe('The generated image as URI'),
269206
},
270207
async (prompt) => {
271208
const response = await ai.generate({
@@ -274,18 +211,7 @@ export const imageGenerationFlow = ai.defineFlow(
274211
output: { format: 'media' },
275212
});
276213
277-
if (!response.media?.url) {
278-
throw new Error('Image generation failed to produce media.');
279-
}
280-
281-
const parsed = parseDataURL(response.media.url);
282-
if (!parsed) {
283-
throw new Error('Could not parse image data URL.');
284-
}
285-
286-
const outputPath = './output.png';
287-
await fs.writeFile(outputPath, parsed.body);
288-
return outputPath;
214+
return response.media?.url;
289215
}
290216
);
291217
```

genkit-tools/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "genkit-cli",
3-
"version": "1.20.0",
3+
"version": "1.22.0-rc.0",
44
"description": "CLI for interacting with the Google Genkit AI framework",
55
"license": "Apache-2.0",
66
"keywords": [

genkit-tools/cli/src/cli.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ export async function startCLI(): Promise<void> {
138138
logger.info(program.help());
139139
})
140140
);
141-
// Default action to catch unknown commands.
142-
program.action(() => {
143-
// print help
141+
// Handle unknown commands.
142+
program.on('command:*', (operands) => {
143+
logger.error(`error: unknown command '${operands[0]}'`);
144144
logger.info(program.help());
145+
process.exit(1);
145146
});
146147

147148
await program.parseAsync();

genkit-tools/cli/src/utils/updates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export async function showUpdateNotification(): Promise<void> {
232232
? 'installer script'
233233
: 'your package manager';
234234
const updateCommand = isCompiledBinary
235-
? 'curl -sL cli.genkit.dev | uninstall=true bash'
235+
? 'curl -sL cli.genkit.dev | upgrade=true bash'
236236
: 'npm install -g genkit-cli';
237237

238238
const updateNotificationMessage =

genkit-tools/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@genkit-ai/tools-common",
3-
"version": "1.20.0",
3+
"version": "1.22.0-rc.0",
44
"scripts": {
55
"compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
66
"build:clean": "rimraf ./lib",

0 commit comments

Comments
 (0)