sa(IO::Async::Notifier) :strict(params) {
use JSON::MaybeXS qw//;
use Net::Async::HTTP;
use Feature::Compat::Try;
use URI;
field $_json = JSON::MaybeXS->new(utf8 => 1, convert_blessed => 1)
headers => {
"Authorization" => "Bearer $api_key",
"Content-Type" => "application/json",
$api_org_name ? (
'OpenAI-Organization' => $api_org_name,
) : ()
my $json = $_json->encode($data);
my $url = URI->new($api_base . $endpoint );
my $result = await $http->do_request(
uri => $url,
method => "POST",
content => $json,
n of specific formats of responses.
OpenAI supports two values, null and C<json_object> to force a correctly formatted JSON response. Needs additional documentation
for how to use this before I enab
:Role::AutoJSON;
use Object::Pad::ClassAttr::Struct;
class OpenAIAsync::Types::Results::ToolCall :does(OpenAIAsync::Types::Base) :Struct {
field $id :JSONStr = undef;
field $type :JSONStr = undef
does(OpenAIAsync::Types::Base) :Struct {
field $arguments :JSONStr = undef; # TODO decode the json from this directly?
field $name :JSONStr = undef;
}
class OpenAIAsync::Types::Results::ChatMessa
uct {
field $content :JSONStr;
field $tool_calls :MarshalTo([OpenAIAsync::Types::Results::ToolCall]) = undef; # don't think my local server provides this
field $role :JSONStr;
field $function_
sa(IO::Async::Notifier) :strict(params) {
use JSON::MaybeXS qw//;
use Net::Async::HTTP;
use Feature::Compat::Try;
use URI;
field $_json = JSON::MaybeXS->new(utf8 => 1, convert_blessed => 1)
headers => {
"Authorization" => "Bearer $api_key",
"Content-Type" => "application/json",
$api_org_name ? (
'OpenAI-Organization' => $api_org_name,
) : ()
my $json = $_json->encode($data);
my $url = URI->new($api_base . $endpoint );
my $result = await $http->do_request(
uri => $url,
method => "POST",
content => $json,