-
Notifications
You must be signed in to change notification settings - Fork 4
VER-278: Use Gemini 2.5 Flash Latest as fallback model in Stage 3 #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| from datetime import datetime, timezone | ||
| from datetime import datetime | ||
| from http import HTTPStatus | ||
| import os | ||
| import time | ||
| from google import genai | ||
| from google.genai import errors | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| import json | ||
| import boto3 | ||
| from pydantic import ValidationError | ||
|
|
@@ -140,16 +142,52 @@ def __get_metadata(snippet): | |
|
|
||
|
|
||
| @optional_task(log_prints=True) | ||
| def process_snippet(supabase_client, snippet, local_file, gemini_key, skip_review: bool): | ||
| def analyze_snippet(gemini_key, audio_file, metadata): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| main_model = GeminiModel.GEMINI_2_5_PRO | ||
| fallback_model = GeminiModel.GEMINI_FLASH_LATEST | ||
|
Comment on lines
+146
to
+147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the fallback model matches the PR objective. The PR title specifies "Gemini 2.5 Flash Latest" as the fallback model, but the code uses 🌐 Web query: 💡 Result: Short answer: gemini-flash-latest is an alias that always points to the most recent "flash" release (it can be stable, preview or experimental and may be hot‑swapped), whereas gemini-2.5-flash is the specific stable Gemini 2.5 Flash model (a fixed release with documented capabilities and limits). [1][2] Details (concise):
Sources: Clarify fallback model intent—consider using the stable model for production consistency. The PR title states "Gemini 2.5 Flash Latest," but the code uses If your intent is to use Gemini 2.5 Flash specifically (as the PR title suggests), consider using 🤖 Prompt for AI Agents |
||
|
|
||
| try: | ||
| print(f"Processing snippet: {local_file} with Gemini 2.5 Flash") | ||
| print(f"Attempting analysis with {main_model}") | ||
| return Stage3Executor.run( | ||
| gemini_key=gemini_key, | ||
| model_name=main_model, | ||
| audio_file=audio_file, | ||
| metadata=metadata, | ||
| ) | ||
| except errors.ServerError as e: | ||
| print(f"Server error with {main_model} (code {e.code}): {e.message}") | ||
| print(f"Falling back to {fallback_model}") | ||
| return Stage3Executor.run( | ||
| gemini_key=gemini_key, | ||
| model_name=fallback_model, | ||
| audio_file=audio_file, | ||
| metadata=metadata, | ||
| ) | ||
|
Comment on lines
+157
to
+165
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| except errors.ClientError as e: | ||
| if e.code in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN]: | ||
| print(f"Auth error with {main_model} (code {e.code}): {e.message}") | ||
| raise | ||
| else: | ||
| print(f"Client error with {main_model} (code {e.code}): {e.message}") | ||
| print(f"Falling back to {fallback_model}") | ||
| return Stage3Executor.run( | ||
| gemini_key=gemini_key, | ||
| model_name=fallback_model, | ||
| audio_file=audio_file, | ||
| metadata=metadata, | ||
| ) | ||
|
Comment on lines
+166
to
+178
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
|
|
||
| @optional_task(log_prints=True) | ||
| def process_snippet(supabase_client, snippet, local_file, gemini_key, skip_review: bool): | ||
| print(f"Processing snippet: {local_file}") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| try: | ||
| metadata = get_metadata(snippet) | ||
| print(f"Metadata:\n{json.dumps(metadata, indent=2, ensure_ascii=False)}") | ||
|
|
||
| response, grounding_metadata = Stage3Executor.run( | ||
| response, grounding_metadata = analyze_snippet( | ||
| gemini_key=gemini_key, | ||
| model_name=GeminiModel.GEMINI_2_5_PRO, | ||
| audio_file=local_file, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use consistent naming for the audio file parameter ( |
||
| metadata=metadata, | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing
HTTPStatusis a good addition for handling specific HTTP error codes, which enhances the clarity and maintainability of the error handling logic.