Build Firebase Genkit NodeJS apps with Dash Agents | Skip the docs
Learn how to get started with Firebase Genkit, an open source framework to build, deploy, and monitor production-ready AI-powered apps.
Ask AI Expert for Genkit
Skip this tutorial and get personalized steps and code for your usecase.
Firebase Genkit is an open-source framework that makes it easy for developers to build, deploy, and monitor Generative AI applications.
It aims to streamline the integration of various AI models, including Google's Gemini, Anthropic models, and locally hosted models like Gemma, Llama 2, and Mistral in your NodeJs apps.
Goal
In this article, we will "Build a travel API that takes a city name and tells us top 5 places to visit there along with the kind of activity - Adventure, Eat out, Relaxation and Shopping"
Introducing Dash Agent for Firebase Genkit
We will use the @Firebase Genkit
agent in CommandDash to avoid reading docs and directly get integration code for our usecases.
Dash agents stay upto date with the latest docs, examples and github issues and assist us from the IDE.
Install from CommandDash marketplace in VSCode (other IDEs coming soon):
Now with the Firebase Genkit agent in place, let's start building. Any interactions with the agent are quoted like below:
Hi Firebase Genkit! Let's start building 👋🏼
Setting up your project.
I want to create a NodeJS project using Firebase Genkit. What are the setup steps?
To start a Node.js project using Genkit, follow these steps.
Install the Genkit CLI:
Create a new Node project:
Initialize a Genkit project:
Follow the prompts to configure your project.
If you have any specific setup queries or face any issues, ask CommandDash for help!
Making the LLM Request
Now, to setup the LLM Request for this, we first need to choose a model, create our input and output schemas, write a suitable prompt and parse the result.
Fortunately, we can skip this work and just ask the Genkit Agent:
Build a travel API that accepts a city name and tells us top 5 places to visit there along with the kind of activity - Adventure, Eat out, Relaxation or Shopping
We've got the entire flow setup for us with schema, request and parsers all added.
Now, let's start the Genkit Developer UI to test our request.
The flow opens up in the Firebase Genkit Developer UI:
Upon entering the city name and hitting run, we encounter the error 🚨:
Fixing Runtime Errors
To fix this, let's move to our IDE and log the llmResponse.text()
to get more context on the issue.
Then paste the output along the error in the agent and attach the code using Attach Snippet to Dash
in the menu bar.
Help me fix this error: [paste the log and errors from the console] (attach your code file)
Here's how you can update your travelRecommendationFlow function to address the invalid JSON format:
After adding the fix, let's re-run the flow from the UI.
And it runs! We've created our first Firebase Genkit Flow 🙌🏼
You can also run your NodeJS project and make the API request:
Genkit facilitates deployment on serverless platforms like Firebase Cloud Functions, Google Cloud Run, or other environments that can serve an Express.js app.
Take it ahead yourself by asking:
How do I deploy my genkit app to Firebase Cloud Function?
Try it out yourself and build your Genkit usecase instantly with CommandDash. We always love to hear what you build!