Skip to content

Commit 7279dab

Browse files
yyyu-googlecopybara-github
authored andcommitted
feat: GenAI - Added response_style to GenerationConfig
PiperOrigin-RevId: 630462525
1 parent 3c3727b commit 7279dab

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

google/cloud/aiplatform_v1beta1/types/content.py

+27
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,30 @@ class GenerationConfig(proto.Message):
309309
The model needs to be prompted to output the appropriate
310310
response type, otherwise the behavior is undefined. This
311311
is a preview feature.
312+
313+
response_style (google.cloud.aiplatform_v1beta1.types.GenerationConfig.ResponseStyle):
314+
Control Three levels of creativity in the model output.
315+
Default: RESPONSE_STYLE_BALANCED
312316
"""
313317

318+
class ResponseStyle(proto.Enum):
319+
r"""Choices of the response style.
320+
321+
Values:
322+
RESPONSE_STYLE_UNSPECIFIED (0):
323+
response style unspecified.
324+
RESPONSE_STYLE_PRECISE (1):
325+
Precise response.
326+
RESPONSE_STYLE_BALANCED (2):
327+
Default response style.
328+
RESPONSE_STYLE_CREATIVE (3):
329+
Creative response style.
330+
"""
331+
RESPONSE_STYLE_UNSPECIFIED = 0
332+
RESPONSE_STYLE_PRECISE = 1
333+
RESPONSE_STYLE_BALANCED = 2
334+
RESPONSE_STYLE_CREATIVE = 3
335+
314336
temperature: float = proto.Field(
315337
proto.FLOAT,
316338
number=1,
@@ -354,6 +376,11 @@ class GenerationConfig(proto.Message):
354376
proto.STRING,
355377
number=13,
356378
)
379+
response_style: ResponseStyle = proto.Field(
380+
proto.ENUM,
381+
number=14,
382+
enum=ResponseStyle,
383+
)
357384

358385

359386
class SafetySetting(proto.Message):

vertexai/generative_models/_generative_models.py

+5
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ class ResponseValidationError(ResponseBlockedError):
11811181

11821182
class GenerationConfig:
11831183
"""Parameters for the generation."""
1184+
ResponseStyle = gapic_content_types.GenerationConfig.ResponseStyle
11841185

11851186
def __init__(
11861187
self,
@@ -1194,6 +1195,7 @@ def __init__(
11941195
presence_penalty: Optional[float] = None,
11951196
frequency_penalty: Optional[float] = None,
11961197
response_mime_type: Optional[str] = None,
1198+
response_style: Optional["GenerationConfig.ResponseStyle"] = None,
11971199
):
11981200
r"""Constructs a GenerationConfig object.
11991201
@@ -1216,6 +1218,7 @@ def __init__(
12161218
12171219
The model needs to be prompted to output the appropriate
12181220
response type, otherwise the behavior is undefined.
1221+
response_style: Control three levels of creativity in the model output.
12191222
12201223
Usage:
12211224
```
@@ -1228,6 +1231,7 @@ def __init__(
12281231
candidate_count=1,
12291232
max_output_tokens=100,
12301233
stop_sequences=["\n\n\n"],
1234+
response_style=ResponseStyle.RESPONSE_STYLE_PRECISE,
12311235
)
12321236
)
12331237
```
@@ -1242,6 +1246,7 @@ def __init__(
12421246
presence_penalty=presence_penalty,
12431247
frequency_penalty=frequency_penalty,
12441248
response_mime_type=response_mime_type,
1249+
response_style=response_style,
12451250
)
12461251

12471252
@classmethod

0 commit comments

Comments
 (0)