File Coverage

blib/lib/OpenAIAsync/Types/Results.pm
Criterion Covered Total %
statement 17 131 12.9
branch n/a
condition n/a
subroutine 6 63 9.5
pod n/a
total 23 194 11.8


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