forked from HemulGM/DelphiOpenAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenAI.Models.pas
116 lines (100 loc) · 3.11 KB
/
OpenAI.Models.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
unit OpenAI.Models;
interface
uses
System.SysUtils, OpenAI.API;
type
TModelPermission = class
private
FAllow_create_engine: Boolean;
FAllow_fine_tuning: Boolean;
FAllow_logprobs: Boolean;
FAllow_sampling: Boolean;
FAllow_search_indices: Boolean;
FAllow_view: Boolean;
FCreated: Int64;
FId: string;
FIs_blocking: Boolean;
FObject: string;
FOrganization: string;
public
property AllowCreateEngine: Boolean read FAllow_create_engine write FAllow_create_engine;
property AllowFineTuning: Boolean read FAllow_fine_tuning write FAllow_fine_tuning;
property AllowLogprobs: Boolean read FAllow_logprobs write FAllow_logprobs;
property AllowSampling: Boolean read FAllow_sampling write FAllow_sampling;
property AllowSearchIndices: Boolean read FAllow_search_indices write FAllow_search_indices;
property AllowView: Boolean read FAllow_view write FAllow_view;
property Created: Int64 read FCreated write FCreated;
property Id: string read FId write FId;
property IsBlocking: Boolean read FIs_blocking write FIs_blocking;
property &Object: string read FObject write FObject;
property Organization: string read FOrganization write FOrganization;
end;
TModel = class
private
FCreated: Int64;
FId: string;
FObject: string;
FOwned_by: string;
FPermission: TArray<TModelPermission>;
FRoot: string;
public
property Created: Int64 read FCreated write FCreated;
property Id: string read FId write FId;
property &Object: string read FObject write FObject;
property OwnedBy: string read FOwned_by write FOwned_by;
property Permission: TArray<TModelPermission> read FPermission write FPermission;
property Root: string read FRoot write FRoot;
destructor Destroy; override;
end;
TModels = class
private
FData: TArray<TModel>;
FObject: string;
public
property Data: TArray<TModel> read FData write FData;
property &Object: string read FObject write FObject;
destructor Destroy; override;
end;
TModelsRoute = class(TOpenAIAPIRoute)
public
/// <summary>
/// Lists the currently available models, and provides basic information about each one such as the owner and availability.
/// </summary>
function List: TModels;
/// <summary>
/// Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
/// </summary>
/// <param name="const Name: string">The ID of the model to use for this request</param>
function Retrieve(const Model: string): TModel;
end;
implementation
{ TModelsRoute }
function TModelsRoute.List: TModels;
begin
Result := API.Get<TModels>('models');
end;
function TModelsRoute.Retrieve(const Model: string): TModel;
begin
Result := API.Get<TModel>('models' + '/' + Model);
end;
{ TModels }
destructor TModels.Destroy;
var
Item: TModel;
begin
for Item in FData do
if Assigned(Item) then
Item.Free;
inherited;
end;
{ TModel }
destructor TModel.Destroy;
var
Item: TModelPermission;
begin
for Item in FPermission do
if Assigned(Item) then
Item.Free;
inherited;
end;
end.