Skip to content

Commit e96b6e6

Browse files
matthew29tangcopybara-github
authored andcommitted
docs: Update Prompt docstring for batch prompting
PiperOrigin-RevId: 665033032
1 parent 7f1e031 commit e96b6e6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

vertexai/generative_models/_prompts.py

+31
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,37 @@ class Prompt:
9191
contents=prompt.assemble_contents(**prompt.variables)
9292
)
9393
```
94+
Generate content with multiple sets of variables:
95+
```
96+
prompt = Prompt(
97+
prompt_data="Hello, {name}! Today is {day}. How are you?",
98+
variables=[
99+
{"name": "Alice", "day": "Monday"},
100+
{"name": "Bob", "day": "Tuesday"},
101+
],
102+
generation_config=GenerationConfig(
103+
temperature=0.1,
104+
top_p=0.95,
105+
top_k=20,
106+
candidate_count=1,
107+
max_output_tokens=100,
108+
stop_sequences=["\n\n\n"],
109+
),
110+
model_name="gemini-1.0-pro-002",
111+
safety_settings=[SafetySetting(
112+
category=SafetySetting.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
113+
threshold=SafetySetting.HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
114+
method=SafetySetting.HarmBlockMethod.SEVERITY,
115+
)],
116+
system_instruction="Please answer in a short sentence.",
117+
)
118+
119+
# Generate content using the assembled prompt for each variable set.
120+
for i in range(len(prompt.variables)):
121+
prompt.generate_content(
122+
contents=prompt.assemble_contents(**prompt.variables[i])
123+
)
124+
```
94125
"""
95126

96127
def __init__(

0 commit comments

Comments
 (0)