run method
Performs a standard non-streaming generation request.
This method waits for the entire AI response to be completed before returning.
It automatically validates tuulOptions and sets stream: false.
Returns an AppResponse which can be a SuccessResponse, ActionResponse, or ErrorResponse.
Implementation
Future<AppResponse<BundleRunResponse>> run({
required TuulOptions tuulOptions,
}) async {
tuulOptions.validate();
tuulOptions = tuulOptions.copyWith(
promptOptions: tuulOptions.promptOptions.copyWith(stream: false),
);
final response = await client.post<BundleRunResponse>(
"/generate",
headers: _headers(),
body: tuulOptions.toJson(),
dataParser: (json) => BundleRunResponse.fromJson(json),
);
switch (response) {
case SuccessResponse():
return response;
case ActionResponse():
return response;
case ErrorResponse(:final error):
throw TuulException(code: '400', message: error);
}
}