View source: R/gemini_structured.R
gemini_structured | R Documentation |
Returns a structured (JSON) response from the Gemini API.
gemini_structured(
prompt,
schema,
model = "2.5-flash",
temperature = 1,
maxOutputTokens = 8192,
topK = 40,
topP = 0.95,
seed = 1234,
timeout = 60
)
prompt |
The prompt (question) to send to the model. |
schema |
JSON schema (as a list) for the expected response. |
model |
Model to use. Default is '2.5-flash'. |
temperature |
Sampling temperature. Default is 1. |
maxOutputTokens |
Maximum number of output tokens. Default is 8192. |
topK |
Top-k value. Default is 40. |
topP |
Top-p value. Default is 0.95. |
seed |
Random seed. Default is 1234. |
timeout |
Request timeout in seconds. Default is 60. |
A structured list (parsed JSON).
## Not run:
schema <- list(
type = "ARRAY",
items = list(
type = "OBJECT",
properties = list(
recipeName = list(type = "STRING"),
ingredients = list(
type = "ARRAY",
items = list(type = "STRING")
)
),
propertyOrdering = c("recipeName", "ingredients")
)
)
gemini_structured(
"List a few popular cookie recipes, and include the amounts of ingredients.",
schema
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.