-
Notifications
You must be signed in to change notification settings - Fork 58
/
OpenAI.Engines.pas
71 lines (58 loc) · 1.76 KB
/
OpenAI.Engines.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
unit OpenAI.Engines;
interface
uses
System.SysUtils, OpenAI.API;
type
TEngine = class
private
FId: string;
FObject: string;
FOwner: string;
FReady: Boolean;
public
property Id: string read FId write FId;
property &Object: string read FObject write FObject;
property Owner: string read FOwner write FOwner;
property Ready: Boolean read FReady write FReady;
end;
TEngines = class
private
FData: TArray<TEngine>;
FObject: string;
public
property Data: TArray<TEngine> read FData write FData;
property &Object: string read FObject write FObject;
destructor Destroy; override;
end;
TEnginesRoute = class(TOpenAIAPIRoute)
public
/// <summary>
/// Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
/// </summary>
function List: TEngines; deprecated 'The Engines endpoints are deprecated. Please use their replacement, Models, instead.';
/// <summary>
/// Retrieves a model instance, providing basic information about it such as the owner and availability.
/// </summary>
/// <param name="EngineId">The ID of the engine to use for this request</param>
function Retrieve(const EngineId: string): TEngine; deprecated 'The Engines endpoints are deprecated. Please use their replacement, Models, instead.';
end;
implementation
{ TEnginesRoute }
function TEnginesRoute.List: TEngines;
begin
Result := API.Get<TEngines>('engines');
end;
function TEnginesRoute.Retrieve(const EngineId: string): TEngine;
begin
Result := API.Get<TEngine>('engines' + '/' + EngineId);
end;
{ TEngines }
destructor TEngines.Destroy;
var
Item: TEngine;
begin
for Item in FData do
Item.Free;
inherited;
end;
end.