File tree 1 file changed +31
-0
lines changed
vertexai/generative_models
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,37 @@ class Prompt:
91
91
contents=prompt.assemble_contents(**prompt.variables)
92
92
)
93
93
```
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
+ ```
94
125
"""
95
126
96
127
def __init__ (
You can’t perform that action at this time.
0 commit comments