Skip to content

Commit 7a299c4

Browse files
yan283holtskinner
andauthored
Add sample code for model_selection_config (#13325)
* chore: update google-genai to new version * feat: add sample code to set model_selection_config * Update genai/text_generation/requirements.txt --------- Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
1 parent e065437 commit 7a299c4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

genai/text_generation/model_optimizer_textgen_with_txt.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@
1616
def generate_content() -> str:
1717
# [START googlegenaisdk_model_optimizer_textgen_with_txt]
1818
from google import genai
19-
from google.genai.types import HttpOptions
19+
from google.genai.types import (
20+
FeatureSelectionPreference,
21+
GenerateContentConfig,
22+
HttpOptions,
23+
ModelSelectionConfig
24+
)
2025

21-
client = genai.Client(http_options=HttpOptions(api_version="v1"))
26+
client = genai.Client(http_options=HttpOptions(api_version="v1beta1"))
2227
response = client.models.generate_content(
2328
model="model-optimizer-exp-04-09",
2429
contents="How does AI work?",
30+
config=GenerateContentConfig(
31+
model_selection_config=ModelSelectionConfig(
32+
feature_selection_preference=FeatureSelectionPreference.BALANCED # Options: PRIORITIZE_QUALITY, BALANCED, PRIORITIZE_COST
33+
),
34+
),
2535
)
2636
print(response.text)
2737
# Example response:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-genai==1.7.0
1+
google-genai==1.12.1

0 commit comments

Comments
 (0)