From 489bbb7b3458d6fd8ba23f7161a3ef9bbf525a3b Mon Sep 17 00:00:00 2001 From: sedanah-m Date: Mon, 22 Jun 2026 11:36:49 -0700 Subject: [PATCH 1/5] feat: add text-generation and chat isolated samples --- ai/ai-samples/src/App.tsx | 42 +++++++++++++-- .../src/features/text-generation/index.tsx | 43 +++++++++++++++ ai/ai-samples/src/index.tsx | 53 ++++++++++++++++--- 3 files changed, 127 insertions(+), 11 deletions(-) diff --git a/ai/ai-samples/src/App.tsx b/ai/ai-samples/src/App.tsx index c9b04bf56..1e7f1eedb 100644 --- a/ai/ai-samples/src/App.tsx +++ b/ai/ai-samples/src/App.tsx @@ -1,10 +1,42 @@ -import React from 'react' +import {Link, Outlet, useLocation} from 'react-router-dom'; +import './app.css'; + + +const NAV_ITEMS = [ +{path: '/text-generation', label: 'Text Generation'}, +{path: '/chat', label: 'Chat'}, +{path: '/multimodal', label: 'Multimodal'}, +{path: '/structured-output', label: 'Structured Output'}, +{path: '/function-calling', label: 'Function Calling'}, +{path: '/image-generation', label: 'Image Generation'}, +]; export default function App() { + const {pathname} = useLocation(); + return ( -
-

Firebase AI Samples

-

Modular Firebase AI capabilities.

+
+ +
+ +
- ) + ); } + + + diff --git a/ai/ai-samples/src/features/text-generation/index.tsx b/ai/ai-samples/src/features/text-generation/index.tsx index 34ab0187c..e859e0b96 100644 --- a/ai/ai-samples/src/features/text-generation/index.tsx +++ b/ai/ai-samples/src/features/text-generation/index.tsx @@ -1,9 +1,52 @@ import React from 'react'; +import React, { useState } from 'react'; +import { generateText } from './service'; export default function Feature() { +export default function TextGeneration() { + const [prompt, setPrompt] = useState(''); + const [response, setResponse] = useState(''); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + + const handleGenerate = async () => { + if (!prompt.trim()) return; + + setLoading(true); + setError(null); + setResponse(''); + + try { + // Direct call to the decoupled logic service + const text = await generateText(prompt); + setResponse(text); + } catch (err: any) { + setError(err.message || 'An unexpected error occurred'); + } finally { + setLoading(false); + } + }; + return (

text-generation

+
+

Text Generation

+ +