Skip to content

Commit 5ccacad

Browse files
msampathkumarholtskinnerSita04
authored
feat(genai): Add http_params to Text Generation doc samples (#13138)
* feat(genai): Add Tool examples * Code execution example * Function Calling example * Grounding with Google Search example * fix(genai): Linter suggestion * feat(genai): Add region tags * feat(genai): Update http flag for TextGeneration samples. * Update genai/text_generation/requirements.txt Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com> * Update pillow package version * Fixing bug from merge conflict * update package version --------- Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com> Co-authored-by: Sita Lakshmi Sangameswaran <sitalakshmi@google.com>
1 parent 3c53ed3 commit 5ccacad

15 files changed

+34
-41
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
pandas==1.3.5; python_version == '3.7'
2-
pandas==2.0.3; python_version == '3.8'
3-
pandas==2.1.4; python_version > '3.8'
4-
pillow==10.3.0; python_version < '3.8'
5-
pillow==10.3.0; python_version >= '3.8'
6-
google-cloud-aiplatform[all]==1.69.0
7-
sentencepiece==0.2.0
8-
google-auth==2.38.0
9-
anthropic[vertex]==0.28.0
10-
langchain-core==0.2.33
11-
langchain-google-vertexai==1.0.10
12-
numpy<2
13-
openai==1.30.5
14-
immutabledict==4.2.0
1+
# pandas==1.3.5; python_version == '3.7'
2+
# pandas==2.0.3; python_version == '3.8'
3+
# pandas==2.1.4; python_version > '3.8'
4+
# pillow==10.3.0; python_version < '3.8'
5+
# pillow==10.3.0; python_version >= '3.8'
6+
# google-cloud-aiplatform[all]==1.69.0
7+
# sentencepiece==0.2.0
8+
# google-auth==2.29.0
9+
# anthropic[vertex]==0.28.0
10+
# langchain-core==0.2.33
11+
# langchain-google-vertexai==1.0.10
12+
# numpy<2
13+
# openai==1.30.5
14+
# immutabledict==4.2.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-genai==0.8.0
1+
google-genai==1.0.0

genai/text_generation/textgen_chat_stream_with_txt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def generate_content() -> str:
1717
# [START googlegenaisdk_textgen_chat_stream_with_txt]
1818
from google import genai
1919

20-
client = genai.Client()
20+
client = genai.Client(http_options={'api_version': 'v1'})
2121
chat = client.chats.create(model="gemini-2.0-flash-001")
2222
response_text = ""
2323

genai/text_generation/textgen_chat_with_txt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def generate_content() -> str:
1818
from google import genai
1919
from google.genai.types import Content, Part
2020

21-
client = genai.Client()
21+
client = genai.Client(http_options={'api_version': 'v1'})
2222
chat = client.chats.create(
2323
model="gemini-2.0-flash-001",
2424
history=[

genai/text_generation/textgen_config_with_txt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def generate_content() -> str:
1818
from google import genai
1919
from google.genai import types
2020

21-
client = genai.Client()
21+
client = genai.Client(http_options={'api_version': 'v1'})
2222
response = client.models.generate_content(
2323
model="gemini-2.0-flash-001",
2424
contents="Why is the sky blue?",

genai/text_generation/textgen_sys_instr_with_txt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def generate_content() -> str:
1818
from google import genai
1919
from google.genai import types
2020

21-
client = genai.Client()
21+
client = genai.Client(http_options={'api_version': 'v1'})
2222
response = client.models.generate_content(
2323
model="gemini-2.0-flash-001",
2424
contents="Why is the sky blue?",

genai/text_generation/textgen_transcript_with_gcs_audio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def generate_content() -> str:
1818
from google import genai
1919
from google.genai.types import Part
2020

21-
client = genai.Client()
22-
21+
client = genai.Client(http_options={'api_version': 'v1'})
2322
prompt = """
2423
Transcribe the interview, in the format of timecode, speaker, caption.
2524
Use speaker A, speaker B, etc. to identify speakers.

genai/text_generation/textgen_with_gcs_audio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def generate_content() -> str:
1818
from google import genai
1919
from google.genai.types import Part
2020

21-
client = genai.Client()
22-
21+
client = genai.Client(http_options={'api_version': 'v1'})
2322
prompt = """
2423
Provide the summary of the audio file.
2524
Summarize the main points of the audio concisely.

genai/text_generation/textgen_with_multi_img.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def generate_content() -> str:
1818
from google import genai
1919
from google.genai.types import Part
2020

21-
client = genai.Client()
21+
client = genai.Client(http_options={'api_version': 'v1'})
2222

2323
# Read content from GCS
2424
gcs_file_img_path = "gs://cloud-samples-data/generative-ai/image/scones.jpg"
@@ -30,21 +30,20 @@ def generate_content() -> str:
3030
response = client.models.generate_content(
3131
model="gemini-2.0-flash-001",
3232
contents=[
33-
"Write an advertising jingle based on the items in both images.",
33+
"Generate a list of all the objects contained in both images.",
3434
Part.from_uri(
3535
file_uri=gcs_file_img_path,
36-
mime_type="image/jpeg",
36+
mime_type="image/jpeg"
3737
),
3838
Part.from_bytes(
3939
data=local_file_img_bytes,
40-
mime_type="image/jpeg",
41-
),
42-
],
40+
mime_type="image/jpeg"
41+
)
42+
]
4343
)
4444
print(response.text)
4545
# Example response:
46-
# Okay, here's an advertising jingle based on the blueberry scones, coffee, and
47-
# flowers from the first image, and the cake and latte in the second image:
46+
# Okay, here's the list of objects present in both images:
4847
# ...
4948
# [END googlegenaisdk_textgen_with_multi_img]
5049
return response.text

genai/text_generation/textgen_with_multi_local_img.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def generate_content(image_path_1: str, image_path_2: str) -> str:
1818
from google import genai
1919
from google.genai.types import Part
2020

21-
client = genai.Client()
22-
21+
client = genai.Client(http_options={'api_version': 'v1'})
2322
# TODO(Developer): Update the below file paths to your images
2423
# image_path_1 = "path/to/your/image1.jpg"
2524
# image_path_2 = "path/to/your/image2.jpg"

0 commit comments

Comments
 (0)