submitToolOutputsToRun method
Future<GptRun>
submitToolOutputsToRun({
- required String apiKey,
- required String organizationId,
- required String threadId,
- required String runId,
- required SubmitToolsOutputsRequest request,
When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
Implementation
Future<GptRun> submitToolOutputsToRun({
required String apiKey,
required String organizationId,
required String threadId,
required String runId,
required SubmitToolsOutputsRequest request,
}) async {
Map<String, String> headers = {
"Authorization": "Bearer $apiKey",
"OpenAI-Organization": organizationId,
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*", // Required for CORS support to work
"OpenAI-Beta": "assistants=v1"
};
Uri endpoint;
if(secure) {
endpoint = Uri.https(
baseUrl, "/v1/threads/$threadId/runs/$runId/submit_tool_outputs");
}
else {
endpoint = Uri.http(
baseUrl, "/v1/threads/$threadId/runs/$runId/submit_tool_outputs");
}
var response = await
http.post(endpoint, headers: headers, body:jsonEncode(request.toJson()));
if (response.statusCode == 200 || response.statusCode == 201) {
return GptRun.fromJson(jsonDecode(const Utf8Decoder().convert(response.bodyBytes)));
}
else {
var error = ServerError.fromJson(jsonDecode(response.body));
throw RunsException(statusCode: response.statusCode, message: error.message);
}
}