genkit icon indicating copy to clipboard operation
genkit copied to clipboard

[Tooling] After migration, Genkit UI doesn't seem to find runtime

Open EduardWayland opened this issue 2 years ago • 12 comments

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: image

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?

EduardWayland avatar Nov 16 '24 12:11 EduardWayland

Same issue

JimmyOnGitHub avatar Nov 17 '24 01:11 JimmyOnGitHub

Same here. I am using Ubuntu 24.04

I hope these screenshots help to narrow down the problem: Screenshot from 2024-11-17 10-03-48 Screenshot from 2024-11-17 10-03-11

Soolan avatar Nov 17 '24 02:11 Soolan

Same here +1

ahmetyazir22 avatar Nov 17 '24 10:11 ahmetyazir22

Same here

jmsegrev avatar Nov 17 '24 15:11 jmsegrev

I was facing similar situation, I was able to solve it. Noticed a few things:

  1. The flow server is not part of genkit start, so you have to set it up and initialize it manually.
  2. 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.

jmsegrev avatar Nov 18 '24 00:11 jmsegrev

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.

pavelgj avatar Nov 18 '24 04:11 pavelgj

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.

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 avatar Nov 18 '24 13:11 EduardWayland

@EduardWayland your fix is now released in 0.9.2

https://github.com/firebase/genkit/releases/tag/genkit%400.9.2

pavelgj avatar Nov 18 '24 15:11 pavelgj

Bug still exists in 0.9.2

JimmyOnGitHub avatar Nov 19 '24 11:11 JimmyOnGitHub

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.

OmarBakry-eg avatar Nov 19 '24 12:11 OmarBakry-eg

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.

EduardWayland avatar Nov 19 '24 12:11 EduardWayland

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 屏幕截图 2024-12-07 002633

I have the same problem, may I ask if you have solved it

553058001 avatar Dec 06 '24 16:12 553058001