diff --git a/ai/ai-samples/README.md b/ai/ai-samples/README.md index 4c8de7b80..8581edd4e 100644 --- a/ai/ai-samples/README.md +++ b/ai/ai-samples/README.md @@ -12,7 +12,9 @@ This repository demonstrates the following capabilities: * Multimodal * Structured Output * Function Calling +* Automatic Function Calling * Image Generation +* Grounding with Google Search ## Setup & Configuration @@ -21,6 +23,7 @@ To connect this sample app to your Firebase project, register a new Web App in y 1. Navigate to this directory and install dependencies: ```bash npm install + ``` 2. Add your Firebase config @@ -31,34 +34,38 @@ Copy the example config file and fill in your project values. Open src/config/fi 3. Running the samples For a full app experience to browse all features: - npm run dev +```bash +npm run dev +``` -To run indivual features in isolated mode, run the single feature directly without the app shell using one of these scripts: +To run individual features in isolated mode, run the single feature directly without the app shell using one of these scripts: -npm run dev:text #Text Generation -npm run dev:chat #Chat -npm run dev:multimodal #Multimodal -npm run dev:structured #Structured Output -npm run dev:function #Function Calling -npm run dev:image #Image Generation +```bash +npm run dev:text # Text Generation +npm run dev:chat # Chat +npm run dev:multimodal # Multimodal +npm run dev:structured # Structured Output +npm run dev:function # Function Calling +npm run dev:auto-function # Automatic Function Calling +npm run dev:image # Image Generation +npm run dev:grounding # Grounding with Google Search +``` -After running any of the above commands, open your browser to https://localhost:*** (provided in the console) +After running any of the above commands, open your browser to http://localhost:*** (provided in the console) ## Copy service.ts for platform agnostic use All AI logic is decoupled from the React UI. If you want to use these features in your own project, navigate to any src/features/*/service.ts file. These files are framework-agnostic and can be safely copy-pasted into any JavaScript or TypeScript web project. - - ## App Check -App check protects your API Key from unauthorized use. It is not required to run the samples locally but highly recommended before deployig to production. +App check protects your API Key from unauthorized use. It is not required to run the samples locally but highly recommended before deploying to production. Debug token: -firebaseAIService.ts includes App Check intilization for local development. To enable it: +firebaseAIService.ts includes App Check initialization for local development. To enable it: 1. Set VITE_APPCHECK_DEBUG_TOKEN=true in your .env.local file -2. On the first run, a deug token will be printed in the browser console. +2. On the first run, a debug token will be printed in the browser console. 3. Copy that token and register it in the Firebase Console under App Check -> Apps -> your apps -> Debug Token @@ -69,4 +76,4 @@ For production, use reCAPTCHA v3 as the App Check provider: 2. Choose reCaptcha v3 and follow the setup steps 3. Add your reCaptcha site key to firebase-config.ts -See the [App Check Docs](https://firebase.google.com/docs/app-check/web/recaptcha-provider) for full instruction. \ No newline at end of file +See the [App Check Docs](https://firebase.google.com/docs/app-check/web/recaptcha-provider) for full instructions. \ No newline at end of file diff --git a/ai/ai-samples/package.json b/ai/ai-samples/package.json index 02d4dd092..ced618a05 100644 --- a/ai/ai-samples/package.json +++ b/ai/ai-samples/package.json @@ -12,6 +12,7 @@ "dev:function": "VITE_ISOLATED_FEATURE=function-calling vite", "dev:auto-function": "VITE_ISOLATED_FEATURE=automatic-function-calling vite", "dev:image": "VITE_ISOLATED_FEATURE=image-generation vite", + "dev:grounding": "VITE_ISOLATED_FEATURE=grounding-with-google-search vite", "build": "tsc -b && vite build", "lint": "eslint .", "preview": "vite preview" diff --git a/ai/ai-samples/src/App.tsx b/ai/ai-samples/src/App.tsx index a3b802829..c1cd0f160 100644 --- a/ai/ai-samples/src/App.tsx +++ b/ai/ai-samples/src/App.tsx @@ -8,13 +8,12 @@ const NAV_ITEMS = [ { path: '/function-calling', label: 'Function Calling' }, { path: '/automatic-function-calling', label: 'Automatic Function Calling' }, { path: '/image-generation', label: 'Image Generation' }, - + { path: '/grounding-with-google-search', label: 'Grounding with Google Search' }, ]; export default function App() { const { pathname } = useLocation(); - return (