| 1 | package OpenAIAsync::Types::Results; | ||
| 2 | 1 | ▶ | use v5.36.0; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 0 | ▶ | use Object::Pad; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 4 | |||
| 5 | use OpenAIAsync::Types; | ||
| 6 | use Object::PadX::Role::AutoMarshal; | ||
| 7 | use Object::PadX::Role::AutoJSON; | ||
| 8 | use Object::Pad::ClassAttr::Struct; | ||
| 9 | |||
| 10 | class OpenAIAsync::Types::Results::ToolCall :does(OpenAIAsync::Types::Base) :Struct { | ||
| 11 | field $id :JSONStr = undef; | ||
| 12 | field $type :JSONStr = undef; # always "function" right now, may get expanded in the future | ||
| 13 | field $function :MarshalTo(OpenAIAsync::Types::Results::FunctionCall) = undef; | ||
| 14 | } | ||
| 15 | |||
| 16 | class OpenAIAsync::Types::Results::FunctionCall :does(OpenAIAsync::Types::Base) :Struct { | ||
| 17 | field $arguments :JSONStr = undef; # TODO decode the json from this directly? | ||
| 18 | field $name :JSONStr = undef; | ||
| 19 | } | ||
| 20 | |||
| 21 | class OpenAIAsync::Types::Results::ChatMessage :does(OpenAIAsync::Types::Base) :Struct { | ||
| 22 | field $content :JSONStr; | ||
| 23 | field $tool_calls :MarshalTo([OpenAIAsync::Types::Results::ToolCall]) = undef; # don't think my local server provides this | ||
| 24 | field $role :JSONStr; | ||
| 25 | field $function_call :MarshalTo(OpenAIAsync::Types::Results::FunctionCall) = undef; # Depcrecated, might still happen | ||
| 26 | } | ||
| 27 | |||
| 28 | class OpenAIAsync::Types::Results::ChatCompletionChoices :does(OpenAIAsync::Types::Base) :Struct { | ||
| 29 | field $finish_reason :JSONStr; | ||
| 30 | field $index :JSONNum; | ||
| 31 | field $message :MarshalTo(OpenAIAsync::Types::Results::ChatMessage); | ||
| 32 | } | ||
| 33 | |||
| 34 | class OpenAIAsync::Types::Results::ChatCompletion :does(OpenAIAsync::Types::Base) :Struct { | ||
| 35 | field $id :JSONStr; | ||
| 36 | field $choices :MarshalTo([OpenAIAsync::Types::Results::ChatCompletionChoices]); | ||
| 37 | field $created :JSONStr; | ||
| 38 | field $model :JSONStr; | ||
| 39 | field $system_fingerprint :JSONStr = undef; # My local system doesn't provide this | ||
| 40 | field $usage :MarshalTo(OpenAIAsync::Types::Results::Usage); | ||
| 41 | field $object :JSONStr; | ||
| 42 | } | ||
| 43 | |||
| 44 | class OpenAIAsync::Types::Results::ChunkDelta :does(OpenAIAsync::Types::Base) :Struct { | ||
| 45 | field $content :JSONStr; | ||
| 46 | field $function_call :MarshalTo(OpenAIAsync::Types::Results::FunctionCall) = undef; | ||
| 47 | field $tool_cass :MarshalTo([OpenAIAsync::Types::Results::ToolCall]) = undef; | ||
| 48 | field $role :JSONStr; | ||
| 49 | } | ||
| 50 | |||
| 51 | class OpenAIAsync::Types::Results::ChatCompletionChunkChoices :does(OpenAIAsync::Types::Base) :Struct { | ||
| 52 | field $delta :MarshalTo(OpenAIAsync::Types::Results::ChunkDelta); | ||
| 53 | field $finish_reason :JSONStr; | ||
| 54 | field $index :JSONStr; | ||
| 55 | } | ||
| 56 | |||
| 57 | # This is part of the streaming API | ||
| 58 | class OpenAIAsync::Types::Results::ChatCompletionChunk :does(OpenAIAsync::Types::Base) :Struct { | ||
| 59 | field $id :JSONStr; | ||
| 60 | field $choices :MarshalTo(OpenAIAsync::Types::Results::ChatCompletionChunkChoices); | ||
| 61 | field $created :JSONStr; | ||
| 62 | field $model :JSONStr; | ||
| 63 | field $system_fingerprint :JSONStr = undef; | ||
| 64 | field $object :JSONStr; | ||
| 65 | } | ||
| 66 | |||
| 67 | class OpenAIAsync::Types::Results::Usage :does(OpenAIAsync::Types::Base) :Struct { | ||
| 68 | field $total_tokens :JSONNum; | ||
| 69 | field $prompt_tokens :JSONNum; | ||
| 70 | field $completion_tokens :JSONNum = undef; # look at chat completions, is this the same | ||
| 71 | } | ||
| 72 | |||
| 73 | class OpenAIAsync::Types::Results::LogProbs :does(OpenAIAsync::Types::Base) :Struct { | ||
| 74 | # TODO what's the representation here? | ||
| 75 | field $text_offset = undef; | ||
| 76 | field $token_logprobs = undef; | ||
| 77 | field $tokens = undef; | ||
| 78 | field $top_logprobs = undef; | ||
| 79 | } | ||
| 80 | |||
| 81 | class OpenAIAsync::Types::Results::CompletionChoices :does(OpenAIAsync::Types::Base) :Struct { | ||
| 82 | field $text :JSONStr; | ||
| 83 | field $index :JSONNum; | ||
| 84 | field $logprobs :MarshalTo(OpenAIAsync::Types::Results::LogProbs) = undef; # TODO make nicer type? | ||
| 85 | field $finish_reason :JSONStr = undef; # TODO enum? helper funcs for this class? ->is_finished? | ||
| 86 | } | ||
| 87 | |||
| 88 | class OpenAIAsync::Types::Results::Completion :does(OpenAIAsync::Types::Base) :Struct { | ||
| 89 | field $id :JSONStr; | ||
| 90 | field $choices :MarshalTo([OpenAIAsync::Types::Results::CompletionChoices]); | ||
| 91 | field $created :JSONStr; | ||
| 92 | field $model :JSONStr; | ||
| 93 | field $system_fingerprint = undef; # my local implementation doesn't provide this, openai does it for tracking changes somehow | ||
| 94 | field $usage :MarshalTo(OpenAIAsync::Types::Results::Usage); | ||
| 95 | field $object :JSONStr; | ||
| 96 | } | ||
| 97 | |||
| 98 | |||
| 99 | class OpenAIAsync::Types::Results::Embedding :does(OpenAIAsync::Types::Base) :Struct { | ||
| 100 | field $object :JSONStr; | ||
| 101 | field $model :JSONStr; | ||
| 102 | field $usage :MarshalTo(OpenAIAsync::Types::Results::Usage); | ||
| 103 | field $data :MarshalTo([OpenAIAsync::Types::Results::EmbeddingData]); | ||
| 104 | } | ||
| 105 | |||
| 106 | class OpenAIAsync::Types::Results::EmbeddingData :does(OpenAIAsync::Types::Base) :Struct { | ||
| 107 | field $index :JSONNum; | ||
| 108 | field $embedding :JSONList(JSONNum); | ||
| 109 | field $object :JSONStr; | ||
| 110 | } | ||