Change full parameters of API and first try at tests
This commit is contained in:
parent
213278513b
commit
f54d3a89e6
17 changed files with 55 additions and 43 deletions
|
@ -361,7 +361,7 @@ class OpenAIAsync::Server :repr(HASH) :strict(params) {
|
||||||
# TODO can I redo this to eliminate the $future_status? I want it for internal chaining inside the handler
|
# TODO can I redo this to eliminate the $future_status? I want it for internal chaining inside the handler
|
||||||
# that is needed for it to persist some code that's running in the future that populates the queue
|
# that is needed for it to persist some code that's running in the future that populates the queue
|
||||||
my $route_method = $route->{handle};
|
my $route_method = $route->{handle};
|
||||||
await $self->$route_method($req, $future_status, $queue, $ctx, $obj, $params);
|
await $self->$route_method($future_status, $queue, $ctx, $obj, $params);
|
||||||
|
|
||||||
my $status = await $future_status;
|
my $status = await $future_status;
|
||||||
my $is_streaming_event = $status->{is_streaming};
|
my $is_streaming_event = $status->{is_streaming};
|
||||||
|
|
|
@ -39,7 +39,7 @@ role OpenAIAsync::Server::API::v1::AudioTTS :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method audio_create_speech($req, $future_status, $queue, $ctx, $obj, $params);
|
async method audio_create_speech($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::v1::AudioSTT :strict(params) {
|
role OpenAIAsync::Server::API::v1::AudioSTT :strict(params) {
|
||||||
|
@ -53,7 +53,7 @@ role OpenAIAsync::Server::API::v1::AudioSTT :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method audio_create_transcript($req, $future_status, $queue, $ctx, $obj, $params);
|
async method audio_create_transcript($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::v1::AudioTranslate :strict(params) {
|
role OpenAIAsync::Server::API::v1::AudioTranslate :strict(params) {
|
||||||
|
@ -67,7 +67,7 @@ role OpenAIAsync::Server::API::v1::AudioTranslate :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method audio_create_translation($req, $future_status, $queue, $ctx, $obj, $params);
|
async method audio_create_translation($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::v1::Audio :strict(params) {
|
role OpenAIAsync::Server::API::v1::Audio :strict(params) {
|
||||||
|
|
|
@ -39,5 +39,5 @@ role OpenAIAsync::Server::API::v1::ChatCompletion :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method chat_completion($req, $future_status, $queue, $ctx, $obj, $params);
|
async method chat_completion($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -37,5 +37,5 @@ role OpenAIAsync::Server::API::v1::Completions :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method completion($req, $future_status, $queue, $ctx, $obj, $params);
|
async method completion($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -37,5 +37,5 @@ role OpenAIAsync::Server::API::v1::Embeddings :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method embeddings($req, $future_status, $queue, $ctx, $obj, $params);
|
async method embeddings($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -66,9 +66,9 @@ role OpenAIAsync::Server::API::v1::File :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method file_list($req, $future_status, $queue, $ctx, $obj, $params);
|
async method file_list($future_status, $queue, $ctx, $obj, $params);
|
||||||
async method file_info($req, $future_status, $queue, $ctx, $obj, $params);
|
async method file_info($future_status, $queue, $ctx, $obj, $params);
|
||||||
async method file_delete($req, $future_status, $queue, $ctx, $obj, $params);
|
async method file_delete($future_status, $queue, $ctx, $obj, $params);
|
||||||
async method file_upload($req, $future_status, $queue, $ctx, $obj, $params);
|
async method file_upload($future_status, $queue, $ctx, $obj, $params);
|
||||||
async method file_download($req, $future_status, $queue, $ctx, $obj, $params);
|
async method file_download($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -36,5 +36,5 @@ role OpenAIAsync::Server::API::v1::Image :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method create_image($req, $future_status, $queue, $ctx, $obj, $params);
|
async method create_image($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -36,5 +36,5 @@ role OpenAIAsync::Server::API::v1::ModelList :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method model_list($req, $future_status, $queue, $ctx, $obj, $params);
|
async method model_list($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -36,5 +36,5 @@ role OpenAIAsync::Server::API::v1::Moderations :strict(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async method moderations($req, $future_status, $queue, $ctx, $obj, $params);
|
async method moderations($future_status, $queue, $ctx, $obj, $params);
|
||||||
}
|
}
|
|
@ -32,17 +32,17 @@ TODO document the subroles here, split up because TTS is much simpler to impleme
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::Test::AudioTTS :strict(params) {
|
role OpenAIAsync::Server::API::Test::AudioTTS :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::AudioTTS;
|
apply OpenAIAsync::Server::API::v1::AudioTTS;
|
||||||
async method audio_create_speech($obj, $http_req, $ctx) {...}
|
async method audio_create_speech($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::Test::AudioSTT :strict(params) {
|
role OpenAIAsync::Server::API::Test::AudioSTT :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::AudioSTT;
|
apply OpenAIAsync::Server::API::v1::AudioSTT;
|
||||||
async method audio_create_transcript($obj, $http_req, $ctx) {...}
|
async method audio_create_transcript($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::Test::AudioTranslate :strict(params) {
|
role OpenAIAsync::Server::API::Test::AudioTranslate :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::AudioTranslate;
|
apply OpenAIAsync::Server::API::v1::AudioTranslate;
|
||||||
async method audio_create_translation($obj, $http_req, $ctx) {...}
|
async method audio_create_translation($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
||||||
|
|
||||||
role OpenAIAsync::Server::API::Test::Audio :strict(params) {
|
role OpenAIAsync::Server::API::Test::Audio :strict(params) {
|
||||||
|
|
|
@ -30,19 +30,31 @@ role OpenAIAsync::Server::API::Test::ChatCompletion :strict(params) {
|
||||||
use OpenAIAsync::Types::Results;
|
use OpenAIAsync::Types::Results;
|
||||||
use Future::AsyncAwait;
|
use Future::AsyncAwait;
|
||||||
|
|
||||||
async method chat ($obj, $http_req, $ctx) {
|
async method chat ($future_status, $queue, $ctx, $obj, $params) {
|
||||||
return OpenAIAsync::Types::Results::ChatCompletion->new(
|
my $chained_future = $future_status->then(sub {
|
||||||
id => "24601",
|
return OpenAIAsync::Types::Results::ChatCompletion->new(
|
||||||
choices => [],
|
id => "24601",
|
||||||
model => "GumbyBrain-llm",
|
choices => [],
|
||||||
system_fingerprint => "SHODAN node 12 of 16 tertiary adjunct of unimatrix 42",
|
model => "GumbyBrain-llm",
|
||||||
usage => {
|
system_fingerprint => "SHODAN node 12 of 16 tertiary adjunct of unimatrix 42",
|
||||||
total_tokens => 42,
|
usage => {
|
||||||
prompt_tokens => 6,
|
total_tokens => 42,
|
||||||
completion_tokens => 9,
|
prompt_tokens => 6,
|
||||||
},
|
completion_tokens => 9,
|
||||||
object => "text_completion",
|
},
|
||||||
created => 0,
|
object => "text_completion",
|
||||||
)
|
created => 0,
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$future_status->done({
|
||||||
|
headers => {}, # TODO a way I can make this not leak and not expose the HTTP nature?
|
||||||
|
is_streaming => false,
|
||||||
|
content_type => "application/json", # TODO this should come from the object return type!
|
||||||
|
status_code => 200,
|
||||||
|
status_message => "OK",
|
||||||
|
});
|
||||||
|
|
||||||
|
return $chained_future; # TODO this might actually be wrong thanks to the async above?
|
||||||
}
|
}
|
|
@ -28,5 +28,5 @@ OpenAIAsync::Server::API::Completions - Basic completion api role, consumed to i
|
||||||
role OpenAIAsync::Server::API::Test::Completions :strict(params) {
|
role OpenAIAsync::Server::API::Test::Completions :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::Completions;
|
apply OpenAIAsync::Server::API::v1::Completions;
|
||||||
|
|
||||||
async method completion($obj, $http_req, $ctx) { ... }
|
async method completion($future_status, $queue, $ctx, $obj, $params) { ... }
|
||||||
}
|
}
|
|
@ -28,5 +28,5 @@ OpenAIAsync::Server::API::Embeddings - Basic embeddings api role, consumed to im
|
||||||
role OpenAIAsync::Server::API::Test::Embeddings {
|
role OpenAIAsync::Server::API::Test::Embeddings {
|
||||||
apply OpenAIAsync::Server::API::v1::Embeddings;
|
apply OpenAIAsync::Server::API::v1::Embeddings;
|
||||||
|
|
||||||
async method embeddings($obj, $http_req, $ctx) { ... }
|
async method embeddings($future_status, $queue, $ctx, $obj, $params) { ... }
|
||||||
}
|
}
|
|
@ -28,9 +28,9 @@ OpenAIAsync::Server::API::File - Basic file api role, consumed to implement the
|
||||||
role OpenAIAsync::Server::API::Test::File :strict(params) {
|
role OpenAIAsync::Server::API::Test::File :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::File;
|
apply OpenAIAsync::Server::API::v1::File;
|
||||||
|
|
||||||
async method file_list($http_req, $ctx) {...}
|
async method file_list($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
async method file_info($http_req, $ctx, $params) {...}
|
async method file_info($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
async method file_delete($http_req, $ctx, $params) {...}
|
async method file_delete($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
async method file_upload($http_req, $ctx, $params) {...}
|
async method file_upload($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
async method file_download($http_req, $ctx, $params) {...}
|
async method file_download($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
|
@ -28,5 +28,5 @@ OpenAIAsync::Server::API::Image - Basic image role, consumed to implement the Op
|
||||||
role OpenAIAsync::Server::API::Test::Image :strict(params) {
|
role OpenAIAsync::Server::API::Test::Image :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::Image;
|
apply OpenAIAsync::Server::API::v1::Image;
|
||||||
|
|
||||||
async method create_image($http_req, $ctx) {...}
|
async method create_image($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
|
@ -28,5 +28,5 @@ OpenAIAsync::Server::API::ModelList - Basic model list api role, consumed to imp
|
||||||
role OpenAIAsync::Server::API::Test::ModelList :strict(params) {
|
role OpenAIAsync::Server::API::Test::ModelList :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::ModelList;
|
apply OpenAIAsync::Server::API::v1::ModelList;
|
||||||
|
|
||||||
async method model_list($obj, $http_req, $ctx) {...}
|
async method model_list($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
|
@ -28,5 +28,5 @@ OpenAIAsync::Server::API::Moderations - Basic moderation api role, consumed to i
|
||||||
role OpenAIAsync::Server::API::Test::Moderations :strict(params) {
|
role OpenAIAsync::Server::API::Test::Moderations :strict(params) {
|
||||||
apply OpenAIAsync::Server::API::v1::Moderations;
|
apply OpenAIAsync::Server::API::v1::Moderations;
|
||||||
|
|
||||||
async method moderations($obj, $http_req, $ctx) {...}
|
async method moderations($future_status, $queue, $ctx, $obj, $params) {...}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue