Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
EduardWayland opened this issue Nov 16, 2024 · 11 comments
Closed
Labels
bug Something isn't working tooling

Comments

@EduardWayland
Copy link
Contributor

EduardWayland commented Nov 16, 2024

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?

@JimmyOnGitHub
Copy link

Same issue

@Soolan
Copy link

Soolan commented Nov 17, 2024

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

@ahmetyazir22
Copy link

Same here +1

@jmsegrev
Copy link

Same here

@jmsegrev
Copy link

jmsegrev commented Nov 18, 2024

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.

@pavelgj
Copy link
Collaborator

pavelgj commented Nov 18, 2024

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.

@EduardWayland
Copy link
Contributor Author

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.

@pavelgj
Copy link
Collaborator

pavelgj commented Nov 18, 2024

@EduardWayland your fix is now released in 0.9.2

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

@JimmyOnGitHub
Copy link

Bug still exists in 0.9.2

@OmarBakry-eg
Copy link

OmarBakry-eg commented Nov 19, 2024

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.

@EduardWayland
Copy link
Contributor Author

EduardWayland commented Nov 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tooling
Projects
Status: Done
Development

No branches or pull requests

7 participants