<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Firebase Developers - Medium]]></title>
        <description><![CDATA[Tutorials, deep-dives, and random musings from Firebase developers all around the world. Views expressed are those of the authors and don’t necessarily reflect those of Firebase or its parent companies. - Medium]]></description>
        <link>https://medium.com/firebase-developers?source=rss----8e8b7dc6774d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Firebase Developers - Medium</title>
            <link>https://medium.com/firebase-developers?source=rss----8e8b7dc6774d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:13:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/firebase-developers" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Beyond the Spinner: Building Responsive AI Apps with Genkit Streaming]]></title>
            <link>https://medium.com/firebase-developers/streaming-made-easy-with-genkit-a6f9da52a76a?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a6f9da52a76a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genkit]]></category>
            <dc:creator><![CDATA[Pavel J]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 10:35:17 GMT</pubDate>
            <atom:updated>2025-10-28T10:35:17.067Z</atom:updated>
            <content:encoded><![CDATA[<h4>Better AI UX</h4><h4>A practical guide to streaming LLM responses, partial JSON, and custom status messages to eliminate perceived latency.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6g9SAP8b-jRbV8iH5PmmA.png" /></figure><p>In the new age of AI, streaming structured data has suddenly become useful and mainstream. The main reason is that LLMs can be slow, and a good user experience (UX) strives to reduce this <em>perceived latency</em>. We <em>could</em> show a spinner for a few seconds, but that feels slow. Instead, if we start rendering content as soon as we receive the first few tokens from the LLM, the user can watch the response “grow in front of their eyes.” Even if the end-to-end time is the same, it <em>feels</em> faster because the user sees activity immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdEmVwISiOSAh5DO4o54Kg.gif" /></figure><p>BTW, this sample app (streaming side only) is available at:<br><a href="https://github.com/genkit-ai/samples/tree/main/simple-chatbot">https://github.com/genkit-ai/samples/tree/main/simple-chatbot</a></p><p>Streaming is foundational to Genkit’s design. Everything in Genkit is built on top of <em>actions</em> — simple, function-like constructs that, among other things, can stream. Models are actions, and flows are actions, so they can all stream.</p><h3>LLM streams</h3><p>Let’s start with receiving streams from LLMs. The most common and useful way is to use the generateStream function:</p><pre>const { stream, response } = ai.generateStream({<br>  prompt: &#39;Tell me a story about AI&#39;,<br>});<br><br>for await (const chunk of stream) {<br>  process.stdout.write(chunk.text);<br>}<br><br>// optional<br>const finalResponse = await response;<br>console.log(finalResponse.usage);<br>console.log(finalResponse.messages); // history</pre><p>In addition to the stream of “generate response chunks,” we can optionally await the response promise. This is useful because it contains final usage data (like token counts), the complete message array (great for tracking history), and other metadata.</p><p>If you don’t like using the for await syntax and prefer callbacks, there’s another less known way to stream using the generate function, by providing the onChunk callback:</p><pre>const response = await ai.generate({<br>  prompt: &#39;Tell me a story aboud AI&#39;,<br>  onChunk: (chunk) =&gt; process.stdout.write(chunk.text),<br>});<br>console.log(response.usage);</pre><p>If you’re using <a href="https://genkit.dev/docs/dotprompt/">prompts</a>, you can call prompts in streaming mode as well:</p><pre>const { stream, response } = myPrompt.stream({<br>  input: &#39;hello&#39;,<br>});<br>for await (const chunk of stream) { ... }<br>const finalResponse = await response;</pre><p>In addition to streaming simple text from LLMs, we can stream structured data. Let’s borrow the recipe generator sample from the <a href="https://genkit.dev/docs/get-started/#create-your-first-application">getting started</a> guide, but add streaming to it:</p><pre>const RecipeSchema = z.object({<br>  title: z.string(),<br>  description: z.string(),<br>  prepTime: z.string(),<br>  cookTime: z.string(),<br>  servings: z.number(),<br>  ingredients: z.array(z.string()),<br>  instructions: z.array(z.string()),<br>  tips: z.array(z.string()).optional(),<br>});<br><br>const { stream } = ai.generateStream({<br>  prompt: &#39;Generate a recipe using: banana, chicken&#39;,<br>  output: { schema: RecipeSchema },<br>});<br><br>for await (const chunk of stream) {<br>  console.log(JSON.stringify(chunk.output));<br>}</pre><p>Note that inside the for await loop, we&#39;re using chunk.output instead of chunk.text. The output getter parses JSON from the accumulated stream. You can imagine that at any given moment, the JSON might be incomplete. A regular parser would throw an error on unclosed braces or quotes, but Genkit uses a special parser that handles incomplete JSON, returning as much of the object as it can parse. Here is how this might look:</p><pre>// chunk 1<br>{<br>  &quot;title&quot;: &quot;Spicy Peanut Chicken with Caramelized Banana&quot;,<br>  &quot;description&quot;: &quot;A delightful fusion of savory and sweet, this dish features tender chicken simmered in a creamy, spicy&quot;<br>}<br><br>// chunk 2<br>{<br>  &quot;title&quot;: &quot;Spicy Peanut Chicken with Caramelized Banana&quot;,<br>  &quot;description&quot;: &quot;A delightful fusion of savory and sweet, this dish features tender chicken simmered in a creamy, spicy peanut sauce, complemented by the sweetness of caramelized bananas. Perfect served over rice.&quot;,<br>  &quot;prepTime&quot;: &quot;20 minutes&quot;,<br>  &quot;servings&quot;: 4,<br>  &quot;ingredients&quot;: [<br>    &quot;1.5&quot;<br>  ]<br>}<br><br>// chunk 3<br>{<br>  &quot;title&quot;: &quot;Spicy Peanut Chicken with Caramelized Banana&quot;,<br>  &quot;description&quot;: &quot;A delightful fusion of savory and sweet, this dish features tender chicken simmered in a creamy, spicy peanut sauce, complemented by the sweetness of caramelized bananas. Perfect served over rice.&quot;,<br>  &quot;prepTime&quot;: &quot;20 minutes&quot;,<br>  &quot;servings&quot;: 4,<br>  &quot;ingredients&quot;: [<br>    &quot;1.5 lbs chicken breast or thighs, cut into 1-inch pieces&quot;,<br>    &quot;2 tbsp vegetable oil&quot;,<br>    &quot;1 medium onion, chopped&quot;,<br>    &quot;3 cloves garlic, minced&quot;,<br>    &quot;1 inch fresh ginger, grated&quot;,<br>  ]<br>}<br><br>// chunk 4<br>{<br>  &quot;title&quot;: &quot;Spicy Peanut Chicken with Caramelized Banana&quot;,<br>  &quot;description&quot;: &quot;A delightful fusion of savory and sweet, this dish features tender chicken simmered in a creamy, spicy peanut sauce, complemented by the sweetness of caramelized bananas. Perfect served over rice.&quot;,<br>  &quot;prepTime&quot;: &quot;20 minutes&quot;,<br>  &quot;cookTime&quot;: &quot;25 minutes&quot;,<br>  &quot;servings&quot;: 4,<br>  &quot;ingredients&quot;: [<br>    &quot;1.5 lbs chicken breast or thighs, cut into 1-inch pieces&quot;,<br>    &quot;2 tbsp vegetable oil&quot;,<br>    &quot;1 medium onion, chopped&quot;,<br>    &quot;3 cloves garlic, minced&quot;,<br>    &quot;1 inch fresh ginger, grated&quot;,<br>  ],<br>  &quot;instructions&quot;: [<br>    &quot;Season chicken&quot;<br>  ]<br>}<br><br>// and so on</pre><h3>Streaming data out</h3><p>Above we’ve seen how to receive streams from LLMs. If that’s all you need, you can just use Genkit that way. But now let’s see how we can build custom AI logic that streams data <em>out</em>. Flows in Genkit allow us to encapsulate AI logic, and if the AI logic is receiving streams we often want to output the same (or transformed) stream back to the clients of our flow (e.g. a web app).</p><p>Let’s go back to the recipe generator example and wrap it into a streaming flow:</p><pre>export const recipeGenerator = ai.defineFlow(<br>  {<br>    name: &#39;recipeGenerator&#39;,<br>    inputSchema: RecipeInputSchema,<br>    outputSchema: RecipeSchema,<br>    streamSchema: RecipeSchema.partial(),<br>  },<br>  async (input, { sendChunk }) =&gt; {<br>    const prompt = `Create a recipe with the following requirements:<br>      Main ingredient: ${input.ingredient}<br>      Dietary restrictions: ${input.dietaryRestrictions || &#39;none&#39;}`;<br><br>    const { stream, response } = await ai.generateStream({<br>      prompt,<br>      output: { schema: RecipeSchema },<br>    });<br><br>    for await (const chunk of stream) {<br>      sendChunk(chunk.output as z.infer&lt;typeof RecipeSchema&gt;);<br>    }<br><br>    return (await response).output!;<br>  }<br>);</pre><p>A few things to point out:</p><ul><li>we’re specifying the streamSchema in the flow metadata. It’s optional, but it helps with type safety because it enforces stricter typing of the sendChunk function.</li><li>the flow function takes in a second argument, which we destructure to access sendChunk function. As mentioned above, this function accepts the object of type specified in streamSchema. When called it sends the contents as a stream chunk.</li><li>we call sendChunk inside the for await loop. We&#39;re effectively piping the incoming LLM stream to the flow&#39;s output stream, transforming it along the way (raw LLM chunk -&gt; parsed partial JSON). Since it&#39;s just code, we&#39;re free to perform any logic here.</li><li>the client might call the flow in streaming or non-streaming mode, but we shouldn’t really care about how the client is calling it. If the flow is called in non-streaming mode, then sendChunk is just a no-op. The code will still work as is, as long as we return something useful at the end (final return).</li></ul><p>When we need to stream out LLM messages, Genkit provides schemas that we can use to set types on our flow. Let’s wrap a simple generator in a flow:</p><pre>import {<br>  GenerateResponseChunkSchema,<br>  GenerateResponseSchema,<br>  PartSchema,<br>} from &#39;genkit/model&#39;;<br><br>export const storyGenerator = ai.defineFlow(<br>  {<br>    name: &#39;storyGenerator&#39;,<br>    inputSchema: z.array(PartSchema),<br>    outputSchema: GenerateResponseSchema,<br>    streamSchema: GenerateResponseChunkSchema,<br>  },<br>  async (content, { sendChunk }) =&gt; {<br>    const { stream, response } = ai.generateStream({<br>      prompt: content,<br>    });<br><br>    for await (const chunk of stream) {<br>      sendChunk(chunk);<br>    }<br><br>    return await response;<br>  }<br>);</pre><p>There are also MessageSchema, TextPartSchema, MediaSchema, etc… schemas for all occasions. And if you need simple Typescript interfaces instead of Zod schemas, just replace *Schema with *Data (ex. MessageData, GenerateResponseData, etc. except Part… it’s just Part… don’t ask 🤦).</p><p>The fun part is that we can create hybrid schemas by combining custom object and built-in model messages. Sometimes we might have to implement a complex multistep workflow during which, for example, we might want to notify our flow client about the progress:</p><pre>const CustomChunkSchema = z.object({<br>  statusUpdate: z.string().optional(),<br>  chunk: GenerateResponseChunkSchema.optional(),<br>});<br><br>export const myMegaFlow = ai.defineFlow(<br>  {<br>    name: &#39;myMegaFlow&#39;,<br>    inputSchema: z.array(PartSchema),<br>    outputSchema: GenerateResponseSchema,<br>    streamSchema: CustomChunkSchema,<br>  },<br>  async (content, { sendChunk }) =&gt; {<br>    // step 1<br>    sendChunk({ statusUpdate: &#39;Fetching data...&#39; });<br>    // ...<br><br>    // step 2<br>    sendChunk({ statusUpdate: &#39;Aggregating data...&#39; });<br>    // ...<br><br>    // step 3<br>    sendChunk({ statusUpdate: &#39;Generating...&#39; });<br><br>    const { stream, response } = ai.generateStream({<br>      prompt: content, // generatePromptUsingFetchedData(),<br>    });<br><br>    for await (const chunk of stream) {<br>      sendChunk({ chunk });<br>    }<br><br>    sendChunk({ statusUpdate: &#39;Done. Enjoy!&#39; });<br><br>    return await response;<br>  }<br>);</pre><p>And we can call our flow in streaming mode from code:</p><pre>const { stream } = myMegaFlow.stream([<br>  { text: &#39;pretend to be busy for a while&#39; },<br>]);<br>for await (const chunk of stream) {<br>  console.log({ chunk });<br>}</pre><p>We will see something like:</p><pre>{ &quot;statusUpdate&quot;: &quot;Fetching data...&quot; }<br><br>{ &quot;statusUpdate&quot;: &quot;Aggregating data...&quot; }<br><br>{ &quot;statusUpdate&quot;: &quot;Generating...&quot; }<br><br>{<br>  &quot;chunk&quot;: {<br>    &quot;role&quot;: &quot;model&quot;,<br>    &quot;index&quot;: 0,<br>    &quot;content&quot;: [ { &quot;text&quot;: &quot;...&quot; } ]<br>  }<br>}<br><br>// more chunks<br><br>{ &quot;statusUpdate&quot;: &quot;Done. Enjoy!&quot; }</pre><p>Or we can call our flow from the <a href="https://genkit.dev/docs/devtools/">Genkit Dev UI</a>, which IMO is the most convenient way to test and debug AI logic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1VjH025Wd31EG5hvpUitqw.gif" /></figure><p>You might have noticed that flows don’t <em>have</em> to contain AI logic. You can use them to implement arbitrary streaming or non-streaming logic. For example, the simple-chatbot sample has a flow that just <a href="https://github.com/genkit-ai/samples/blob/165f0be4fcdd17378aefc90e0f78a8e5a65164f1/simple-chatbot/src/genkit.ts#L14">returns conversation history</a>. ;)</p><h3>Where to go from here</h3><p>In the next article I’ll show you how to turn your flows into APIs and call your flows (and stream) from a client web app. Check out:</p><p><a href="https://medium.com/@pavel.jbanov/full-stack-ai-made-easy-with-genkit-c0c393118cde">Full-Stack AI Made Easy with Genkit</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6f9da52a76a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/streaming-made-easy-with-genkit-a6f9da52a76a">Beyond the Spinner: Building Responsive AI Apps with Genkit Streaming</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Arc: An AI Messenger Powered by Firebase, Flutter, and Vertex AI]]></title>
            <link>https://medium.com/firebase-developers/building-arc-an-ai-messenger-powered-by-firebase-flutter-and-vertex-ai-f8a3d947c247?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/f8a3d947c247</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[messenger]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[TAKAYUKI MIYANO]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 07:49:55 GMT</pubDate>
            <atom:updated>2025-10-27T07:49:54.165Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction: The Vision of Arc</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*cc3BGDLhrIhgD3vSVKbXog.png" /></figure><p>Our journey at <a href="https://www.atlasassociates.io/arc"><strong>Arc</strong></a> began with a singular vision: to redefine private communication in the digital age. We envisioned a world of ephemeral, intimate conversations — a space where privacy isn’t an afterthought, but the very foundation. This philosophy gave birth to Arc, a next-generation messaging app where every message, even in group chats, is designed to disappear over time.</p><p>Our vision goes beyond just ephemerality. We also saw a critical need to build resilience, especially in regions with unstable internet infrastructure and in a world where disasters are a constant threat. This led us to develop our mesh networking technology, a potential lifeline when traditional communication fails. Our mission is to transform our app into a vital piece of social infrastructure that protects people’s safety and gives them peace of mind.</p><p>However, a vision of this scale demands an architecture that can compete on a global level. For us, true “optimization” is a comprehensive concept built on four pillars: <strong>Stability, Speed, Lightweight Design, and High Security</strong>.</p><p>In this article, we’ll explore the architectural decisions that shaped Arc. We’ll detail how we integrated Flutter as our client, used Firebase’s managed services as our foundation, and combined them with Cloud Run for scalable microservices, Cloud Functions for event-driven processing, and an advanced RAG (Retrieval-Augmented Generation) architecture using Vertex AI Search for grounding and Gemini models. This is the story of how we built a platform that is not only secure and high-performance but also intelligent and ready for future evolution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*c7lIkwuGYRlXb4Db7cSt0g.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fh8ZU9NyUsc_0HrmStEyQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEumC22T_w0SwpPgZewC-w.png" /></figure><h3>The Challenge: Going Beyond a Standard Messenger</h3><p>To make <strong>Arc</strong> a reality, we faced numerous technical hurdles that went beyond conventional architectures. Our goal wasn’t just to build another messaging app; it was to create a new conversational experience and a resilient communication platform. Our app also includes GenAI companions (AI Characters) to provide empathetic support. This required a robust backend for our AI characters, uncompromising security for user data, and a high-performance client application. We also aimed to solve a larger, more fundamental problem: protecting users’ privacy from third parties. This “<strong>Defense Tech</strong>” philosophy is at the heart of our architecture, designed to provide a level of <strong>secure communication and privacy protection that professionals like government officials and lawyers can use with confidence.</strong></p><h3>The Client — A Fluid UX with Optimized Flutter</h3><p>We chose <a href="https://flutter.dev/">Flutter</a> for its ability to deliver high-fidelity experiences across platforms from a single codebase. This strategic choice has enabled our compact team to achieve high development velocity. In the 34 months since Arc’s public launch, we have released 144 updates — an average of more than four per month. We plan to settle into a bi-weekly cycle to focus on larger features, but this agility is our core strength.</p><p>Performance is paramount. The “lag” often attributed to cross-platform frameworks is not a limitation of the tool, but a challenge of implementation. We tackled this with a rigorous optimization process:</p><ul><li><strong>Static Analysis with </strong><a href="https://dcm.dev/"><strong>Dart Code Metrics (DCM)</strong></a><strong>:</strong> We enforce strict code quality standards, identifying complex and inefficient patterns before they become performance bottlenecks.</li><li><strong>Dynamic Profiling with </strong><a href="https://docs.flutter.dev/tools/devtools"><strong>Flutter DevTools</strong></a><strong>:</strong> We dive deep into frame rendering times (UI and GPU threads), CPU usage, and memory allocation to identify and eliminate sources of jank at the millisecond level. Our focus is on minimizing widget rebuilds through meticulous state management and efficient layout rendering.</li></ul><h3>A Hybrid Approach with Firebase, Cloud Run and Vertex AI</h3><p>Our app is not a monolith but a collection of specialized services, choosing the best tool for each job.</p><p><strong>A. Firebase for the Core Experience:</strong> For real-time messaging, user authentication, monitoring, and core application state management, the development speed and seamless integration of the Firebase suite are second to none.</p><ul><li><a href="https://firebase.google.com/docs/firestore"><strong>Firestore</strong></a><strong>:</strong> Serves as the primary database for ephemeral message data and user profiles, providing real-time synchronization and robust offline capabilities.</li><li><a href="https://firebase.google.com/docs/auth"><strong>Firebase Authentication</strong></a><strong> &amp; </strong><a href="https://www.atlasassociates.io/arc/ciphergrid"><strong>Ciphergrid</strong></a><strong>:</strong> We integrate standard social providers with Ciphergrid, our proprietary blockchain-based digital ID. This is managed via Firebase Authentication’s custom token system, providing a federated yet highly secure identity layer.</li><li><a href="https://firebase.google.com/docs/app-check"><strong>App Check</strong></a><strong>:</strong> Enforces that all backend requests originate from a legitimate, untampered app instance. This is a critical defense layer against abuse and unauthorized clients.</li><li><a href="https://firebase.google.com/docs/perf-mon"><strong>Performance Monitoring</strong></a>: Helps us to identify and resolve performance bottlenecks, such as slow start times or API call latency, ensuring a fluid user experience even in low-connectivity areas.</li><li><a href="https://firebase.google.com/docs/analytics"><strong>Google Analytics</strong></a><strong>: </strong>Provides deep insights into user behavior and engagement, allowing us to validate our feature roadmap and make data-driven decisions. By combining both, we can quickly pinpoint the root cause of app quality issues and deliver continuous, data-informed improvements.</li></ul><p><strong>B. </strong><a href="https://cloud.google.com/run"><strong>Cloud Run</strong></a><strong> for Scalable and Complex Logic:</strong> While <a href="https://cloud.google.com/functions">Cloud Run functions</a> excels at event-driven tasks, we used <a href="https://cloud.google.com/run/docs/managing/services">Cloud Run services</a> for more complex, stateful, or computationally intensive microservices. The orchestration of our AI characters is a prime example. Although currently manageable with Cloud Run functions, migrating this core logic to Cloud Run services unlocks several advantages:</p><ul><li><strong>Flexibility in Languages and Dependencies:</strong> We can use any containerized environment, allowing us to choose the absolute best tool for a specific AI task.</li><li><strong>Concurrency and Performance:</strong> Cloud Run services offers fine-grained control over concurrency, CPU allocation, and instance scaling, enabling us to optimize both cost and latency for AI inference workloads.</li><li><strong>Decoupled Architecture:</strong> Treating the AI service as a distinct microservice on Cloud Run isolates it from the main Firebase event bus, allowing it to evolve independently and potentially serve other applications in the future.</li></ul><p>C. <strong>AI — Intelligent Conversations with </strong><a href="https://firebase.google.com/docs/ai-logic"><strong>Gemini using Firebase AI Logic</strong></a><strong> and </strong><a href="https://cloud.google.com/vertex-ai"><strong>Vertex AI</strong></a><strong>: </strong>Our AI characters are not just chatbots; they are central to the Arc experience. To give them a distinct personality and a deep understanding of the Arc universe — we moved beyond simple prompt engineering. We have fully embraced Firebase AI Logic and Vertex AI.</p><ul><li><strong>Dynamic Gemini Model usage</strong> : the Gemini model we use is not fixed. We employ an architecture that dynamically selects and applies the optimal model (e.g., Gemini 2.5 Flash-light for speed, or Flash and Pro for quality) based on the AI character’s personality and the conversational context.</li><li><strong>Integration with Vertex AI :</strong> We built a knowledge base containing extensive FAQs and character lore within a Vertex AI Search data store. Our backend service calls the Gemini API on the Vertex AI platform via the Vertex AI SDK. The API call is configured to use our data store as the sole source of information (grounding). This forces the model to generate responses based only on our verified knowledge, dramatically reducing hallucinations and ensuring character consistency. We are also experimenting with the Firebase AI Logic Client SDK with Live API for interactive conversations with AI characters.</li></ul><h3>The Future: A Globally Competitive Platform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEOOTmB9HlmiZdMK-sugzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k49_4X8mvUsT6Ba_IiaQXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3AVp7qo8hx-28wEaEnXJQ.png" /></figure><p>Our architecture is the result of deliberate choices. By combining the rapid development capabilities of Flutter and Firebase with the scalable power of Cloud Run and the intelligence of Vertex AI, we have built a platform designed for global competition. Our architecture allows us to focus on delivering unique value to our users, such as our AI characters and mesh networking technology. At the core of this are our AI characters, which create intelligent conversations, and our fully implemented mesh networking technology, which functions even when internet connectivity is lost. This technology offers true resilience, moving beyond everyday convenience to become a potential lifeline during disasters. Armed with this unique architecture, we will continue to define the next generation of communication experiences.</p><p><strong>As a tech startup from Japan</strong>, this is just the beginning of our journey at Atlas Associates. Arc will continue to evolve at the forefront of technology. Stay tuned.</p><p>Takayuki Miyano , Founder and CEO <br><a href="https://www.linkedin.com/in/takayukimiyano">https://www.linkedin.com/in/takayukimiyano</a>/</p><p>Atlas Associates Inc <br><a href="https://www.linkedin.com/company/atlasassociates/">https://www.linkedin.com/company/atlasassociates/</a></p><p>Arc <br><a href="https://onelink.to/project-arc">https://onelink.to/project-arc</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8a3d947c247" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/building-arc-an-ai-messenger-powered-by-firebase-flutter-and-vertex-ai-f8a3d947c247">Building Arc: An AI Messenger Powered by Firebase, Flutter, and Vertex AI</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic configuration in Java with Server-Side Firebase Remote Config]]></title>
            <link>https://medium.com/firebase-developers/dynamic-configuration-in-java-using-server-side-firebase-remote-config-9d30a3c2e1a1?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/9d30a3c2e1a1</guid>
            <category><![CDATA[firebase-remote-config]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[remote-config]]></category>
            <dc:creator><![CDATA[Athira M]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 06:33:20 GMT</pubDate>
            <atom:updated>2025-10-27T09:31:57.277Z</atom:updated>
            <content:encoded><![CDATA[<h4>Dynamic Configuration in Java</h4><h3>Using Server-Side Firebase Remote Config</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWmK6EGHs53dXtQqhacEew.png" /></figure><p><strong>Firebase Remote Config</strong> is a powerful, cloud-based service that lets you dynamically change your app’s behavior and appearance without requiring users to update your app. It’s been a game-changer for feature flags and dynamic theming on mobile and web platforms.</p><p>But what about your backend, or your critical API or Java micro-service?</p><p>The great news is that Firebase has expanded its support, bringing this powerful tool to the server side with SDKs for <strong>Node.js, Python, Go, and Java</strong>. This allows you to control server behavior and externalize configuration directly from the Firebase console.</p><h3>The key difference: where evaluation happens</h3><p>If you’re familiar with client-side Remote Config, you know the client makes a request, and the Firebase service returns the <strong>final, evaluated configuration</strong>.</p><p>The server-side model is fundamentally different:</p><ol><li>The <strong>Java server</strong> fetches the <strong>entire configuration template</strong> (parameters, values, and conditions) from the Remote Config service.</li><li>The <strong>Java server</strong> then performs the <strong>condition evaluation locally</strong>, using the SDK.</li></ol><p>This shift means your server is in control, making local decisions based on attributes like user ID, location, or subscription tier. This is efficient and perfect for dynamic server logic.</p><h3>🛠️ Setting up Remote Config in Java</h3><p>Let’s walk through how to integrate this into your backend, using a <strong>Payment Gateway Feature Flag</strong> as our running example.</p><h3>Step 1: Add the Firebase Admin SDK</h3><p>First, add the Firebase Admin SDK dependency to your project’s configuration file (e.g., pom.xml for Maven).</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;com.google.firebase&lt;/groupId&gt;<br>  &lt;artifactId&gt;firebase-admin&lt;/artifactId&gt;<br>  &lt;version&gt;9.7.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><h3>Step 2: Initialize the Admin SDK</h3><p>Your server needs secure access to Firebase. We’ll use a <strong>Service Account</strong> to initialize the Admin SDK.</p><pre>import com.google.auth.oauth2.GoogleCredentials;<br>import com.google.firebase.FirebaseApp;<br>import com.google.firebase.FirebaseOptions;<br>import java.io.FileInputStream;<br>import java.io.IOException;<br><br>public void initializeFirebase() {<br>  try {<br>    // Load the service account file (stored securely)<br>    FileInputStream serviceAccount = new FileInputStream(&quot;path/to/your/serviceAccountKey.json&quot;);<br>    FirebaseOptions options = new FirebaseOptions.Builder()<br>                                .setCredentials(GoogleCredentials.fromStream(serviceAccount))<br>                                .build();<br>    FirebaseApp.initializeApp(options);<br>  } catch (IOException e) {<br>    System.err.println(&quot;Failed to initialize Firebase: &quot; + e.getMessage());<br>  }<br>}</pre><h3>Step 3: Fetch the template and define defaults</h3><p>Defining <strong>default values</strong> is non-negotiable. They act as a critical failsafe, ensuring your application runs even if the Remote Config service is unreachable. Our defaults assume the safest, most stable configuration: the old payment gateway and the standard rate limit.</p><pre>import com.google.firebase.remoteconfig.FirebaseRemoteConfig;<br>import com.google.firebase.remoteconfig.ServerTemplate;<br>import com.google.firebase.remoteconfig.KeysAndValues;<br><br>public ServerTemplate fetchTemplate() {<br>  FirebaseRemoteConfig rc = FirebaseRemoteConfig.getInstance();<br>  // Define robust defaults: Default to the stable, old gateway<br>  KeysAndValues defaultConfig = new KeysAndValues.Builder()<br>                                  .put(&quot;use_new_gateway&quot;, false)<br>                                  .put(&quot;rate_limit_multiplier&quot;, 1.0)<br>                                  .build();<br>  try {<br>    return rc.getServerTemplate(defaultConfig);<br>  } catch (Exception e) {<br>    System.err.println(&quot;Failed to fetch Remote Config template. Using local defaults.&quot;);<br>  }<br>}</pre><h3>💡 Evaluating parameters on the server</h3><p>With the template cached, we can now evaluate parameters against runtime context, like a user’s ID or location.</p><h3>Step 4: Define the evaluation context</h3><p>The <strong>evaluation context</strong> contains all the attributes your server needs to perform local condition checks (e.g., matching a user’s country code to a Remote Config condition).</p><pre>import com.google.firebase.remoteconfig.KeysAndValues;<br><br>public KeysAndValues createEvaluationContext(String userId, String countryCode, String subscriptionTier) {<br>  return new KeysAndValues.Builder()<br>          // randomizationId needed for percentage rollouts<br>          .put(&quot;randomizationId&quot;, userId)<br>          // Custom signals map to conditions set in the Firebase Console<br>          .put(&quot;country&quot;, countryCode)<br>          .put(&quot;subscription_tier&quot;, subscriptionTier)<br>          .build();<br>}</pre><h3>Step 5: Get the evaluated value</h3><p>The template.evaluate() call is where the magic happens. It takes the context and returns a ServerConfig object containing the final values for that specific user request.</p><pre>import com.google.firebase.remoteconfig.ServerConfig;<br>import com.google.firebase.remoteconfig.ValueSource;<br><br>public void processPayment(ServerTemplate template, KeysAndValues context) {<br>  // Evaluate the template with signals<br>  ServerConfig config = template.evaluate(context);<br>  // Get the feature flag value<br>  boolean useNewGateway = config.getBoolean(&quot;use_new_gateway&quot;);<br>  // Get the rate limit multiplier<br>  double rateLimitMultiplier = config.getDouble(&quot;rate_limit_multiplier&quot;);<br>  // Check where the value came from (REMOTE, DEFAULT, or STATIC)<br>  ValueSource source = config.getValueSource(&quot;use_new_gateway&quot;);<br>  // Server logic uses the dynamic configuration:<br>  if (useNewGateway) {<br>    System.out.println(&quot;Switching to NEW Payment Gateway for this user! (Source: &quot; + source + &quot;)&quot;);<br>  } else {<br>    System.out.println(&quot;Using OLD Payment Gateway. (Source: &quot; + source + &quot;)&quot;);<br>  }<br>  System.out.println(&quot;Rate limit factor applied: &quot; + rateLimitMultiplier);<br>  // … complete the payment processing logic …<br>}</pre><h3>🚀 What’s next?</h3><p>By shifting configuration control to the server, you gain the agility to manage feature rollouts and adjust critical service parameters without requiring code redeployment.</p><p><strong>Ready to gain dynamic control over your Java backend?</strong></p><ol><li><strong>Read the official docs:</strong> Dive deeper into the specifics of the<a href="https://firebase.google.com/docs/remote-config/server?serverplatform=java"> Firebase Admin Java SDK for Remote Config</a>.</li><li><strong>Try it out:</strong> Create your first server side parameter in the<a href="https://console.firebase.google.com/"> Firebase Remote Config Console</a> and test the feature flag logic in your local Java environment.</li><li><strong>Share your experience:</strong> Comment below what dynamic configurations you are implementing in your backend services!</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d30a3c2e1a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/dynamic-configuration-in-java-using-server-side-firebase-remote-config-9d30a3c2e1a1">Dynamic configuration in Java with Server-Side Firebase Remote Config</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart Client for Genkit]]></title>
            <link>https://medium.com/firebase-developers/dart-client-for-genkit-call-genkit-flows-from-flutter-dart-b5a2c9b9400e?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/b5a2c9b9400e</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[genkit]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Nozomi Koborinai]]></dc:creator>
            <pubDate>Thu, 23 Oct 2025 10:49:27 GMT</pubDate>
            <atom:updated>2025-10-23T15:35:31.077Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing the Dart Client for Genkit</h3><h4><strong>Calling Genkit Flows from Flutter/Dart</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*DGmz6jDybKvi57fvBfQLjQ.png" /><figcaption>Dart client for Genkit</figcaption></figure><p>I’m a big fan of Firebase and often choose Flutter as my front-end framework.</p><p>Since Google I/O 2024, I’ve been continuously exploring Genkit. Developed by the Firebase team, Genkit is an open-source framework from Google that simplifies the definition of AI-powered processing sequences on the server-side as Flows.</p><p><a href="https://genkit.dev">Genkit | Open-source AI development framework by Google</a></p><p>However, calling a server-defined flow from a Dart/Flutter client application required some extra effort. To bridge this gap, I developed the Dart client for Genkit package.</p><p><a href="https://pub.dev/packages/genkit">genkit | Dart package</a></p><blockquote><strong>Note: </strong>This library is not for defining Genkit flows themselves. It is specifically designed for easily and securely calling flows deployed on a server from a Dart client.</blockquote><h4><strong>Library overview</strong></h4><p>As mentioned above, this library is a <strong>dedicated client for easily calling Genkit flows deployed on a server</strong> (e.g., as Web APIs on platforms like Cloud Functions for Firebase, Cloud Run, or GKE). It is not for implementing Genkit flows in Dart.</p><h4><strong>The challenges before</strong></h4><p>Previously, calling a Genkit flow from Dart/Flutter required manually implementing an HTTP client according to a set of conventions.</p><p>For example, here’s a typical piece of code using the <a href="https://pub.dev/packages/dio">dio</a> package to call an image generation flow defined in Genkit.</p><pre>  Future&lt;String&gt; generateImage({required String imageDescription}) async {<br>    try {<br>      final response = await dio.post(<br>        &#39;https://&lt;YOUR_GENKIT_ENDPOINT&gt;/generateImage&#39;,<br>        data: {<br>          &#39;data&#39;: {<br>            &#39;imageDescription&#39;: imageDescription,<br>          },<br>        },<br>      );<br><br>      if (response.statusCode == 200) {<br>        return response.data[&#39;result&#39;][&#39;url&#39;] as String;<br>      }<br>      throw Exception(&#39;Failed to generate image: ${response.statusCode}&#39;);<br>    } on DioException catch (e) {<br>      throw Exception(&#39;Failed to generate image: ${e.message}&#39;);<br>    }<br>  }</pre><p>This code presents several challenges:</p><ul><li>When sending a request, the input must be wrapped in {‘data’: …}, and when receiving a response, the result must be extracted from response.data[‘result’]. This is a Genkit server-side rule that is cumbersome and error-prone for client-side developers to remember.</li><li>As the number of Genkit flows increases, you end up writing similar HTTP request code repeatedly. Common tasks like adding authentication headers required building your own mechanisms.</li><li>The example above is for a simple request. Implementing real-time data reception with streaming requires manually parsing responses from the Server-Sent Events (SSE) protocol, which further complicates the code.</li></ul><blockquote><strong>Note: </strong>This library works with flows defined in both Genkit JS (TypeScript/JavaScript) and Genkit Go. As long as you can access the server endpoints, you can use this client regardless of the server-side implementation language.</blockquote><h3><strong>Core design</strong></h3><p>Let’s dive into the design philosophy and implementation details of how this library abstracts the process of calling Genkit flows.</p><h4><strong>Key components</strong></h4><p>The library is primarily composed of three classes.</p><p><strong>1. </strong><strong>RemoteAction&lt;O, S&gt; class</strong></p><p>This is the central class and the starting point for all operations. You can think of it as an object that represents a remote (server-side) Genkit flow in the Dart world.</p><pre>class RemoteAction&lt;O, S&gt; {<br>  final String _url;<br>  final Map&lt;String, String&gt;? _defaultHeaders;<br>  final http.Client _httpClient;<br>  final O Function(dynamic jsonData) _fromResponseData;<br>  final S Function(dynamic jsonData)? _fromStreamChunkData;<br><br>  // ... implementation details<br>}</pre><p>It uses generics to ensure type-safe operations:</p><ul><li><strong>O (Output)</strong>: The type of the final response received when the flow completes.</li><li><strong>S (Stream)</strong>: The type of the chunk data sent during a streaming execution (specify void if not using streaming).</li></ul><p><strong>2. </strong><strong>ActionStream&lt;S, F&gt; Class</strong></p><p>The return value for streaming operations is defined by the ActionStream class.</p><pre>class ActionStream&lt;S, F&gt; extends StreamView&lt;S&gt; {<br>  final Future&lt;F&gt; onResult;<br>  F get result;<br>  // ... implementation details<br>}</pre><p>ActionStream extends StreamView&lt;S&gt; , allowing you to receive streaming data (type S) while also providing access to the final result (type F).</p><p><strong>Type Parameters</strong></p><ul><li>S : The type of streaming chunks</li><li>F : The type of the final result</li></ul><p><strong>onResult: </strong>A Future&lt;F&gt; for obtaining the final result. The recommended way to get the final result is to use await stream.onResult after fully consuming the stream.</p><p><strong>result: </strong>A synchronous getter for the final result. This should only be accessed after the stream has been fully consumed.</p><blockquote><strong>Note: </strong>The stream() method of RemoteAction&lt;O, S&gt; returns ActionStream&lt;S, O&gt;. This means the first type parameter is the stream chunk type, and the second is the final result type.</blockquote><p><strong>3. </strong><strong>GenkitException class</strong></p><p>If a Genkit flow returns an error, the library throws it as a GenkitException. This exception includes the HTTP status code and detailed error information, supporting flexible error handling on the client side.</p><pre>class GenkitException implements Exception {<br>  final String message;<br>  final int? statusCode;<br>  final String? details;<br>  final Exception? underlyingException;<br>  final StackTrace? stackTrace;<br><br>  const GenkitException(<br>    this.message, {<br>    this.statusCode,<br>    this.details,<br>    this.underlyingException,<br>    this.stackTrace,<br>  });<br>}</pre><h4><strong>Streaming implementation</strong></h4><p>One of the most powerful features of this library is its support for streaming. Under the hood, it uses the Server-Sent Events (SSE) protocol.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events">Using server-sent events - Web APIs | MDN</a></p><p>A Genkit streaming endpoint sends data intermittently in the following format:</p><pre>data: {&quot;message&quot;: {&quot;text&quot;: &quot;Hello&quot;}}<br><br>data: {&quot;message&quot;: {&quot;text&quot;: &quot; World&quot;}}<br><br>data: {&quot;result&quot;: &quot;Hello World&quot;}</pre><p>Since this format is difficult to work with directly, the library internally parses the raw data using several constants defined by the SSE protocol.</p><pre>// Constants used in the SSE protocol<br>const flowStreamDelimiter = &#39;\n\n&#39;;<br>const sseDataPrefix = &#39;data: &#39;;</pre><ul><li><strong>flowStreamDelimiter</strong>: Each message block is separated by two newline characters (\n\n). This constant is used to accurately split individual messages from the stream.</li><li><strong>sseDataPrefix</strong>: According to the SSE specification, each line of the message body must start with the data: prefix. This constant is used to identify and remove that prefix.</li></ul><p>Using these constants, the library performs the following logic to convert the data stream into a Dart Stream object.</p><pre>var buffer = &#39;&#39;;<br>// Subscribe to the response body stream<br>subscription = streamedResponse.stream.transform(utf8.decoder).listen(<br>  (decodedChunk) {<br>    // 1. Data can arrive in segments, so append it to a buffer first.<br>    buffer += decodedChunk;<br><br>    // 2. Loop as long as the buffer contains the delimiter indicating the end of a chunk.<br>    while (buffer.contains(flowStreamDelimiter)) {<br>      final endOfChunk = buffer.indexOf(flowStreamDelimiter);<br>      // Extract the first chunk.<br>      final chunkData = buffer.substring(0, endOfChunk);<br>      // Remove the processed part from the buffer.<br>      buffer = buffer.substring(endOfChunk + flowStreamDelimiter.length);<br><br>      // 3. According to the SSE spec, skip lines that don&#39;t start with &quot;data: &quot;.<br>      if (!chunkData.startsWith(sseDataPrefix)) {<br>        continue;<br>      }<br>      // Remove the &quot;data: &quot; prefix to get the JSON string content.<br>      final jsonData = chunkData.substring(sseDataPrefix.length);<br>      if (jsonData.isEmpty) continue;<br><br>      try {<br>        final parsedJson = jsonDecode(jsonData);<br><br>        // 4. Based on the JSON keys, route to the streaming message, final result, or error.<br>        if (parsedJson is Map&lt;String, dynamic&gt;) {<br>          if (parsedJson.containsKey(&#39;message&#39;)) {<br>            // If &#39;message&#39; key exists, push it to the Stream as streaming data.<br>            if (!streamController.isClosed) {<br>              streamController.add(parsedJson[&#39;message&#39;]);<br>            }<br>          } else if (parsedJson.containsKey(&#39;result&#39;)) {<br>            // If &#39;result&#39; key exists, complete the Future with the final flow result.<br>            if (!responseCompleter.isCompleted) {<br>              responseCompleter.complete(parsedJson[&#39;result&#39;]);<br>            }<br>          } else if (parsedJson.containsKey(&#39;error&#39;)) {<br>            // If &#39;error&#39; key exists, create a GenkitException with detailed error info<br>            // and notify both the Stream and the Future of the error.<br>            // ... (error handling) ...<br>          }<br>        }<br>      } on FormatException catch (e, s) {<br>        // Error handling for JSON parsing failures.<br>        // ... (wrap in GenkitException and push to the Stream) ...<br>      }<br>    }<br>  },<br>  onDone: () {<br>    // Handling when the stream completes successfully (e.g., caring for remaining data in buffer).<br>  },<br>  onError: (e, s) {<br>    // Handling for errors in the HTTP stream itself.<br>  },<br>);</pre><p>This implementation allows Dart/Flutter developers to handle streaming data from Genkit flows intuitively using await for, without needing to worry about the complexities of the SSE protocol.</p><h3><strong>How to use</strong></h3><p>Now for the main topic: how to use the Dart client for Genkit package in your project.</p><h4><strong>Basic setup</strong></h4><pre>dart pub add genkit<br>or<br>flutter pub add genkit</pre><pre>import &#39;package:genkit/client.dart&#39;;</pre><h4><strong>1. Simplest </strong><strong>String → String flow call</strong></h4><p>First, let’s look at the most basic example: calling a flow that takes a string as input and returns a string.</p><p><strong>Genkit (server-side)</strong></p><p>Assume you have a Genkit flow defined on the server with string input and output types.</p><pre>import { ai } from &quot;genkit&quot;;<br>import { z } from &quot;zod&quot;;<br><br>export const simpleStringFlow = ai.defineFlow(<br>  {<br>    name: `simple-string`,<br>    inputSchema: z.string(),<br>    outputSchema: z.string(),<br>  },<br>  async (input) =&gt; {<br>    const response = await ai.generate({ prompt: input });<br>    return response.text();<br>  }<br>);</pre><p><strong>Dart (client-side)</strong></p><p>To call this flow from Dart, you define a client using defineRemoteAction. Simply pass the flow’s endpoint URL and a fromResponse function to convert the response to the expected type. Then, you can execute the defined action like a function.</p><pre>import &#39;package:genkit/client.dart&#39;;<br><br>void main() async {<br>  // Define a RemoteAction to call the Genkit flow published on the server.<br>  final simpleStringAction = defineRemoteAction(<br>    url: &#39;https://your-service.com/simpleString&#39;, // Genkit flow endpoint<br>    fromResponse: (json) =&gt; json as String,     // Response conversion logic<br>  );<br><br>  // Execute the flow<br>  try {<br>    final response = await simpleStringAction(<br>      input: &#39;Hello Dart client!&#39;,<br>    );<br>    print(&#39;Response: $response&#39;);<br>  } on GenkitException catch (e) {<br>    print(&#39;Genkit Error: ${e.message}&#39;);<br>  }<br>}</pre><h4><strong>2. Using typed objects</strong></h4><p>Next, let’s look at a more practical example: sending and receiving typed objects. By combining this with a library like json_serializable, you can handle complex data while maintaining type safety.</p><p><strong>Schema definition (using </strong><strong>json_annotation)</strong></p><p>First, define a common data structure as a Dart class for both the client and server. Here, we use json_serializable to auto-generate toJson / fromJson methods.</p><pre>import &#39;package:json_annotation/json_annotation.dart&#39;;<br><br>part &#39;my_schemas.g.dart&#39;;<br><br>@JsonSerializable()<br>class MyInput {<br>  final String message;<br>  final int count;<br><br>  MyInput({required this.message, required this.count});<br><br>  factory MyInput.fromJson(Map&lt;String, dynamic&gt; json) =&gt;<br>      _$MyInputFromJson(json);<br>  Map&lt;String, dynamic&gt; toJson() =&gt; _$MyInputToJson(this);<br>}<br><br>@JsonSerializable()<br>class MyOutput {<br>  final String reply;<br>  final int newCount;<br><br>  MyOutput({required this.reply, required this.newCount});<br><br>  factory MyOutput.fromJson(Map&lt;String, dynamic&gt; json) =&gt;<br>      _$MyOutputFromJson(json);<br>  Map&lt;String, dynamic&gt; toJson() =&gt; _$MyOutputToJson(this);<br>}</pre><p><strong>Genkit (server-side)</strong></p><p>On the server, use <a href="https://zod.dev/">zod</a> to define a schema corresponding to the Dart class.</p><pre>import { ai } from &quot;genkit&quot;;<br>import { z } from &quot;zod&quot;;<br><br>export const processObjectFlow = ai.defineFlow(<br>  {<br>    name: `process-object`,<br>    inputSchema: z.object({<br>      message: z.string(),<br>      count: z.number(),<br>    }),<br>    outputSchema: z.object({<br>      reply: z.string(),<br>      newCount: z.number(),<br>    }),<br>  },<br>  async (input) =&gt; {<br>    const response = await ai.generate({<br>      prompt: input.message,<br>    });<br><br>    const newCount = input.count * 2;<br><br>    return {<br>      reply: response.text(),<br>      newCount,<br>    };<br>  }<br>);</pre><p><strong>Dart (client-side)</strong></p><p>Pass the fromJson factory constructor of your class to the fromResponse parameter of defineRemoteAction. This allows the client to automatically convert the received JSON into a MyOutput object. When calling the action, simply pass a MyInput object, and the library will handle the JSON conversion internally.</p><pre>import &#39;package:genkit/client.dart&#39;;<br>import &#39;schemas/my_schemas.dart&#39;;<br><br>void main() async {<br>  final processObjectAction = defineRemoteAction&lt;MyOutput, void&gt;(<br>    url: &#39;https://your-service.com/processObject&#39;,<br>    fromResponse: (json) =&gt; MyOutput.fromJson(json),<br>  );<br><br>  // Execute the flow using type-safe objects<br>  try {<br>    final response = await processObjectAction(<br>      input: MyInput(message: &#39;Hello Genkit!&#39;, count: 20),<br>    );<br>    print(&#39;Response: ${response.reply}, New Count: ${response.newCount}&#39;);<br>  } on GenkitException catch (e) {<br>    print(&#39;Error: ${e.message}&#39;);<br>  }<br>}</pre><h4><strong>3. Streaming flow</strong></h4><p>Streaming is a key feature of this library. It’s useful when you want to receive data intermittently from the server, such as responses from a generative AI.</p><p><strong>Genkit (server-side)</strong></p><p>On the server, define a streaming Genkit flow using streamSchema and streamingCallback.</p><pre>import { ai } from &quot;genkit&quot;;<br>import { z } from &quot;zod&quot;;<br><br>export const streamObjectsFlow = ai.defineFlow(<br>  {<br>    name: `stream-objects`,<br>    inputSchema: z.object({<br>      prompt: z.string(),<br>    }),<br>    outputSchema: z.object({<br>      text: z.string(),<br>      summary: z.string(),<br>    }),<br>    streamSchema: z.object({<br>      text: z.string(),<br>      summary: z.string(),<br>    }),<br>  },<br>  async (input, streamingCallback) =&gt; {<br>    if (!streamingCallback) {<br>      throw new Error(`Streaming callback not provided for a streaming flow.`);<br>    }<br><br>    const { stream, response } = await ai.generate({<br>      prompt: input.prompt,<br>      stream: true,<br>    });<br><br>    let accumulatedText = ``;<br><br>    for await (const chunk of stream) {<br>      if (chunk.text()) {<br>        accumulatedText += chunk.text()!;<br><br>        const streamChunk = {<br>          text: chunk.text()!,<br>          summary: `Processing: ${accumulatedText.slice(0, 50)}...`,<br>        };<br><br>        streamingCallback(streamChunk);<br>      }<br>    }<br><br>    const finalResponse = await response;<br>    const finalOutput = {<br>      text: finalResponse.text(),<br>      summary: `Completed processing of: &quot;${input.prompt}&quot;`,<br>    };<br><br>    return finalOutput;<br>  }<br>);</pre><p><strong>Dart (client-side)</strong></p><p>On the client side, call the stream() method. This returns an ActionStream. Since ActionStream extends Stream, you can process the streaming data using the await for syntax, and then retrieve the final result using onResult. You can handle the streaming data from the server concisely, without worrying about the complexities of SSE.</p><pre>import &#39;package:genkit/client.dart&#39;;<br>import &#39;schemas/stream_schemas.dart&#39;;<br><br>void main() async {<br>  // Define a RemoteAction that supports streaming<br>  final streamObjectsAction = defineRemoteAction&lt;StreamOutput, StreamOutput&gt;(<br>    url: &#39;https://your-service.com/streamObjects&#39;,<br>    fromResponse: (json) =&gt; StreamOutput.fromJson(json),      // Final response<br>    fromStreamChunk: (json) =&gt; StreamOutput.fromJson(json),  // Stream chunk<br>  );<br><br>  try {<br>    // Execute streaming<br>    final stream = streamObjectsAction.stream(<br>      input: StreamInput(prompt: &#39;What is Genkit?&#39;),<br>    );<br><br>    // Process stream data sequentially<br>    print(&#39;Streaming chunks:&#39;);<br>    await for (final chunk in stream) {<br>      print(&#39;Chunk: ${chunk.text}&#39;);<br>    }<br><br>    // Get the final response (recommended: use onResult)<br>    final finalResult = await stream.onResult;<br>    print(&#39;Final Response: ${finalResult.text}&#39;);<br>  } on GenkitException catch (e) {<br>    print(&#39;Error: ${e.message}&#39;);<br>  }<br>}</pre><h4><strong>4. Sending authentication headers</strong></h4><p>Authentication is essential in real-world applications. This library makes it easy to call authenticated flows by allowing flexible configuration of HTTP headers.</p><p><strong>Genkit (server-side)</strong></p><p>As an example, let’s set a policy on the server that only allows users authenticated with Firebase Authentication (anonymous) to execute the flow.</p><pre>import { onCallGenkit } from &quot;firebase-functions/v2/genkit&quot;;<br>import { googleAI } from &quot;genkit/x-googleai&quot;;<br>import * as z from &quot;zod&quot;;<br><br>import { processObjectFlow } from &quot;./flows/process-object-flow&quot;;<br>import { streamObjectsFlow } from &quot;./flows/stream-objects-flow&quot;;<br>import { simpleStringFlow } from &quot;./flows/simple-string-flow&quot;;<br><br>const opts = {<br>  region: `asia-northeast1`,<br>  cors: true,<br>  authPolicy: (auth: any) =&gt; {<br>    // Only allow anonymous users from Firebase Authentication<br>    return auth?.token?.firebase?.sign_in_provider === `anonymous`;<br>  },<br>};<br><br>// Expose each flow as a Cloud Function for Firebase (2nd Gen)<br>export const simpleString = onCallGenkit(opts, simpleStringFlow);<br>export const processObject = onCallGenkit(opts, processObjectFlow);<br>export const streamObjects = onCallGenkit(opts, streamObjectsFlow);</pre><p><strong>Dart (client-side)</strong></p><p>On the client side, include the ID token obtained from the Firebase Authentication SDK (or other provider) in the Authorization header. By setting it in defineRemoteAction’s defaultHeaders, this header will be automatically added to all requests from that action instance.</p><pre>import &#39;package:genkit/client.dart&#39;;<br>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br><br>void main() async {<br>  // Get ID token from Firebase Auth<br>  final user = FirebaseAuth.instance.currentUser;<br>  final idToken = await user?.getIdToken();<br><br>  // Define an action with an authentication header<br>  final simpleStringAction = defineRemoteAction(<br>    url: &#39;https://your-service.com/simpleString&#39;,<br>    fromResponse: (json) =&gt; json as String,<br>    defaultHeaders: {<br>      &#39;Authorization&#39;: &#39;Bearer $idToken&#39;,<br>    },<br>  );<br><br>  // Execute the flow with authentication<br>  // Of course, without the auth header, the request will be rejected<br>  // with a 403 error due to the server&#39;s policy.<br>  final response = await simpleStringAction(<br>    input: &#39;Hello Dart client!&#39;,<br>  );<br>  print(&#39;Response: $response&#39;);<br>}</pre><p><strong>Per-request header configuration</strong></p><p>In addition to defaultHeaders, you can also set headers dynamically for each request. By specifying them in the headers argument of the call() or stream() methods, you can handle flexible scenarios like adding a request ID.</p><pre>import &#39;package:genkit/client.dart&#39;;<br><br>void main() async {<br>  final remoteAction = defineRemoteAction(<br>    url: &#39;https://your-service.com/simpleString&#39;,<br>    fromResponse: (json) =&gt; json as String,<br>    defaultHeaders: {<br>     &#39;Authorization&#39;: &#39;Bearer your-token&#39;,<br>     &#39;X-Client-Type&#39;: &#39;flutter&#39;,<br>    },<br>  );<br><br>  // Per-request headers<br>  final response1 = await remoteAction(<br>    input: &#39;First request&#39;,<br>    headers: {<br>      &#39;X-Request-ID&#39;: &#39;req-001&#39;,<br>      &#39;X-Priority&#39;: &#39;high&#39;,<br>    },<br>  );<br><br>  // Per-request headers<br>  final response2 = await remoteAction(<br>    input: &#39;Second request&#39;,<br>    headers: {<br>      &#39;X-Request-ID&#39;: &#39;req-002&#39;,<br>      &#39;X-Priority&#39;: &#39;normal&#39;,<br>    },<br>  );<br>}</pre><p><strong>Header Merge Order</strong></p><p>When making a request, defaultHeaders and individual headers are merged. If the same key exists in both, the individual headers take precedence.</p><pre>import &#39;package:genkit/client.dart&#39;;<br><br>void main() async {<br>  final action = defineRemoteAction(<br>    url: &#39;https://your-service.com/flow&#39;,<br>    fromResponse: (json) =&gt; json,<br>    defaultHeaders: {<br>      &#39;X-Client&#39;: &#39;Flutter&#39;,<br>      &#39;X-Version&#39;: &#39;1.0&#39;,<br>    },<br>  );<br><br>  // X-Version will be overridden with &#39;2.0&#39;<br>  // Final headers: {&#39;X-Client&#39;: &#39;Flutter&#39;, &#39;X-Version&#39;: &#39;2.0&#39;, &#39;X-Request-ID&#39;: &#39;abc123&#39;}<br>  await action(<br>    input: &#39;test&#39;,<br>    headers: {<br>      &#39;X-Version&#39;: &#39;2.0&#39;,<br>      &#39;X-Request-ID&#39;: &#39;abc123&#39;,<br>    },<br>  );<br>}</pre><h4>5. Resource Management (dispose)</h4><p>If a RemoteAction creates an HTTP client internally (i.e., when the httpClient parameter is not provided), it is recommended to call the dispose method to free up resources when the action is no longer needed.</p><pre>import &#39;package:genkit/client.dart&#39;;<br><br>void main() async {<br>  final action = defineRemoteAction(<br>    url: &#39;https://your-service.com/simpleString&#39;,<br>    fromResponse: (json) =&gt; json as String,<br>  );<br><br>  try {<br>    // Use the action<br>    final response = await action(input: &#39;Hello!&#39;);<br>    print(&#39;Response: $response&#39;);<br>  } finally {<br>    // Free up resources after use<br>    action.dispose();<br>  }<br>}</pre><blockquote><strong>Note: </strong>If you provide your own httpClient to defineRemoteAction, you are responsible for managing its lifecycle. In this case, calling dispose() will not close the HTTP client.</blockquote><h4>6. Working with Genkit Data Objects</h4><p>When interacting with Genkit models, you’ll often work with a set of standardized data classes that represent the inputs and outputs of generative models. This library provides these classes to make it easy to construct requests and handle responses in a type-safe way.</p><p><strong>Key Data Classes</strong></p><p>GenerateResponse : The final response from a model generation call.</p><p>GenerateResponseChunk : A streaming chunk from a model generation call.</p><p>Message : Represents a message in a conversation, containing a role (e.g., user, model) and content.</p><p>Part : The content of a message is made up of one or more Part objects. Common parts include:</p><ul><li>TextPart : For text content.</li><li>MediaPart : For media content like images.</li><li>ToolRequestPart : A request from the model to invoke a tool.</li><li>ToolResponsePart : The response from a tool invocation.</li><li>DataPart , CustomPart , ReasoningPart , ResourcePart : For other specialized data.</li></ul><p><strong>Helpful Extension Methods</strong></p><p>These classes provide the following helpful extension methods (getters):</p><p>Message.text : Extracts and concatenates text from all TextPart objects in the message</p><p>Message.media : Returns the media object from the first MediaPart in the message</p><p>GenerateResponse.text : Extracts text from the response message (internally calls message?.text)</p><p>GenerateResponse.media : Gets media from the response message (internally calls message?.media)</p><p>GenerateResponseChunk.text : Extracts and concatenates text from all TextPart objects in the chunk</p><p>GenerateResponseChunk.media : Returns the media object from the first MediaPart in the chunk</p><p>These getters make it easy to access text and media content from responses and messages.</p><p><strong>Example: Streaming with Genkit Data Objects</strong></p><p>Here is an example of how to call a generative model and process the streaming response using the built-in data classes.</p><pre>import &#39;package:genkit/client.dart&#39;;<br><br>void main() async {<br>  final generateFlow = defineRemoteAction(<br>    url: &#39;http://localhost:3400/generate&#39;,<br>    fromResponse: (json) =&gt; GenerateResponse.fromJson(json),<br>    fromStreamChunk: (json) =&gt; GenerateResponseChunk.fromJson(json),<br>  );<br><br>  try {<br>    final stream = generateFlow.stream(<br>      input: Message(role: Role.user, content: [TextPart(text: &quot;hello&quot;)]),<br>    );<br><br>    print(&#39;Streaming chunks:&#39;);<br>    await for (final chunk in stream) {<br>      // Use the .text getter to easily access the text content of the chunk<br>      print(&#39;Chunk: ${chunk.text}&#39;);<br>    }<br><br>    final finalResult = await stream.onResult;<br>    // The .text getter also works on the final response<br>    print(&#39;Final Response: ${finalResult.text}&#39;);<br>  } on GenkitException catch (e) {<br>    print(&#39;Error: ${e.message}&#39;);<br>  }<br>}</pre><p>In this example, we use Message and TextPart to create a structured input, and the .text getter to easily extract text content from the response.</p><h3><strong>Combination with Flutter</strong></h3><p>I’ve also created a sample app to demonstrate how to use the Dart client for Genkit in a Flutter project.</p><h4><strong>Sample App</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fembed%2FAfsGlEh9tR4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fwatch%3Fv%3DAfsGlEh9tR4&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.ytimg.com%2Fvi%2FAfsGlEh9tR4%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf1986a015938f5c77767fcd06abadd9/href">https://medium.com/media/cf1986a015938f5c77767fcd06abadd9/href</a></iframe><p>You can find the implementation details of the sample app here. To make the processing flow easier to understand, I’ve included not only the Flutter (client-side) code but also the Genkit flow (server-side) code.</p><p><a href="https://github.com/nozomi-koborinai/dart-client-for-genkit-example">GitHub - nozomi-koborinai/dart-client-for-genkit-example</a></p><h4><strong>Tips</strong></h4><p>In this sample, I’ve created a custom GenkitClient class to encapsulate the Genkit flow calls made via the Dart client for Genkit.</p><p>(In the context of Clean Architecture, Onion Architecture, or Layered Architecture, this would be responsible for the infrastructure layer.)</p><pre>class GenkitClient {<br>  GenkitClient();<br><br>  final baseUrl = &#39;https://region-project-name.cloudfunctions.net&#39;;<br><br>  /// Calls the process object flow with the provided message and count.<br>  ///<br>  /// This method invokes the `processObject` flow which processes a structured<br>  Future&lt;MyOutput&gt; callProcessObjectAction({<br>    required String idToken,<br>    required String message,<br>    required int count,<br>  }) async {<br>    try {<br>      final remoteAction = defineRemoteAction&lt;MyOutput, void&gt;(<br>        url: &#39;$baseUrl/processObject&#39;,<br>        fromResponse: (json) =&gt; MyOutput.fromJson(json),<br>        defaultHeaders: {&#39;Authorization&#39;: &#39;Bearer $idToken&#39;},<br>      );<br><br>      return await remoteAction(input: MyInput(message: message, count: count));<br>    } on GenkitException catch (e) {<br>      throw Exception(&#39;Failed to remote action: ${e.message}&#39;);<br>    }<br>  }<br><br>  /// Subscribes to the stream objects flow with the provided prompt.<br>  ///<br>  /// This method invokes the `streamObjects` flow which processes a prompt<br>  ActionStream&lt;StreamOutput, StreamOutput&gt; subscribeStreamObjectAction({<br>    required String idToken,<br>    required String prompt,<br>  }) {<br>    try {<br>      final remoteAction = defineRemoteAction&lt;StreamOutput, StreamOutput&gt;(<br>        url: &#39;$baseUrl/streamObjects&#39;,<br>        fromResponse: (json) =&gt; StreamOutput.fromJson(json),<br>        fromStreamChunk: (json) =&gt; StreamOutput.fromJson(json),<br>        defaultHeaders: {&#39;Authorization&#39;: &#39;Bearer $idToken&#39;},<br>      );<br><br>      return remoteAction.stream(input: StreamInput(prompt: prompt));<br>    } on GenkitException catch (e) {<br>      throw Exception(&#39;Failed to remote action: ${e.message}&#39;);<br>    }<br>  }<br><br>  // Define other methods similarly...<br>}</pre><h3><strong>Conclusion</strong></h3><p>In this article, I introduced the Dart client for Genkit, a package developed to streamline calling Genkit flows from Dart/Flutter.</p><p>I once had the opportunity to hear a Google employee talk about the design philosophy of the Firebase team. They mentioned that “the interface design of Firebase is beautiful.” In the context of this project, the philosophy of providing a consistent user experience across different frameworks like Next.js and AngularJS was a new perspective for me. I’ve come to realize that this is a particularly important point to consider for products that provide SDKs for multiple platforms.</p><p>Given that, having the library I worked on be reviewed for its interface consistency with the official clients was a very gratifying experience, as it felt like I was able to embody that philosophy, even if just a little.</p><p>These days, AI increasingly helps us with code generation, but I believe that we, the human developers, are ultimately responsible for ensuring the final quality. That’s why I feel that the readability and maintainability of code for humans are becoming more important than ever.</p><p>I hope this library, by hiding and abstracting complexity and providing a clean interface, can be of some help in that regard.</p><h3>Acknowledgments</h3><p>I am sincerely grateful to <a href="https://github.com/i14h">i14h (Iman Rahmatizadeh)</a> for his feedback on ideas to energize the Firebase and Flutter communities, and to <a href="https://github.com/pavelgj">pavelgj (Pavel Jbanov)</a> for welcoming and reviewing my contributions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5a2c9b9400e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/dart-client-for-genkit-call-genkit-flows-from-flutter-dart-b5a2c9b9400e">Dart Client for Genkit</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Your First MCP Server with Genkit]]></title>
            <link>https://medium.com/firebase-developers/building-your-first-mcp-server-with-genkit-c2053cde230f?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/c2053cde230f</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genkit]]></category>
            <dc:creator><![CDATA[Pavel J]]></dc:creator>
            <pubDate>Fri, 25 Apr 2025 14:09:50 GMT</pubDate>
            <atom:updated>2025-04-25T14:09:50.385Z</atom:updated>
            <content:encoded><![CDATA[<h4>Generative AI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*R037j1e1ykp3ifZo9onAKw.png" /></figure><p>Building robust backends for AI applications often involves integrating various components. The Model Context Protocol (MCP) offers a standardized communication layer, and Genkit provides a powerful framework to leverage it. This article guides you through creating a custom MCP server using Genkit, from defining data schemas to interacting with the server using development tools like Cline.</p><p>This article assumes some familiarity with Genkit concepts like flows and tools. Learn more about Genkit: <a href="https://firebase.google.com/docs/genkit">https://firebase.google.com/docs/genkit</a></p><p>If you prefer this tutorial in video format, check out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fembed%2FLc0iQdm3AAY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fwatch%3Fv%3DLc0iQdm3AAY&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.ytimg.com%2Fvi%2FLc0iQdm3AAY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/908bbf0df5ad1306b125a4c7411c203c/href">https://medium.com/media/908bbf0df5ad1306b125a4c7411c203c/href</a></iframe><h3>1. Defining Your Data Schema</h3><p>Before building any application, you need to define the structure of your data. In this example, we’re building a system to manage website orders for a consulting company. We use zod, a popular schema declaration library, integrated with Genkit.</p><p>The OrderSchema defines the necessary fields for each order:</p><pre>const OrderSchema = z.object({<br>  id: z.string().describe(&quot;Order Id. Format: A-XXX-XXX, ex. A-123-456&quot;),<br>  name: z.string().describe(&quot;Name of the business&quot;),<br>  colorScheme: z.object({<br>    mainColor: z.string().describe(&quot;RGB color prefixed with #, ex. #FFAA66&quot;),<br>    highlight: z.string().describe(&quot;RGB color prefixed with #, ex. #AA6611&quot;),<br>    textColor: z.string().describe(&quot;RGB color prefixed with #, ex. #224455&quot;),<br>  }),<br>  email: z.string(),<br>  jobDescription: z<br>    .string()<br>    .describe(<br>      &quot;Detailed description of the website they need. Ex. if they are a construction &quot; +<br>        &quot;company describe what they want on the home, contact age, testimonials, etc. &quot; +<br>        &quot;pages. Not too crazy, usually static website.&quot;<br>    ),<br>  address: z.string(),<br>});</pre><p>This schema clearly outlines each piece of information associated with an order, including nested details like the colorScheme.</p><h3>2. Generating Realistic Test Data (optional)</h3><p>During development, you need ways to both populate your system with test data and inspect that data. Manually creating test data can be tedious. Genkit integrates with tools like <a href="https://www.npmjs.com/package/genthetic">genthetic</a> to automatically generate realistic (but fake) data based on your schema.</p><p>Here’s how we define a Genkit flow (populateData) to generate 20 unique order entries and store them in Firestore:</p><pre>// Adds fake orders to firestore<br>ai.defineFlow(&quot;populateData&quot;, async () =&gt; {<br>  const OrderSynth = g<br>    .defineType({<br>      name: &quot;Order&quot;,<br>      schema: OrderSchema,<br>    })<br>    .generate({<br>      unique: true,<br>      instructions:<br>        &quot;Generate orders for a consulting company that builds websites for &quot; +<br>        &quot;small businesses. Make realistic looking data, but obviously not real.&quot;,<br>    });<br>  const { complete } = OrderSynth.synthesize({<br>    batchSize: 5,<br>    count: 20,<br>    logging: &quot;debug&quot;,<br>  });<br>  const orders = (await complete()) as z.infer&lt;typeof OrderSchema&gt;[];<br>  for (const o of orders) {<br>    await firestore.collection(&quot;orders&quot;).doc(o.id).set(o);<br>  }<br>  return orders;<br>});</pre><p>This flow uses the OrderSchema and specific instructions to create varied and plausible order data for testing our server.</p><p>Once data exists, you’ll often want to view it. We can define another flow, listOrders, to retrieve and stream all order documents from the database:</p><pre>// Lists orders from firestore<br>ai.defineFlow(&quot;listOrders&quot;, async (_, ctx) =&gt; {<br>  for (const ref of await firestore.collection(&quot;orders&quot;).listDocuments()) {<br>    // stream orders<br>    ctx.sendChunk((await ref.get()).data());<br>  }<br>});</pre><p>These flows provide convenient ways to manage the sample data within our Genkit application during the development cycle.</p><h3>3. Defining Tools</h3><p>While flows orchestrate tasks, Genkit tools define specific, discrete actions. These tools are particularly important because they can be invoked by AI models or external clients like Cline. Tools often represent the core capabilities you want to expose through your MCP server.</p><p>Let’s define a tool named getOrderInfo that retrieves a single order by its unique ID:</p><pre>ai.defineTool(<br>  {<br>    name: &quot;getOrderInfo&quot;,<br>    description: &quot;retrives order info&quot;,<br>    // Define expected input using Zod schema<br>    inputSchema: z.object({<br>      orderId: z<br>        .string()<br>        .describe(&quot;Order ID. Format: A-XXX-XXX, ex. A-123-456&quot;),<br>    }),<br>    // Define expected output using Zod schema (optional if order not found)<br>    outputSchema: OrderSchema.optional(),<br>  },<br>  // The async function implementing the tool&#39;s logic<br>  async (input) =&gt; {<br>    // Assumes firestore collection &#39;orders&#39; exists<br>    const doc = await firestore.collection(&quot;orders&quot;).doc(input.orderId).get();<br>    return doc.data() as z.infer&lt;typeof OrderSchema&gt; | undefined;<br>  }<br>);</pre><p>This getOrderInfo tool takes an orderId as input, fetches the corresponding document from Firestore, and returns the data conforming to our OrderSchema.</p><h3>4. Setting up the MCP Server</h3><p>With the core components defined (schema, data management flows, actionable tools), you can assemble the MCP server using the genkitx-mcp plugin. This makes your Genkit flows and tools accessible via the MCP protocol.</p><pre>import { mcpServer } from &quot;genkitx-mcp&quot;;<br>import { SSEServerTransport } from &quot;@modelcontextprotocol/sdk/server/sse.js&quot;;<br>import express from &quot;express&quot;;<br><br>// Create MCP server using genkitx-mcp plugin.<br>// It automatically discovers tools defined on &#39;ai&#39;<br>const mcp = mcpServer(ai, { name: &quot;orders&quot;, version: &quot;0.0.1&quot; });<br><br>// Create an express server to serve the MCP server using SSEServerTransport<br>const app = express();<br>let transport: SSEServerTransport | null = null;<br><br>// Endpoint for clients (like Cline) to establish an SSE connection<br>app.get(&quot;/sse&quot;, (req, res) =&gt; {<br>  transport = new SSEServerTransport(&quot;/messages&quot;, res);<br>  mcp.server!.connect(transport);<br>});<br><br>app.post(&quot;/messages&quot;, (req, res) =&gt; {<br>  if (transport) {<br>    transport.handlePostMessage(req, res);<br>  }<br>});<br><br>const port = 3000;<br>app.listen(port, () =&gt; {<br>  console.log(`MCP server listening on http://localhost:${port}`);<br>  console.log(`Connect Cline or other clients to http://localhost:${port}/sse endpoint.`);<br>});</pre><p>This setup initializes the MCP server, configures an Express application, and uses Server-Sent Events (SSE) for transport.</p><p>Now when you run the MCP server, you can access it from an MCP client like Cline and can give it tasks like: “build a website using information from order id: A-123–456”.</p><p>See the demo in the video linked above (around <a href="https://youtu.be/Lc0iQdm3AAY?si=-_F9rZ94h-YqYMTn&amp;t=446">7:26 mark</a>).</p><h3>Conclusion</h3><p>Genkit provides a robust and developer-friendly framework for building sophisticated AI-powered applications and backends. It simplifies development with features like clear data structure definition using familiar tools like Zod, straightforward orchestration of tasks through flows, the creation of discrete, reusable actions as tools, and integrated observability for monitoring traces and performance during development and in production.</p><p>By integrating seamlessly with MCP, Genkit enables these defined tools to be exposed through a standardized interface. This makes your application’s capabilities readily accessible not only for direct interaction using MCP-compatible development tools (such as Cline) but also for integration into larger AI systems or agent-based architectures. Defining tools like getOrderInfo effectively creates callable endpoints for specific AI-powered business logic, ready to be consumed.</p><p>Ultimately, Genkit empowers developers to structure their AI projects effectively, manage complexity, and build interoperable components, significantly streamlining the development of modern, intelligent applications.</p><p>Genkit Discord: <a href="http://genkit.dev/discord">http://genkit.dev/discord</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2053cde230f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/building-your-first-mcp-server-with-genkit-c2053cde230f">Building Your First MCP Server with Genkit</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Develop Firebase Genkit Flows]]></title>
            <link>https://medium.com/firebase-developers/how-to-develop-firebase-genkit-functions-2677b386a227?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/2677b386a227</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[firestore]]></category>
            <category><![CDATA[genkit]]></category>
            <dc:creator><![CDATA[Nozomi Koborinai]]></dc:creator>
            <pubDate>Sat, 15 Mar 2025 10:00:54 GMT</pubDate>
            <atom:updated>2025-11-26T14:47:57.354Z</atom:updated>
            <content:encoded><![CDATA[<h4>AI</h4><h3>How to Develop Genkit Flows</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q9UeZMIyju5CmlcAGr0eJg.png" /></figure><p><strong>Genkit</strong> includes a powerful tool called the <strong>Genkit Developer UI</strong> that can significantly accelerate the development of <strong>Genkit Flows</strong> by enabling local testing. However, when integrating with other Firebase products, such as Firestore or Cloud Storage, the Genkit Developer UI may not be sufficient.</p><p>In this article, I’ll walk you through how to enhance your local testing environment by integrating the <strong>Firebase Local Emulator Suite</strong> to test Genkit Flows more effectively.</p><h3>Genkit Developer UI</h3><p>The Genkit Developer UI is an essential tool that allows you to verify the behavior of Genkit Flows locally before deploying them. (It has a great UI, and it’s super exciting to use!!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1bwe736Boxpnrwyv.png" /></figure><p>While the Genkit Developer UI provides a fantastic developer experience, it does have some limitations.</p><h3><strong>The Limitation</strong></h3><p>The challenge comes when you need to integrate other Firebase products. For example, when you create a configuration where <strong>Genkit</strong> communicates with <strong>Firestore</strong>, such as the one I discussed in my previous article,<a href="https://medium.com/@nozomi-koborinai/orchestrating-firebase-and-ai-8-genkit-architecture-patterns-12e44db40345"> “8 Genkit Architectures to Orchestrate Firebase &amp; AI”</a>.</p><p>To clarify this, let’s look at two cases.</p><h4><strong>Working with self-contained flows</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nVBYu6V8qlTLskH10n4Jng.png" /><figcaption>OK case</figcaption></figure><p>In this case, the entire processing is self-contained within Genkit, with no need to integrate Firebase products like Firestore or Cloud Storage, so you can run everything locally using the Genkit Developer UI.</p><pre>export const firebaseAuthFlow = onFlow(<br>  ai,<br>  {<br>    name: `firebaseAuthFlow`,<br>    outputSchema: z.string(),<br>    authPolicy: firebaseAuth((user) =&gt; {<br>      if (user.firebase?.sign_in_provider !== `anonymous`) {<br>        throw new Error(`Only anonymously authenticated users can access this function`)<br>      }<br>    }),<br>    httpsOptions: {<br>      secrets: [googleAIapiKey],<br>      cors: true,<br>    },<br>  },<br>  async () =&gt; {}<br>)</pre><p><em>Even though this function uses authPolicy with </em><strong><em>Firebase Authentication</em></strong><em>, Genkit Developer UI allows you to inject an authentication provider, so local testing is still possible.</em></p><h4><strong>Working with Flows that require Firebase services</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxA7xQBzKYD1-lvkgqZOCA.png" /><figcaption>Further testing required case</figcaption></figure><p>In this scenario, since Firestore is being accessed within async (input) =&gt;, the Genkit Developer UI cannot connect to the Firestore database, making local testing impossible.</p><p>Many developers might deploy their functions to a live environment and test their behavior by accessing the endpoint, which is less efficient.</p><pre>export const generateChatMessageFlow = onFlow(<br>  ai,<br>  {<br>    name: `generateChatMessageFlow`,<br>    inputSchema: z.object({<br>      userId: z.string(),<br>      chatId: z.string(),<br>    }),<br>    outputSchema: z.object({<br>      response: z.string(),<br>    }),<br>    authPolicy: firebaseAuth((user) =&gt; {<br>      if (user.firebase?.sign_in_provider !== `anonymous`) {<br>        throw new Error(`Only anonymously authenticated users can access this function`)<br>      }<br>    }),<br>    httpsOptions: {<br>      secrets: [googleAIapiKey],<br>      cors: true,<br>    },<br>  },<br>  async (input) =&gt; {<br>    try {<br>      // Initialize Firestore<br>      const db = getFirestore()<br><br>      // Retrieve chat document<br>      const chatDoc = await db.collection(`chats`).doc(input.chatId).get()<br><br>      if (!chatDoc.exists) throw new Error(`Chat document not found`)<br><br>      // Retrieve message history for context<br>      const messagesSnapshot = await chatDoc.ref.collection(`messages`).get()<br><br>      // Transform Firestore documents into message objects<br>      const messages = messagesSnapshot.docs.map((doc) =&gt; ({<br>        createdAt: doc.data().createdAt.toDate().toString(),<br>        isUser: doc.data().isUser,<br>        text: doc.data().text,<br>      }))<br><br>      // Generate AI response using chat history<br>      const { output } = await generateChatMessagePrompt({ messages })<br><br>      // Store AI response in Firestore<br>      await chatDoc.ref.collection(`messages`).add({<br>        createdAt: Timestamp.now(),<br>        isUser: false,<br>        text: output.response,<br>      })<br><br>      // Store data in Firestore, but return to client as a response just in case<br>      return output<br>    } catch (error) {<br>      console.error(`Error in generateChatMessage:`, error)<br>      throw error<br>    }<br>  }<br>)</pre><h3><strong>Integrating Genkit flows with the Firebase Local Emulator Suite</strong></h3><p>If your flows require Firebase services, you can use the <strong>Firebase Local Emulator Suite</strong> to simulate Firebase products like Firestore and Cloud Storage, enabling you to test Genkit Flows locally.</p><p>Let’s see how to set this up.</p><h4><strong>Understanding the Flow</strong></h4><p>In our example, the flow needs to perform the following steps:</p><p>1. Retrieve data from Firestore.</p><p>2. Process the chat message using an AI model.</p><p>3. Write the processed message back to Firestore.</p><p>To achieve this, Firestore must be accessible, and we can use Firebase Local Emulator Suite for that. Below are the schema and key code snippets involved in this process.</p><h4><strong>Firestore Schema</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*qLcT29flyCiXW4lX42_HNg.png" /><figcaption>Schemas</figcaption></figure><h4><strong>Key Code Snippets</strong></h4><p>1. Retrieving Data from Firestore</p><pre>const chatDoc = await db.collection(`chats`).doc(input.chatId).get()<br><br>const messagesSnapshot = await chatDoc.ref.collection(`messages`).get()<br><br>const messages = messagesSnapshot.docs.map((doc) =&gt; ({<br>  createdAt: doc.data().createdAt.toDate().toString(),<br>  isUser: doc.data().isUser,<br>  text: doc.data().text,<br>}))</pre><p>2. Processing Chat Messages with AI</p><pre>const { output } = await generateChatMessagePrompt({ messages })</pre><p>3. Writing the Processed Message Back to Firestore</p><pre>await chatDoc.ref.collection(`messages`).add({<br>  createdAt: Timestamp.now(),<br>  isUser: false,<br>  text: output.response,<br>})</pre><h4><strong>Configuring Firebase Local Emulator Suite</strong></h4><p>To connect the Genkit Developer UI to Firebase Local Emulator, follow these steps.</p><p>0. Install</p><pre>firebase init</pre><p>1. Start Firebase emulator and Genkit Developer UI</p><p>The following command will start the Genkit Developer UI with a connection to the Firebase emulator.</p><pre>npx genkit start -- firebase emulators:start --inspect-functions</pre><h4><strong>Verifying Genkit Flows locally</strong></h4><p>Now that your local environment is set up, you can proceed to verify your Genkit Flows.</p><p><strong>1. Prepare Firestore Data in Firestore Emulator</strong></p><p>Since the function uses Firestore data, we’ll begin by launching Firestore from the Firebase Local Emulator Suite UI and populating it with test data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYS-ifoK-NlE1tz28PSwEA.png" /><figcaption>Chats Collection</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Imz6w2EdDr4hSO2-SLeCQQ.png" /><figcaption>Messages Sub Collection</figcaption></figure><p><strong>2. Run Genkit Flows in Genkit Developer UI</strong></p><p>Now, using the Genkit Developer UI, input the required values according to the defined request schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOBs_gM9zPn4fpw4kVwFlA.png" /><figcaption><em>Genkit </em>Developer UI</figcaption></figure><p>Since this example uses anonymous authentication, you’ll also need to inject an authentication provider through the Auth JSON tab in the Genkit Developer UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_WVkxCJcQa70F1MDe32nw.png" /><figcaption><em>Genkit </em>Developer UI<em> &gt; Auth JSON</em></figcaption></figure><p>For reference, check out <a href="https://firebase.google.com/docs/rules/rules-and-auth#identify_users">How to Identify Users</a>.</p><p>Once everything is set, hit the <strong>Run</strong> button to execute the flow. You should see that the function returns a response after reading from the Firestore Emulator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z35zDlgeIKnRGiUSaqGlFQ.png" /><figcaption>Response</figcaption></figure><p>Additionally, as the flow writes data back to Firestore, you can check the Firestore Emulator to confirm the new data has been added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjoEfxeiKUQMXaaBsKXrAQ.png" /><figcaption><em>Firestore Emulator</em></figcaption></figure><h3><strong>References</strong></h3><p><a href="https://genkit.dev/docs/deployment/firebase/">Deploy with Firebase</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2677b386a227" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/how-to-develop-firebase-genkit-functions-2677b386a227">How to Develop Firebase Genkit Flows</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[internal AI: A Genkit-Based Internal AI Chat Released as Open Source!]]></title>
            <link>https://medium.com/firebase-developers/internal-ai-a-genkit-based-internal-ai-chat-released-as-open-source-37795896a106?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/37795896a106</guid>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[genkit]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[tanabee]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 17:14:41 GMT</pubDate>
            <atom:updated>2025-03-23T06:26:40.362Z</atom:updated>
            <content:encoded><![CDATA[<h3>internal AI: An open-source Genkit-based internal AI chat implementation</h3><p>I have released <strong>internal AI</strong>, an AI chat solution you can easily and cost-effectively run internally, under an open-source license!</p><p>Recently, <a href="https://firebase.blog/posts/2025/02/announcing-genkit">Firebase Genkit reached version 1.0</a> and became stable for production use. With Genkit, you can quickly build applications that leverage generative AI. However, Genkit itself does not include a user interface. As a use case for an internal AI chat, I decided to make <strong>internal AI</strong> available as open source.</p><p>Because <strong>internal AI</strong> uses a pay-as-you-go model instead of charging per user, you can optimize costs by only paying for the amount of usage. Moreover, thanks to Genkit’s extensibility, you can combine <a href="https://firebase.google.com/docs/genkit/rag">RAG</a> (Retrieval-Augmented Generation) and <a href="https://firebase.google.com/docs/genkit/tool-calling">Function Calling</a> to tailor AI features to your organization’s needs. This opens the door to more practical AI applications, such as specialized internal information retrieval or automated workflow processes!</p><p><a href="https://github.com/tanabee/internal-ai">GitHub - tanabee/internal-ai</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCz6uCYuM3HrrjtC3ZnYnA.gif" /><figcaption>internal AI — Chat</figcaption></figure><h3>Key Features</h3><ul><li><strong>Open-source</strong> project, allowing customization to fit your organization’s needs</li><li><strong>Abstracted interface</strong> with generative AI via Genkit</li><li><strong>Deployable on Firebase</strong></li><li><strong>Firebase AI Monitoring</strong> for monitoring requests to generative AI</li><li><strong>Restricting Usage</strong> to Specific Domains</li><li><strong>Usage-based pricing</strong>, independent of the number of users</li></ul><h3>Open-source project, allowing customization to fit your organization’s needs</h3><p><strong>internal AI</strong> is provided as a boilerplate, which you can freely fork and customize according to your organization’s requirements.</p><p>Genkit can be extended in many ways, such as using RAG for accessing internal data or utilizing Google Search for grounding. To keep things simple for initial adoption, this example just communicates with Gemini 2.0.</p><pre>const ai = genkit({<br> // …<br> model: gemini20Flash001,<br>})<br>export const chatFlow = ai.defineFlow(<br> // …<br> async (messages) =&gt; {<br> const response = await ai.generate({ messages })<br> return response.messages<br> },<br>)</pre><p><a href="https://github.com/tanabee/internal-ai/blob/main/functions/src/genkit/chatFlow.ts">internal-ai/functions/src/genkit/chatFlow.ts at main · tanabee/internal-ai</a></p><h3>Abstracted interface with generative AI via Genkit</h3><p>In this project, I’m using Vertex AI via Genkit, but you can change the backend or model based on your needs.</p><p>Genkit follows a policy of community plugins named in the format “genkitx-*”. If you need a model not provided by the official plugins, you might find it by searching npm.</p><p><a href="https://www.npmjs.com/search?q=genkitx-">genkitx- - npm search</a></p><h3>Deployable on Firebase</h3><p>I designed this project to be deployed on Firebase. The following Firebase services are used, all of which can be managed through the Firebase Console. In addition, you can run everything locally with the Firebase Emulator, making it possible to verify all behaviors in a local environment.</p><ul><li><strong>Firestore</strong>: Used as the database, storing chat histories and user information</li><li><strong>Cloud Functions for Firebase</strong>: Server-side execution environment</li><li><strong>Firebase Authentication</strong>: Authentication layer</li><li><strong>Firebase Hosting</strong>: Hosts the web application</li><li><strong>Firebase Genkit</strong>: Interface to generative AI and monitoring of AI requests</li></ul><h3>Firebase AI Monitoring for monitoring requests to generative AI</h3><p>You can monitor requests to generative AI made through Genkit. This lets you see metrics like success rates and token consumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VgzEMwT1hpNJeQKnf1PCIQ.png" /><figcaption>Firebase AI Monitoring</figcaption></figure><h3>Restricting Usage to Specific Domains</h3><p>To limit usage to your organization, you can use Firebase Authentication Blocking Functions to set email domain restrictions. You’re also free to modify the restriction logic in the source code. For instance, you could allow multiple domains or grant access only to specific users for personal use — whatever suits your needs.</p><pre>export const beforeusercreated = beforeUserCreated(async (event) =&gt; {<br>  // TODO: Replace with your company domain<br>  const domain = &#39;@tanabee.dev&#39;<br>  if (!user?.email?.includes(domain)) {<br>    throw new HttpsError(&#39;permission-denied&#39;, &#39;Unauthorized email&#39;)<br>  }<br>})</pre><p>Additionally, there’s an Admin console accessible only by administrators, where you can add more menu options as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9zQcYXzyydPtNSmtbTC4Q.png" /><figcaption>internal AI — Admin Console</figcaption></figure><h3>Usage-based pricing, independent of the number of users</h3><p><strong>internal AI</strong> is billed based on usage rather than the number of users, so you only pay for what you actually use. For most organizations, this can significantly reduce costs.</p><p>There are also additional Firebase charges, but for smaller organizations, you may well operate within the free tier, making it extremely cost-effective to adopt.</p><p>Because it uses Vertex AI for LLM connections, all billing is tied to your GCP project, which allows you to manage costs centrally.</p><h3>Special Thanks for the Design</h3><p>The UI design for <strong>internal AI</strong> was created by <a href="https://x.com/hikarutayama">Hikaru Tayama</a>! Thanks to the simple and intuitive design, it’s easy to use. I truly appreciate this excellent work, which has helped <strong>internal AI</strong> become a project that many can enjoy comfortably.</p><h3>Conclusion</h3><p>If you’re interested, I’ve prepared an <a href="https://github.com/tanabee/internal-ai/blob/main/docs/installation-guide.md">installation guide</a>. Feel free to fork it and try it out within your company.</p><p><a href="https://github.com/tanabee/internal-ai/blob/main/docs/installation-guide.md">internal-ai/docs/installation-guide.md at main · tanabee/internal-ai</a></p><h3>Related Posts</h3><ul><li><a href="https://medium.com/firebase-developers/implementing-function-calling-using-genkit-0c03f6cb9179">Implementing Function Calling using Genkit</a></li><li><a href="https://medium.com/firebase-developers/high-precision-responses-with-genkits-google-search-integration-7f142f5c9693">High-Precision Responses with Genkit’s Google Search Integration</a></li><li><a href="https://medium.com/firebase-developers/how-to-develop-using-the-gemma2-model-in-genkit-085f22ce68f3">Master Gemma2 and Genkit</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37795896a106" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/internal-ai-a-genkit-based-internal-ai-chat-released-as-open-source-37795896a106">internal AI: A Genkit-Based Internal AI Chat Released as Open Source!</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bring Relational Power to Firebase with Firebase Data Connect]]></title>
            <link>https://medium.com/firebase-developers/bring-relational-power-to-firebase-with-firebase-data-connect-e65e5c420ca8?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/e65e5c420ca8</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[firebase-database]]></category>
            <category><![CDATA[sql-database]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Nui Somjin]]></dc:creator>
            <pubDate>Tue, 17 Dec 2024 14:09:33 GMT</pubDate>
            <atom:updated>2024-12-17T15:26:53.781Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmCt4FU2oIqndlWc-Jv-tA.png" /><figcaption>This article has been translated from its original <a href="https://medium.com/firebasethailand/firebase-data-connect-%E0%B8%9A%E0%B8%A3%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%97%E0%B8%B3%E0%B9%83%E0%B8%AB%E0%B9%89-firebase-%E0%B9%80%E0%B8%8A%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%A1%E0%B8%95%E0%B9%88%E0%B8%AD%E0%B8%81%E0%B8%B1%E0%B8%9A-postgressql-%E0%B9%84%E0%B8%94%E0%B9%89%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86-43a3b0ff6141">blog post in Thai</a></figcaption></figure><p>Many of us are familiar with Firebase as a robust Backend-as-a-Service, renowned for its NoSQL databases such as Realtime Database (since 2012) and Cloud Firestore (since 2017). However, both have limitations when handling complex queries. The Firebase community has long been requesting a SQL database solution to address redundancy and facilitate complex queries.</p><p>At the recent Google I/O, Firebase introduced Firebase Data Connect, its first relational database offering 🎉</p><h3>How Firebase Data Connect Works</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLTQGzXCFGGTVuXvk-_1VQ.png" /><figcaption>App data flow</figcaption></figure><p>While Firebase Data Connect interacts with databases, it’s more accurately described as an interface. Under the hood, it’s leveraging PostgreSQL on GCP Cloud and providing a GraphQL-based bridge to connect clients with the SQL database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*POGsEgp0V0Oti_BvrTe6Xg.png" /><figcaption>Firebase Data Connect capabilities that make working with PostgresSQL easier</figcaption></figure><p>The Firebase team built Data Connect with the philosophy of ‘You write the query, we do the rest.’ Developers only need to define two things, and Firebase handles the rest, allowing developers to focus on their application’s core logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOgrNje-L-rAKEMF_EKdrA.png" /><figcaption><strong><em>“You write the query, we do the rest”</em></strong></figcaption></figure><h4><strong>Firebase provides (in GraphQL):</strong></h4><ul><li><strong>Data model (schema):</strong> This specifies the database schema, including the tables, columns, and data types.</li><li><strong>Connectors (queries &amp; mutations):</strong> These define the operations for creating, reading, updating, and deleting data within the database.</li></ul><h4><strong>Firebase automatically creates:</strong></h4><ul><li><strong>PostgresSQL schema:</strong> Generates the SQL commands to create the database structure in PostgreSQL, including migrations.</li><li><strong>Type-safe SDK:</strong> Provides a strongly-typed SDK for client applications (iOS, Android, Web, Flutter) to interact with the database.</li><li><strong>API Endpoints:</strong> Creates API endpoints for clients to perform CRUD operations on the database, complete with authorization mechanisms to control user permissions. For instance, all users might be able to view product listings, but only admins can add new products.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Ubdh2wWnIUP6F9xs3t9tw.png" /><figcaption>We define Data Model with GraphQL ➡ Firebase automatically generates SQL schema</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6ScWLe3emKSO0X4dRPFpg.png" /><figcaption>Queries and Mutations, defined via GraphQL</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ElCnMOpSrvW1PESVNVgM9Q.png" /><figcaption>Auto-generated API Endpoint from Firebase</figcaption></figure><h3>Getting started with Firebase Data Connect</h3><p>The process consists of 6 steps</p><pre>0. Set up the environment<br>1. Define the data model (schema)<br>2. Define the connector (queries, mutations)<br>3. Test locally<br>4. Integrate into the client app<br>5. Deploy to production</pre><h4>0. Set up the environment</h4><p>Firebase Data Connect can be initiated either through the user-friendly Firebase Console interface or by utilizing the command-line interface provided by the <a href="https://firebase.google.com/docs/cli">Firebase CLI</a>.</p><pre>firebase init dataconnect</pre><p>During the installation process, we’ll need to specify the Cloud SQL instance ID, database ID, and desired region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lPQ1JhLV1YYJfkT-S744EQ.png" /><figcaption>Start a new Data Connect project using the command-line interface, and simultaneously set up a fresh Cloud SQL instance via Data Connect while it’s in public preview (eligible for a 3-month free trial).</figcaption></figure><p>As mentioned earlier, Firebase Data Connect is backed by Cloud SQL. To initialize the Data Connect via Firebase also means to create a Cloud SQL instance and a PostgreSQL database (if you haven’t already created one). Make sure your project is on the Blaze Plan (pay-as-you-go) before using this service.</p><p>During the public preview, creating a new database instance through Firebase Data Connect grants you a free 3-month trial of a Cloud SQL instance (db-f1-micro 1 vCPU, 600 MB RAM, and 10 GB storage). After the trial, standard pricing will apply based on instance size and usage. For detailed pricing, refer to the <a href="https://firebase.blog/posts/2024/11/dataconnect-pricing">Data Connect Pricing</a>.</p><p>After the setup is complete, you’ll have a Data Connect folder containing three components</p><ol><li><strong>connector folder</strong> for querying and mutating data.</li><li><strong>schema folder</strong> for defining the database data model.</li><li><strong>dataconnect.yaml file</strong> for the configuration.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ibh_5exyp6AYiWiOjcK_ng.png" /><figcaption>The dataconnect.yaml file stores various config information that we connect to CloudSQL.</figcaption></figure><h4>1. Define the data model (schema)</h4><p>Imagine we’re building an app for a board game store. The first thing we need to do is figure out how we want to organize all the data. Here’s an example of what this might look like using GraphQL in a file named schema.gql within the schema folder.</p><pre># schema.gql<br><br># Users<br>type User @table {<br>  id: String! @col(name: &quot;auth_uid&quot;)<br>  username: String! @col(name: &quot;username&quot;, dataType: &quot;varchar(50)&quot;)<br>}<br><br># Games<br>type Game @table {<br>  # The below parameter values are generated by default with @table, and can be edited manually.<br>  # implies directive `@col(name: &quot;game_id&quot;)`, generating a column name<br>  id: UUID! @default(expr: &quot;uuidV4()&quot;)<br>  title: String!<br>  description: String!<br>  imageUrl: String!<br>  genre: String<br>  emoji: String<br>  minAge: Int<br>  minPlayers: Int<br>  maxPlayers: Int<br>  playTime: Int<br>  descriptionEmbedding: Vector @col(size: 768) # Enables vector search<br>}<br><br># Reservations<br>type Reservation<br>  @table(name: &quot;reservations&quot;, key: [&quot;game&quot;, &quot;user&quot;, &quot;timeSlot&quot;]) {<br>  id: UUID! @default(expr: &quot;uuidV4()&quot;)<br>  user: User!<br>  game: Game!<br>  timeSlot: Timestamp!<br>  createAt: Date! @default(expr: &quot;request.time&quot;)<br>}</pre><p>Think of the user table as a list of all our players. The game table is a catalog of our games. The reservation table acts like a bridge between the two, showing which user has reserved which game and when. This table can have multiple foreign keys to connect to both the user and game tables, as shown in the code snippet.</p><h4>2. Define the connector (queries, mutations)</h4><p>This involves performing CRUD (Create, Read, Update, Delete) operations, such as retrieving or modifying data from the database. For example, in our board game store app, we might want to implement connectors as follows:</p><ul><li><strong>All users can search for board games, using keywords related to age and the number of players</strong></li></ul><p>The @auth(level: PUBLIC) directive specifies that this query is accessible to all users without requiring prior login.</p><pre># queries.gql<br><br>query SearchGames($keyword: String!, $minAge: Int, $player: Int)<br>@auth(level: PUBLIC) {<br>  games(<br>    where: {<br>      _and: [<br>        { minAge: { ge: $minAge } }<br>        { minPlayers: { le: $player } }<br>        { maxPlayers: { ge: $player } }<br>        {<br>          _or: [<br>            { title: { contains: $keyword } }<br>            { description: { contains: $keyword } }<br>            { genre: { contains: $keyword } }<br>          ]<br>        }<br>      ]<br>    }<br>  ) {<br>    ...DisplayGame<br>  }<br>}</pre><ul><li><strong>Users can only view their own reservations</strong></li></ul><p>The @auth(level: USER) directive ensures that only authenticated users can access this query. The eq_expr: &quot;auth.uid&quot; expression in the where clause utilizes the uid value from the provided auth token, enhancing security by eliminating the need for explicit uid parameters.</p><pre># queries.gql<br><br>query ListMyReservations @auth(level: USER) {<br>  reservations(where: { user: { id: { eq_expr: &quot;auth.uid&quot; } } }) {<br>    id<br>    game {<br>      ...DisplayGame<br>    }<br>    timeSlot<br>  }<br>}</pre><ul><li><strong>Only administrators can add new games</strong></li></ul><p>We can write an expression to check the token’s claims. For instance, if the token contains an isAdmin claim, we can verify that its value is true before granting the user permission to insert new game data into the database.</p><pre># mutations.gql<br><br>mutation CreateGame(<br>  $title: String!<br>  $description: String!<br>  ...<br>) @auth(expr: &quot;auth.token.isAdmin == true&quot;) {<br>  game_insert(<br>    data: {<br>      title: $title<br>      description: $description<br>      ...<br>    }<br>  )<br>}</pre><p>From the examples above, we can summarize the core concepts of creating connectors into 3 main parts:</p><ol><li><strong>Accepting parameters:</strong> We can pass parameters to queries to filter results. For example, specifying a minimum age to find suitable games.</li><li><strong>Defining access control:</strong> We can control access to endpoints using the @auth directive. We can either specify a predefined level or create custom expressions. If no @auth directive is provided, access is restricted to the Admin SDK by default. For more details on authorization, refer to <a href="https://firebase.google.com/docs/data-connect/authorization-and-security">Secure Data Connect with authorization and attestation</a>.</li><li><strong>Write SQL statements:</strong> including queries and mutations, following the GraphQL schema. Refer to the <a href="https://firebase.google.com/docs/reference/data-connect">Firebase Data Connect API Reference</a> for detailed instructions.</li></ol><p>While GraphQL is great for most queries, Firebase Data Connect also offers the flexibility to write raw SQL queries for more complex scenarios. This allows you to create custom database views tailored to your specific use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8GeskBGKtCXFfKy-.png" /><figcaption><em>An example of using raw SQL to create a new view named “ReviewInfo” containing information about restaurants and their average reviews.</em></figcaption></figure><h4>3. Test locally</h4><p>Firebase Data Connect supports emulators, allowing for comprehensive local development and testing before deployment to production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I762z7ERESUMYMETHJzAxw.png" /></figure><p><strong>3.1 Extensions<br></strong>To streamline a Data Connect workflow in VSCode or IDX, consider installing the Firebase Data Connect extension. This extension offers features like GraphQL autocompletion, a user interface for connecting to local emulators, and a tool for testing connections to our database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hZzEJ6UqljJ0q40w.png" /><figcaption><a href="https://marketplace.visualstudio.com/items?itemName=GoogleCloudTools.firebase-dataconnect-vscode">Firebase Data Connect extension for VSCode</a></figcaption></figure><p>Once we run the command</p><pre>firebase emulators:start</pre><p>We will see the Run (local) option. We could also go in DATA CONNECT EXECUTION tab to test the connection to our auto-generated API endpoints. After defining parameter variables and authentication, we can then click on “Run (local)” to test the endpoint locally or “Run (production)” to directly invoke the endpoint in the production environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQCTbSMKUBNXIZGFQqf_2g.png" /></figure><p>We can further customize the authentication process for each endpoint. For instance, we can define a rule for the SearchGame endpoint: @auth(level: USER_EMAIL_VERIFIED). This means only users with verified email addresses can access this endpoint. To test this scenario, we can configure the authentication settings during testing by setting the “Run as” to be “Authenticated” but with the email_verified flag set to false. When we run the test locally, we should receive a 401 Unauthorized error, confirming that the authentication requirement is enforced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qbR0ARWV2vRcOBYYfiM1RQ.png" /></figure><p><strong>3.2 Data Seeding</strong><br>During local development, the database is cleared before each run. To pre-populate the database with some necessary data, we can create mutations to insert initial records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*8hWCWP6eHrQwxBAA.png" /><figcaption>A file used to populate a database with initial game data</figcaption></figure><p>Once we’ve finished running the emulators, we can click “Run (local)” on this command to populate the initial data into our database.</p><p><strong>3.3 Exploring the data <br></strong>My SQL workflow typically involves tabular data visualization. While Firebase Data Connect currently lacks this feature, all output from testing each endpoint is simply returned in JSON format. As mentioned earlier, the underlying database is PostgreSQL, and Firebase uses PGLite for local execution, making tabular data viewing possible. We can utilize SQL viewers like DBeaver, DataGrip, or other preferred tools to establish a connection to jdbc:postgressql://127.0.0.1:5432/[databaseName]?sslmode=disable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sWrsNA7MsEEgj4HJ.png" /><figcaption>Connection configuration for connecting to PostgresSQL locally with DBeaver</figcaption></figure><p>After that, we can look around at the data in each table and see how the database is structured, just like any other SQL database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ltXtYt1vv7zkrZ4-.png" /><figcaption>The ER Diagram of our database / The data we added to the Game table viewed through DBeaver</figcaption></figure><h4>4. Integrate into the client app</h4><p>I have put together a Vue web application as an example. It lists all the games and lets you search for specific ones using keywords like game name, age rating, or number of players.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*TBjN6euXc051WDWv.png" /><figcaption>The app UI after connecting with database</figcaption></figure><p>Having defined our data model and connectors, we’re ready to integrate them with our frontend. To streamline this process, we’ll leverage Firebase’s generated type-safe SDK instead of directly interacting with the database.</p><p>The connector.yaml file, generated during setup, determines the SDK’s destination and package name. Firebase will then create a customized SDK that can be seamlessly integrated into various client platforms including iOS, Android, Web, and Flutter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HpfDTnu68slqW5OD.png" /></figure><p>All configurations will be initially commented out. We can uncomment and customize the settings according to our requirements. In this specific configuration, the output directory is set to the ‘app’ folder, corresponding to the Vue application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mTg9zTM_6e9hZaKlwG5IUg.png" /></figure><p><strong>4.1 Connect UI with Data Connect Emulators</strong></p><pre>/* lib/firebase.ts */<br><br>export const firebaseApp = initializeApp({<br>  // your config from Firebase console<br>})<br>const auth = getAuth(firebaseApp)<br>const dataconnect = getDataConnect(firebaseApp, connectorConfig)<br>if (import.meta.env.DEV) {<br>  connectDataConnectEmulator(dataconnect, &#39;127.0.0.1&#39;, 9398, false)<br>  connectAuthEmulator(auth, &#39;http://localhost:9098&#39;)<br>}<br>export { auth, dataconnect }</pre><p><strong>4.2 Utilize functions and types provided by the SDK on the client-side</strong></p><pre>import { searchGames } from &#39;@dicely/dataconnect&#39;<br><br>const response = await searchGames({<br>  keyword: qParams.keyword,<br>  minAge: qParams.minAge ? Number(qParams.minAge) : undefined,<br>  player: qParams.player ? Number(qParams.player) : undefined,<br>})<br>/* ใช้ค่า response.data ใน UI <br> games.value = response.data.games as Game[]<br>*/</pre><p>As soon as we run this, it’ll automatically call the Firebase API endpoint and handle all the authentication stuff for us. It’s really this simple — just call the function and you’re good to go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*jPjyLEnrtFtVEU7s.png" /><figcaption>API Endpoint for searching game, auto-generated by Firebase</figcaption></figure><h4>5. Deploy to production</h4><p>Once we are satisfied with our local testing, we can execute the firebase deploy command to deploy the entire application or specifically deploy some product (e.g. dataconnect) to the production environment with</p><pre>firebase deploy --only dataconnect</pre><p>If there are any changes to our database that could potentially impact our production Firebase deployment, we will be notified beforehand. Alternatively, we can execute a command to review database changes before deploying.</p><pre>firebase dataconnect:sql:diff</pre><p>Once the deployment is complete, we can verify the data through the Firebase Console or inspect the Cloud SQL instance in the Google Cloud Console too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sqlYcEUQLlJfi-We.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-eURMftFXx_pLSRK.png" /><figcaption>We could explore the data in the Data Connect section of the Firebase Console or use Cloud Studio on Google Cloud Platform</figcaption></figure><h3>The workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vW5U91wf24gzERnO_G5O9w.png" /></figure><p>Whether developing for production or locally, our workflow as developers remains consistent:</p><ol><li>Define the data model and connectors using GraphQL.</li><li>Create an SDK for client-side usage.</li><li>Connect to the database via the client SDK.</li></ol><p>For those eager to experiment, feel free to check out this Codelab.</p><p><a href="https://firebase.google.com/codelabs/firebase-dataconnect-web?source=post_page-----43a3b0ff6141--------------------------------#0">Build with Firebase Data Connect</a></p><p>The content of this article is based on my talk, <em>Build better AI-driven Cloud SQL apps with Firebase Data Connect, </em>at Google DevFest Bangkok 2024<em>.</em> To make it easier to digest, I’ve decided to break it down into 2 parts. Stay tuned for Part 2, where we’ll be unlocking the full potential of Firebase Data Connect for building databases for AI-powered apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*usMuDzTEVaD2c8SZ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e65e5c420ca8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/bring-relational-power-to-firebase-with-firebase-data-connect-e65e5c420ca8">Bring Relational Power to Firebase with Firebase Data Connect</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firestore for Image Embeddings]]></title>
            <link>https://medium.com/firebase-developers/firestore-for-image-embeddings-f3fa2a5a5058?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/f3fa2a5a5058</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Mete Atamel]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 19:13:03 GMT</pubDate>
            <atom:updated>2024-10-29T19:13:03.809Z</atom:updated>
            <content:encoded><![CDATA[<h4>Powering LLMs with Firestore</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/0*TtO1vK1gOXuOKtu5.png" /></figure><p>In my previous post about <a href="https://medium.com/firebase-developers/firestore-for-text-embedding-and-similarity-search-d74acbc8d6f5">Firestore for Text Embedding and Similarity Search</a>, I talked about how Firestore and LangChain can help you to store <strong>text embeddings</strong> and do similarity searches against them. With <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-multimodal-embeddings">multimodal</a> embedding models, you can generate embeddings not only for text but for images and video as well. In this post, I will show you how to store <strong>image embeddings</strong> in Firestore and later use them for similarity search.</p><h3>Image embeddings support in FirestoreVectorStore</h3><p>As a recap from the previous post, the <a href="https://github.com/googleapis/langchain-google-firestore-python">Firestore for LangChain</a> project provides a FirestoreVectorStore which simplifies storage and retrieval of embeddings.</p><p>Initially, FirestoreVectorStore only supported text embeddings, but we recently added a new <a href="https://cloud.google.com/python/docs/reference/langchain-google-firestore/latest/langchain_google_firestore.vectorstores.FirestoreVectorStore#langchain_google_firestore_vectorstores_FirestoreVectorStore_add_images">add_images</a> method to store image embeddings. Likewise, we added the <a href="https://cloud.google.com/python/docs/reference/langchain-google-firestore/latest/langchain_google_firestore.vectorstores.FirestoreVectorStore#langchain_google_firestore_vectorstores_FirestoreVectorStore_similarity_search_image">similarity_search_image</a> method to run similarity searches with image embeddings.</p><p>Let’s take a closer look at how you can use FirestoreVectorStore in LangChain to work with image embeddings.</p><p>First, you need to create a multimodal embedding model that can embed images:</p><pre>from langchain_google_vertexai import VertexAIEmbeddings<br><br>embedding = VertexAIEmbeddings(<br>    model_name=&quot;multimodalembedding&quot;,<br>    project=PROJECT_ID,<br>    location=&quot;us-central1&quot;<br>)</pre><p>Then, you create a Firestore-backed vector store with the embedding model:</p><pre>from langchain_google_firestore import FirestoreVectorStore<br><br>vector_store = FirestoreVectorStore(<br>    collection=COLLECTION_NAME,<br>    embedding_service=embedding,<br>)</pre><p>Now, you can add images stored locally, in Google Cloud Storage, or any image on the web as follows:</p><pre>ids = [&quot;landmark1.png&quot;, &quot;landmark2.png&quot;, &quot;landmark3.png&quot;]<br>image_paths = [<br>    &quot;gs://your-storage-bucket/landmark1.png&quot;,<br>    &quot;./images/landmark2.png&quot;,<br>    &quot;https://your-website/images/landmark3.png&quot;,<br>]<br><br>vector_store.add_images(image_paths, ids=ids)</pre><p>This creates embeddings for each image and saves them to Firestore.</p><p>Afterwards, you can perform a similarity search with a text query:</p><pre>vector_store.similarity_search(&quot;stadium&quot;, k=3)</pre><p>You can also perform a similarity search with an image. In that case, the image is first embedded and the resulting embedding is then used to retrieve the similar images:</p><pre>image_path = &quot;../images/landmark4.png&quot;<br>vector_store.similarity_search_image(image_path, k=3)</pre><p>You can see play with these examples in the <a href="https://github.com/googleapis/langchain-google-firestore-python/blob/main/docs/vectorstores.ipynb">FirestoreVectorStore notebook</a>.</p><p>Sometimes, it’s useful to store base64 encoded images as content in the Firestore document for easy retrieval. In that case, you can set the store_encodings flag to true:</p><pre>vector_store.add_images(image_paths, ids=ids, store_encodings=True)</pre><p>Note that Firestore documents have a size limit (1 MiB (1,048,576 bytes) — see the <a href="https://firebase.google.com/docs/firestore/quotas#collections_documents_and_fields">Firestore documentation</a> for details) and you might run into that if you try to embed large images and store their base64 encodings.</p><h3>Sample: Image embedding storage and retrieval</h3><p>Let’s see a sample of how to store and retrieve image embeddings with FirestoreVectorStore. The full source code is in <a href="https://github.com/meteatamel/genai-beyond-basics/blob/main/samples/multimodal/retrievers/firestore/main.py">main.py</a>.</p><h4>Firestore database and index</h4><p>First, create a Firestore database for image embeddings:</p><pre>gcloud firestore databases create --database image-database --location=europe-west1</pre><p>Create a Firestore index that we will need for retrieval later. Note that if you forget to do this initially, you’ll get an error when you run your first query with the exact command you need to run in order to create the index:</p><pre>gcloud firestore indexes composite create --project=your-project-id \<br> --database=&quot;image-database&quot; --collection-group=ImageCollection --query-scope=COLLECTION \<br> --field-config=vector-config=&#39;{&quot;dimension&quot;:&quot;1408&quot;,&quot;flat&quot;: &quot;{}&quot;}&#39;,field-path=embedding</pre><h4>Add image embeddings</h4><p>Let’s add some images.</p><p>Add the <a href="https://github.com/meteatamel/genai-beyond-basics/blob/main/samples/multimodal/retrievers/images/landmark1.png">landmark1.png</a> from a Cloud Storage url:</p><pre>python main.py --project_id=genai-atamel --image_paths gs://genai-atamel-firestore-images/landmark1.png</pre><p>Add <a href="https://github.com/meteatamel/genai-beyond-basics/blob/main/samples/multimodal/retrievers/images/landmark2.png">landmark2.png</a> and <a href="https://github.com/meteatamel/genai-beyond-basics/blob/main/samples/multimodal/retrievers/images/landmark3.png">landmark3.png</a> from a local folder:</p><pre>python main.py --project_id=genai-atamel --image_paths ../images/landmark2.png ../images/landmark3.png</pre><p>Add another <a href="https://atamel.dev/img/mete-512.jpg">image</a> from a URL:</p><pre>python main.py --project_id=genai-atamel --image_paths https://atamel.dev/img/mete-512.jpg</pre><p>At this point, you should see images and their embeddings saved to Firestore:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*HrohDYnxrtt0_tXk" /><figcaption>Image embeddings in Firestore</figcaption></figure><h4>Retrieve images</h4><p>Now, you can retrieve and display images with a keyword using the similarity_search method. For example, you can retrieve by the keyword stadium:</p><pre>python main.py --project_id=genai-atamel --search_by_keyword= &quot;stadium&quot;</pre><p>You get back the picture of the Colosseum:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/0*wScOL3DqvlZ4Y2Fu" /></figure><p>You can also search similar images using the similarity_search_image method. For example, you can pass in <a href="https://github.com/meteatamel/genai-beyond-basics/blob/main/samples/multimodal/retrievers/images/landmark4.png">landmark4.png</a>, a picture of a temple:</p><pre>python main.py --project_id=genai-atamel --search_by_image=&quot;../images/landmark4.png&quot;</pre><p>You get back another temple as the most similar image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*K5JQIGHB4xrAJpQQ" /></figure><p>That’s cool!</p><h3>Conclusion</h3><p>In this post, you learned how you can use LangChain and Firestore to store and retrieve image embeddings using a multimodal image embedding model. This allows LLMs to answer questions grounded not only in text but images as well. Try out the new image embedding support in FirestoreVectorStore and let us know what you think!</p><h3>Further reading</h3><ul><li><a href="https://github.com/meteatamel/genai-beyond-basics/blob/main/samples/multimodal/retrievers/firestore">Multimodal image storage and retrieval with Firestore Vector Store</a></li><li><a href="https://cloud.google.com/firestore/docs/langchain">Build LLM-powered applications using LangChain</a></li><li><a href="https://github.com/googleapis/langchain-google-firestore-python">Firestore for LangChain</a></li><li><a href="https://github.com/googleapis/langchain-google-firestore-python/blob/main/docs/vectorstores.ipynb">FirestoreVectorStore notebook</a></li></ul><p><em>Originally published at </em><a href="https://atamel.dev/posts/2024/10-29_firestore_for_image_embeddings/"><em>https://atamel.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3fa2a5a5058" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/firestore-for-image-embeddings-f3fa2a5a5058">Firestore for Image Embeddings</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High-Precision Responses with Genkit’s Google Search Integration]]></title>
            <link>https://medium.com/firebase-developers/high-precision-responses-with-genkits-google-search-integration-7f142f5c9693?source=rss----8e8b7dc6774d---4</link>
            <guid isPermaLink="false">https://medium.com/p/7f142f5c9693</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[genkit]]></category>
            <category><![CDATA[grounding]]></category>
            <category><![CDATA[google-search]]></category>
            <dc:creator><![CDATA[tanabee]]></dc:creator>
            <pubDate>Mon, 21 Oct 2024 18:37:56 GMT</pubDate>
            <atom:updated>2024-11-17T23:58:40.092Z</atom:updated>
            <content:encoded><![CDATA[<h4>aGenkit</h4><p>With the release of Genkit version 0.5.9, it is now possible to leverage Google Search directly through Genkit. By using Google Search, Genkit can access the latest information, including niche details from specific domains, leading to more accurate responses.</p><p>This article explains how to set up Google Search integration for Genkit.</p><h3>Enabling Vertex AI</h3><p>To use the Google Search feature, you need a Google Cloud project with Vertex AI enabled. Follow these steps to enable Vertex AI and link your local environment with Google Cloud:</p><p>1. In the Cloud console, Enable the Vertex AI API for your project.</p><p>2. Set environment variables:</p><pre>export GCLOUD_PROJECT=&lt;your project ID&gt;<br>export GCLOUD_LOCATION=us-central1</pre><p>3. Authenticate with gcloud:</p><pre>gcloud auth application-default login</pre><h3>Initializing a Genkit Project</h3><p>Next, initialize your Genkit project.</p><pre>% npm init -y<br>% npm i -D genkit-cli<br>% npm i genkit @genkit-ai/googleai @genkit-ai/vertexai<br>% mkdir src &amp;&amp; touch src/index.ts</pre><p>Paste the following initialization code into the src/index.ts file.</p><pre>import { genkit, z } from &#39;genkit&#39;;<br>import { vertexAI } from &#39;@genkit-ai/vertexai&#39;;<br>import { gemini15Flash } from &#39;@genkit-ai/vertexai&#39;;<br><br>const ai = genkit({<br>  model: gemini15Flash,<br>  plugins: [vertexAI({ location: &#39;us-central1&#39; })],<br>});<br><br>export const mainFlow = ai.defineFlow(<br>  {<br>    name: &#39;mainFlow&#39;,<br>    inputSchema: z.string(),<br>    outputSchema: z.string(),<br>  },<br>  async (prompt) =&gt; {<br>    const { text } = await ai.generate(prompt);<br>    return text;<br>  }<br>);<br><br>ai.startFlowServer({ flows: [mainFlow] });</pre><h3>Enabling Google Search</h3><p>To enable Google Search, specify `googleSearchRetrieval` with `withConfig` for the `gemini15Flash` model, as shown in the following code.</p><pre>const ai = genkit({<br>  model: gemini15Flash.withConfig({ googleSearchRetrieval: {}}),<br>  plugins: [vertexAI({ location: &#39;us-central1&#39; })],<br>});</pre><h3>Run locally</h3><p>Launch the Genkit Developer UI with the following command:</p><pre>% npx genkit start -- npx tsx --watch src/index.ts</pre><p>Try asking about the current weather in Tokyo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZX-L83SRDc_9kQaScdjCzQ.png" /><figcaption>Ask about Tokyo’s weather using Genkit x Google Search — Flow</figcaption></figure><p>A response will be returned. Clicking the “View Trace” button reveals that Google Search was used with the phrase “weather in Tokyo today”, and the response was generated based on the search results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gl-cBGFz4Z8aSxIH9dZkOg.png" /><figcaption>Ask about Tokyo’s weather using Genkit x Google Search — View Trace</figcaption></figure><h3>Summary</h3><p>Enabling Google Search integration in Genkit is as easy as adding one line of code. You can find the sample code on GitHub, so feel free to try it out.</p><p><a href="https://github.com/tanabee/genkit-google-search-sample">GitHub - tanabee/genkit-google-search-sample</a></p><h3>References</h3><ul><li><a href="https://github.com/firebase/genkit/releases/tag/0.5.9">Release Genkit JS 0.5.9 · firebase/genkit</a></li><li><a href="https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview">Grounding overview | Generative AI on Vertex AI | Google Cloud</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fembed%2FTjxJnQQCS_A%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fwatch%3Fv%3DTjxJnQQCS_A&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.ytimg.com%2Fvi%2FTjxJnQQCS_A%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/79db4375c95e6f10cf4f8ddbf78c15e2/href">https://medium.com/media/79db4375c95e6f10cf4f8ddbf78c15e2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f142f5c9693" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/high-precision-responses-with-genkits-google-search-integration-7f142f5c9693">High-Precision Responses with Genkit’s Google Search Integration</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>