makeTemplateRequest<T> method
Future<T>
makeTemplateRequest<T>(
- TemplateTask task,
- String templateId,
- Map<
String, Object?> ? inputs, - Iterable<
Content> ? history, - List<
TemplateTool> ? tools, - TemplateToolConfig? toolConfig,
- T parse(),
inherited
Makes a unary request to a template-based API.
This method sends a request to the API with the given task, templateId,
and inputs. It returns a Future that completes with the parsed
response.
Implementation
Future<T> makeTemplateRequest<T>(
TemplateTask task,
String templateId,
Map<String, Object?>? inputs,
Iterable<Content>? history,
List<TemplateTool>? tools,
TemplateToolConfig? toolConfig,
T Function(Map<String, Object?>) parse) {
Map<String, Object?> body = {};
if (inputs != null) {
body['inputs'] = _serializeTemplateInputs(inputs);
}
if (history != null) {
body['history'] = history.map((c) => c.toJson()).toList();
}
if (tools != null) {
body['tools'] = tools.map((t) => t.toJson()).toList();
}
if (toolConfig != null) {
body['toolConfig'] = toolConfig.toJson();
}
return _client
.makeRequest(templateTaskUri(task, templateId), body)
.then(parse);
}