Feat/video anaylsis - #1082
Conversation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
… and `streamText`; remove redundant `generateWithSystemInstruction` helper function; enable system instruction input when streaming is enabled in `TextGenerationView`; renamed component to `TextGenerationView` for consistency
… Remove redundant isolated feature switch and unused component imports from `App.tsx`; ensure `automatic-function-calling` is handled in `index.tsx`; keep `App.tsx` strictly focused on layout shell and navigation
| {previewUrl && ( | ||
| <div style={{ marginBottom: '16px', borderRadius: '8px', overflow: 'hidden', border: '1px solid #dadce0', backgroundColor: '#000' }}> | ||
| <video | ||
| src={previewUrl} |
There was a problem hiding this comment.
Code Review
This pull request introduces a new Video Analysis feature, refactors the Text Generation feature to support system instructions and streaming, and cleans up the Chat feature. Feedback on these changes includes adding the new Video Analysis feature to the sidebar navigation and registering it in the router, fixing a typo in the folder name (video-anaylsis), correcting an inconsistent model name (gemini-3.7-flash vs gemini-3.5-flash), and implementing client-side file size validation to prevent performance issues when uploading large videos.
| { path: '/image-generation', label: 'Image Generation' }, | ||
|
|
||
| ]; |
There was a problem hiding this comment.
The new Video Analysis feature is missing from the sidebar navigation items. Add it to NAV_ITEMS so users can navigate to it.
| { path: '/image-generation', label: 'Image Generation' }, | |
| ]; | |
| { path: '/image-generation', label: 'Image Generation' }, | |
| { path: '/video-analysis', label: 'Video Analysis' }, | |
| ]; |
| element: <App />, | ||
| children: [ | ||
| // Redirect the root path to text-generation automatically | ||
| { index: true, element: <Navigate to="/text-generation" replace /> }, |
There was a problem hiding this comment.
The new VideoAnalysis feature is not registered in the router. To make it accessible, please:
- Import
VideoAnalysisfrom./features/video-analysisat the top of the file. - Add the route
{ path: 'video-analysis', element: <VideoAnalysis /> }to the router children. - Add
case 'video-analysis': return <VideoAnalysis />;to therenderContentswitch-case for isolated features.
| ): Promise<void> { | ||
| try { | ||
| const videoPart = await fileToGenerativePart(videoFile); | ||
| const model = getAiModel('gemini-3.7-flash'); |
There was a problem hiding this comment.
Inconsistent model name used here (gemini-3.7-flash). Everywhere else in the codebase (including analyzeVideo in this file and text-generation/service.ts), gemini-3.5-flash is used. Please update this to maintain consistency and ensure the correct model is called.
| const model = getAiModel('gemini-3.7-flash'); | |
| const model = getAiModel('gemini-3.5-flash'); |
| @@ -0,0 +1,237 @@ | |||
| import React, { useState, useRef, useEffect } from 'react'; | |||
| import { analyzeVideo, streamVideoAnalysis } from './service'; | |||
| const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const file = e.target.files?.[0] || null; | ||
| setSelectedFile(file); | ||
| setError(null); | ||
| }; |
There was a problem hiding this comment.
Since the UI notes that inline payloads are recommended to be under 20MB, it is highly recommended to enforce this limit on the client side. Reading extremely large video files into memory as Base64 can crash the browser tab or cause severe performance issues.
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0] || null;
if (file && file.size > 20 * 1024 * 1024) {
setError('File size exceeds the 20MB limit for inline payloads.');
setSelectedFile(null);
if (fileInputRef.current) {
fileInputRef.current.value = '';
}
return;
}
setSelectedFile(file);
setError(null);
};
Feature sample for analyzing videos: https://firebase.google.com/docs/ai-logic/analyze-video?api=dev