Slide 23
Slide 23 text
Structured Output
● 構造化された JSON で返り値を制約
● State Control 上の IF となる
● Gemini-2.0 Flash / Pro ともに対応
23
async def parse(
prompt: str,
response_format: BaseModel,
*,
instruction: str | None = None,
model: str = "gemini-2.0-flash",
) -> GenerateContentResponse:
client = genai.Client(
vertexai=True, project="aitech-example-project", location="us-central1"
)
resp = await client.aio.models.generate_content(
model="gemini-2.0-flash",
contents=prompt,
config=GenerateContentConfig(
system_instruction=[instruction],
response_mime_type="application/json",
response_schema=response_format,
),
)
return resp
tools=[google_search_tool]
Google 検索によるグラウンディング