Skip to content
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

feat(generative-ai): Update Gemini Flask and Pro model names #12627

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generative_ai/batch_predict/gemini_batch_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def batch_predict_gemini_createjob(

# Submit a batch prediction job with Gemini model
batch_prediction_job = BatchPredictionJob.submit(
source_model="gemini-1.5-flash-001",
source_model="gemini-1.5-flash-002",
msampathkumar marked this conversation as resolved.
Show resolved Hide resolved
input_dataset=input_uri,
output_uri_prefix=output_uri,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
messages.append({"role": "user", "content": "What is the weather in Boston?"})

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=messages,
tools=tools,
tool_choice="auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=[
{
"role": "user",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=[
{
"role": "user",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
stream=True,
)
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/context_caching/create_context_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create_context_cache() -> str:
]

cached_content = caching.CachedContent.create(
model_name="gemini-1.5-pro-001",
model_name="gemini-1.5-pro-002",
system_instruction=system_instruction,
contents=contents,
ttl=datetime.timedelta(minutes=60),
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/controlled_generation/example_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generate_content() -> str:
},
}

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
"List a few popular cookie recipes",
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/controlled_generation/example_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def generate_content() -> str:
- "Quite good, but a bit too sweet for my taste." Rating: 1, Flavor: Mango Tango
"""

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
prompt,
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/controlled_generation/example_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def generate_content() -> str:
Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F, and a humidity level of 40%. Winds will be gentle at 8 km/h.
"""

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
prompt,
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/controlled_generation/example_04.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def generate_content() -> str:
It has large questionable stains on it.
"""

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
prompt,
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/controlled_generation/example_05.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_content() -> str:
# PROJECT_ID = "your-project-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = """
List a few popular cookie recipes using this JSON schema:
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/controlled_generation/example_06.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generate_content() -> str:
},
}

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate_content(project_id: str) -> str:
# project_id = "PROJECT_ID"
vertexai.init(project=project_id, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = """
List a few popular cookie recipes using this JSON schema:
Expand Down
10 changes: 5 additions & 5 deletions generative_ai/controlled_generation/response_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def generate_content(project_id: str) -> str:
},
}

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
"List a few popular cookie recipes",
Expand Down Expand Up @@ -84,7 +84,7 @@ def generate_content2(project_id: str) -> str:
- "Quite good, but a bit too sweet for my taste." Rating: 1, Flavor: Mango Tango
"""

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
prompt,
Expand Down Expand Up @@ -142,7 +142,7 @@ def generate_content3(project_id: str) -> str:
Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F, and a humidity level of 40%. Winds will be gentle at 8 km/h.
"""

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
prompt,
Expand Down Expand Up @@ -218,7 +218,7 @@ def generate_content4(project_id: str) -> str:
It has large questionable stains on it.
"""

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
prompt,
Expand Down Expand Up @@ -257,7 +257,7 @@ def generate_content6(project_id: str) -> str:
},
}

model = GenerativeModel("gemini-1.5-pro-001")
model = GenerativeModel("gemini-1.5-pro-002")

response = model.generate_content(
[
Expand Down
4 changes: 2 additions & 2 deletions generative_ai/function_calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def generate_function_call() -> GenerationResponse:
vertexai.init(project=PROJECT_ID, location="us-central1")

# Initialize Gemini model
model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

# Define the user's prompt in a Content object that we can reuse in model calls
user_prompt_content = Content(
Expand Down Expand Up @@ -168,7 +168,7 @@ def generate_function_call_advanced() -> GenerationResponse:
)

model = GenerativeModel(
model_name="gemini-1.5-flash-001",
model_name="gemini-1.5-flash-002",
tools=[retail_tool],
tool_config=retail_tool_config,
)
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/function_calling/advanced_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def generate_function_call_advanced() -> GenerationResponse:
)

model = GenerativeModel(
model_name="gemini-1.5-flash-001",
model_name="gemini-1.5-flash-002",
tools=[retail_tool],
tool_config=retail_tool_config,
)
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/function_calling/basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_function_call() -> GenerationResponse:
vertexai.init(project=PROJECT_ID, location="us-central1")

# Initialize Gemini model
model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

# Define the user's prompt in a Content object that we can reuse in model calls
user_prompt_content = Content(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def generate_text() -> object:
messages.append({"role": "user", "content": "What is the weather in Boston?"})

response = client.chat.completions.create(
model="google/gemini-1.5-flash-001",
model="google/gemini-1.5-flash-002",
messages=messages,
tools=tools,
tool_choice="auto",
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_all_modalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def analyze_all_modalities() -> str:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

video_file_uri = (
"gs://cloud-samples-data/generative-ai/video/behind_the_scenes_pixel.mp4"
Expand Down
4 changes: 2 additions & 2 deletions generative_ai/gemini_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def summarize_audio() -> str:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = """
Please provide a summary for the audio.
Expand Down Expand Up @@ -56,7 +56,7 @@ def transcript_audio() -> str:
# TODO (developer): update project & location
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = """
Can you transcribe this interview, in the format of timecode, speaker, caption.
Expand Down
4 changes: 2 additions & 2 deletions generative_ai/gemini_chat_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def chat_text_example() -> str:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

chat = model.start_chat()

Expand Down Expand Up @@ -56,7 +56,7 @@ def chat_stream_example() -> str:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

chat = model.start_chat()

Expand Down
4 changes: 2 additions & 2 deletions generative_ai/gemini_count_token_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def count_tokens() -> GenerationResponse:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = "Why is the sky blue?"
# Prompt tokens count
Expand Down Expand Up @@ -55,7 +55,7 @@ def count_tokens_multimodal() -> GenerationResponse:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

contents = [
Part.from_uri(
Expand Down
4 changes: 2 additions & 2 deletions generative_ai/gemini_grounding_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_text_with_grounding_web() -> GenerationResponse:
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

# Use Google Search for grounding
tool = Tool.from_google_search_retrieval(grounding.GoogleSearchRetrieval())
Expand Down Expand Up @@ -68,7 +68,7 @@ def generate_text_with_grounding_vertex_ai_search(
# TODO (developer): update project_id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

# TODO(developer): Update project id, location, and data store id for your Vertex AI Search data store.
# data_store_id = "DATA_STORE_ID"
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_guide_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_text() -> str:
# PROJECT_ID = "your-project-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

response = model.generate_content(
[
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_multi_image_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generate_text_multimodal() -> str:
mime_type="image/png",
)

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")
response = model.generate_content(
[
image_file1,
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_pdf_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def analyze_pdf() -> str:
# TODO(developer): Update project_id and location
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = """
You are a very professional document summarization specialist.
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_pro_basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def generate_text() -> None:
# TODO(developer): Update project_id and location
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

image_file = Part.from_uri(
"gs://cloud-samples-data/generative-ai/image/scones.jpg", "image/jpeg"
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_pro_config_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_text() -> None:
# TODO(developer): Update project_id and location
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

# Load example image from local storage
encoded_image = base64.b64encode(open("scones.jpg", "rb").read()).decode("utf-8")
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_safety_config_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_text() -> str:
# TODO(developer): Update project
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

# Safety config
safety_config = [
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_single_turn_video_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def generate_text() -> str:
# TODO(developer): Update project_id and location
vertexai.init(project=PROJECT_ID, location="us-central1")

vision_model = GenerativeModel("gemini-1.5-flash-001")
vision_model = GenerativeModel("gemini-1.5-flash-002")

# Generate text
response = vision_model.generate_content(
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_system_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def set_system_instruction(project_id: str) -> str:
vertexai.init(project=project_id, location="us-central1")

model = GenerativeModel(
model_name="gemini-1.5-flash-001",
model_name="gemini-1.5-flash-002",
system_instruction=[
"You are a helpful language translator.",
"Your mission is to translate text in English to French.",
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_text_input_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def generate_from_text_input() -> str:
# PROJECT_ID = "your-project-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

response = model.generate_content(
"What's a good name for a flower shop that specializes in selling bouquets of dried flowers?"
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/gemini_video_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def analyze_video_with_audio() -> str:
# PROJECT_ID = "your-project-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-001")
model = GenerativeModel("gemini-1.5-flash-002")

prompt = """
Provide a description of the video.
Expand Down
Loading