generateStructured static method
Future<StructuredOutputResult>
generateStructured({
- required String prompt,
- required JSONSchema schema,
- LLMGenerationOptions? options,
Generate structured output from a typed JSON schema.
Mirrors Swift RunAnywhere.generateStructured(prompt:schema:options:)
(RunAnywhere+StructuredOutput.swift:25-39): caller-supplied options
(maxTokens, temperature, topP, systemPrompt, …) are forwarded to the
underlying LLM through generateWithStructuredOutput; the resulting raw
text is then parsed via the commons extraction/validation path.
Implementation
static Future<StructuredOutputResult> generateStructured({
required String prompt,
required JSONSchema schema,
LLMGenerationOptions? options,
}) async {
if (!DartBridge.isInitialized) throw SDKException.notInitialized();
final generation = await generateWithStructuredOutput(
prompt: prompt,
structuredOutput: StructuredOutputOptionsDefaults.defaults(
schema: schema,
),
options: options,
);
return RunAnywhereLLM.shared.extractStructuredOutput(
text: generation.text,
schema: schema,
);
}