Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions js/core/src/reflection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import getPort, { makeRange } from 'get-port';
import type { Server } from 'http';
import path from 'path';
import * as z from 'zod';
import {
StatusCodes,
runWithStreamingCallback,
type Status,
} from './action.js';
import { StatusCodes, type Status } from './action.js';
import { GENKIT_REFLECTION_API_SPEC_VERSION, GENKIT_VERSION } from './index.js';
import { logger } from './logging.js';
import type { Registry } from './registry.js';
Expand Down Expand Up @@ -173,16 +169,11 @@ export class ReflectionServer {
const callback = (chunk) => {
response.write(JSON.stringify(chunk) + '\n');
};
const result = await runWithStreamingCallback(
this.registry,
callback,
() =>
action.run(input, {
context,
onChunk: callback,
telemetryLabels,
})
);
const result = await action.run(input, {
context,
onChunk: callback,
telemetryLabels,
});
await flushTracing();
response.write(
JSON.stringify({
Expand Down
21 changes: 5 additions & 16 deletions js/plugins/express/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
import bodyParser from 'body-parser';
import cors, { type CorsOptions } from 'cors';
import express from 'express';
import {
runWithStreamingCallback,
type Action,
type ActionContext,
type Flow,
type z,
} from 'genkit';
import { type Action, type ActionContext, type Flow, type z } from 'genkit';
import {
getCallableJSON,
getHttpStatus,
Expand Down Expand Up @@ -110,16 +104,11 @@ export function expressHandler<
'data: ' + JSON.stringify({ message: chunk }) + streamDelimiter
);
};
const result = await runWithStreamingCallback(
action.__registry,
const result = await action.run(input, {
onChunk,
() =>
action.run(input, {
onChunk,
context,
abortSignal: abortController.signal,
})
);
context,
abortSignal: abortController.signal,
});
response.write(
'data: ' + JSON.stringify({ result: result.result }) + streamDelimiter
);
Expand Down
12 changes: 4 additions & 8 deletions js/testapps/flow-simple-ai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export const jokeFlow = ai.defineFlow(
{
name: 'jokeFlow',
inputSchema: z.object({
modelName: z.string().default('vertexai/gemini-2.5-pro-exp-03-25'),
modelVersion: z.string().optional().default('gemini-2.5-pro-exp-03-25'),
modelName: z.string().default('vertexai/gemini-2.5-pro'),
modelVersion: z.string().optional().default('gemini-2.5-pro'),
subject: z.string().default('bananas'),
}),
outputSchema: z.string(),
Expand Down Expand Up @@ -963,7 +963,7 @@ ai.defineFlow('embedders-tester', async () => {
ai.defineFlow('reasoning', async (_, { sendChunk }) => {
const { message } = await ai.generate({
prompt: 'whats heavier, one kilo of steel or or one kilo of feathers',
model: googleAI.model('gemini-2.5-flash-preview-04-17'),
model: googleAI.model('gemini-2.5-flash'),
config: {
thinkingConfig: {
thinkingBudget: 1024,
Expand All @@ -979,11 +979,7 @@ ai.defineFlow('reasoning', async (_, { sendChunk }) => {
ai.defineFlow(
{
name: 'audioSimple',
inputSchema: z
.string()
.default(
'say that that Genkit (G pronounced as J) is an amazing Gen AI library'
),
inputSchema: z.string().default('AI can be fun, eh?'),
outputSchema: z.object({ media: z.string() }),
},
async (query) => {
Expand Down