[Tooling] After migration, Genkit UI doesn't seem to find runtime
I was using Genkit 0.5 and everything was working correctly. Then I migrated to Genkit 0.9 following the guide at https://firebase.google.com/docs/genkit/migrating-from-0.5 and the UI doesn't seem to start up properly.
It opens up with "Waiting to connect to Genkit runtime" and I see it's making requests to "http://localhost:4000/api/getCurrentRuntime?batch=1&input=%7B%7D" in loop, the response is always: HttpCode: 200, body: [{"result":{"data":{}}}].
Here a screenshot of what shows up in the UI:
I have also tried to make a new project from scratch by following the installation guide here: https://firebase.google.com/docs/genkit/get-started, but same result...
Here a snippet of one of the sample code I'm trying to startup:
// import the Genkit and Google AI plugin libraries
import { gemini15Flash, googleAI } from '@genkit-ai/googleai';
import { genkit } from 'genkit';
// configure a Genkit instance
const ai = genkit({
plugins: [googleAI()],
model: gemini15Flash, // set default model
});
export const menuSuggestionFlow = ai.defineFlow(
{
name: 'menuSuggestionFlow',
},
async (restaurantTheme) => {
const { text } = await ai.generate({
model: gemini15Flash,
prompt: `Invent a menu item for a ${restaurantTheme} themed restaurant.`,
});
return text;
}
);
const flows = [menuSuggestionFlow];
ai.startFlowServer({flows})
Is there something I'm missing? Do I need to do some other kind of configuration somewhere else?
Same issue
Same here. I am using Ubuntu 24.04
I hope these screenshots help to narrow down the problem:
Same here +1
Same here
I was facing similar situation, I was able to solve it. Noticed a few things:
- The flow server is not part of
genkit start, so you have to set it up and initialize it manually. - GENKIT_ENV=dev needs to be set for the flow server.
// flows/server.ts
import { genkit } from "genkit";
import { gemini15Flash, googleAI } from "@genkit-ai/googleai";
import { logger } from "genkit/logging";
import { getInputMessageFlow } from "../../flows/input-message/flow";
import { getChatFlow } from "../../flows/chat/flow";
const ai = genkit({
plugins: [
googleAI(),
],
model: gemini15Flash,
});
logger.setLogLevel("debug");
const chatFlow = ai.defineFlow(...);
const inputMessageFlow = ai.defineFlow(...);
ai.startFlowServer({
flows: [
chatFlow,
inputMessageFlow,
],
});
After build GENKIT_ENV=dev node dist/flows/server.js. After this running genkit start will connect to your flows.
Note the changes to how to run the Genkit Dev UI: https://firebase.google.com/docs/genkit/migrating-from-0.5#5_run_it
The full command is:
genkit start -- <command to run node>
Ex:
genkit start -- npm run dev
If you just run genkit start it no longer runs your code (it only starts the UI). You'd have to manually run it along with setting the GENKIT_ENV env var. Which works, just requires extra steps.
Note the changes to how to run the Genkit Dev UI: https://firebase.google.com/docs/genkit/migrating-from-0.5#5_run_it
The full command is:
genkit start -- <command to run node>Ex:
genkit start -- npm run devIf you just run
genkit startit no longer runs your code (it only starts the UI). You'd have to manually run it along with setting the GENKIT_ENV env var. Which works, just requires extra steps.
As I said, I followed the migration guide. I've investigated more in deep and I opened a PR that solves the issue. It's about how runtime files are generated and compatibility with Windows file system.
@EduardWayland your fix is now released in 0.9.2
https://github.com/firebase/genkit/releases/tag/genkit%400.9.2
Bug still exists in 0.9.2
I solved the issue by setting the GOOGLE_GENAI_API_KEY inside functions folder via this command:
export GOOGLE_GENAI_API_KEY=<your API key>
You've to make sure that you're targeting the right project while creating the api key from Google AI Studio
Then Inside functions folder I ran this command npm run genkit:start and that's solved my issue.
Bug still exists in 0.9.2
@JimmyOnGitHub I can confirm that the bug is now fixed, ensure you're executing both commands shown in the guide:
- tsx --watch src/index.ts, this will effectively start-up the server and you should see a line "Runtime file written:
" with logger level set to "debug". Tell use if you see this line or if you see any runtime file generated in .genkit/runtimes. - in another terminal, run genkit start from the directory that contains the package.json etc.
The problem that has been fixed is described in the PR.
genkit start -- go run main.go
[Telemetry Server] initialized local file trace store at root: C:\Users\55305\Desktop\gen.genkit\traces
Telemetry API running on http://localhost:4033
Genkit Developer UI: http://localhost:4000
time=2024-12-07T00:24:45.081+08:00 level=INFO msg=RegisterAction type=model name=googleai/gemini-1.5-flash
time=2024-12-07T00:24:45.086+08:00 level=INFO msg=RegisterAction type=model name=googleai/gemini-1.0-pro
time=2024-12-07T00:24:45.086+08:00 level=INFO msg=RegisterAction type=model name=googleai/gemini-1.5-pro
time=2024-12-07T00:24:45.086+08:00 level=INFO msg=RegisterAction type=embedder name=googleai/text-embedding-004
time=2024-12-07T00:24:45.086+08:00 level=INFO msg=RegisterAction type=embedder name=googleai/embedding-001
time=2024-12-07T00:24:45.087+08:00 level=INFO msg=RegisterAction type=flow name=menuSuggestionFlow
time=2024-12-07T00:24:45.087+08:00 level=INFO msg="starting reflection server"
time=2024-12-07T00:24:45.087+08:00 level=INFO msg="starting flow server"
time=2024-12-07T00:24:45.087+08:00 level=INFO msg="server listening" addr=127.0.0.1:3400
time=2024-12-07T00:24:45.087+08:00 level=INFO msg="all servers started successfully"
time=2024-12-07T00:24:45.087+08:00 level=INFO msg="server listening" addr=127.0.0.1:3100
I have the same problem, may I ask if you have solved it