micah
08/05/2025, 2:52 PMval promptExecutor = simpleGoogleAIExecutor(geminiApiKey)
val exampleStructure =
JsonStructuredData.createJsonStructure<Example>(
schemaFormat = JsonSchemaGenerator.SchemaFormat.JsonSchema,
schemaType = JsonStructuredData.JsonSchemaType.FULL,
)
val structuredResponse =
promptExecutor.executeStructured(
prompt =
prompt("example") {
system(SystemPrompts.EXAMPLE_SYSTEM_PROMPT)
user {
text("Please extract information from the provided document.")
attachments {
Attachment.File(
content = AttachmentContent.Binary.Bytes(document),
format = "pdf",
mimeType = "application/pdf",
)
}
}
},
structure = exampleStructure,
mainModel = GoogleModels.Gemini2_5Flash,
retries = 5,
)
Didier Villevalois
08/05/2025, 3:06 PMprompt("example") {
system(SystemPrompts.EXAMPLE_SYSTEM_PROMPT)
user {
text("Please extract information from the provided document.")
attachments {
attachment(
Attachment.File(
content = AttachmentContent.Binary.Bytes(document),
format = "pdf",
mimeType = "application/pdf",
)
)
}
}
}
micah
08/05/2025, 3:22 PMbinaryFile
function awhile ago, and in that case (and as I've updated the code now), the framework is throwing from here:
require(model.capabilities.contains(LLMCapability.Document)) {
"Model ${model.id} does not support documents"
}
micah
08/05/2025, 3:22 PMAndrey Bragin
08/05/2025, 3:39 PMLLModel
, you can create and pass your own model based on the built-in one. Either copy-pasting the source and adjusting parameters as you need, or using .copy
if you don’t want to redefine all the parameters. In your case, it might look something like this
val MyGemini2_5Flash = with(Gemini2_5Flash) {
copy(
capabilities = capabilities + LLMCapability.Document
)
}
Didier Villevalois
08/05/2025, 3:39 PM.copy
the model and add the appropriate capability.micah
08/05/2025, 3:46 PMEduardo Ruesta
08/06/2025, 7:19 PMmicah
08/06/2025, 7:20 PMval MyGemini2_5Flash = with(Gemini2_5Flash) {
copy(
capabilities = capabilities + LLMCapability.Document
)
}
micah
08/06/2025, 7:20 PMmainModel = MyGemini2_5Flash
micah
08/06/2025, 7:22 PMEduardo Ruesta
08/06/2025, 7:26 PM