-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathOpenAI.Component.ChatHistory.pas
More file actions
88 lines (70 loc) · 2.14 KB
/
Copy pathOpenAI.Component.ChatHistory.pas
File metadata and controls
88 lines (70 loc) · 2.14 KB
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
unit OpenAI.Component.ChatHistory;
interface
uses
System.SysUtils, System.Classes, System.SyncObjs, System.Generics.Collections,
System.Threading, OpenAI, OpenAI.Chat, OpenAI.Utils.ObjectHolder,
OpenAI.Utils.ChatHistory;
type
TChat = OpenAI.Chat.TChat;
TChatMessageBuild = OpenAI.Chat.TChatMessageBuild;
TOpenAIChatHistoryCustom = class(TComponent)
private
function GetAutoTrim: Boolean;
function GetMaxTokensForQuery: Int64;
function GetMaxTokensOfModel: Int64;
procedure SetAutoTrim(const Value: Boolean);
procedure SetMaxTokensForQuery(const Value: Int64);
procedure SetMaxTokensOfModel(const Value: Int64);
protected
FItems: TChatHistory;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Items: TChatHistory read FItems;
property AutoTrim: Boolean read GetAutoTrim write SetAutoTrim;
property MaxTokensForQuery: Int64 read GetMaxTokensForQuery write SetMaxTokensForQuery;
property MaxTokensOfModel: Int64 read GetMaxTokensOfModel write SetMaxTokensOfModel;
end;
TOpenAIChatHistory = class(TOpenAIChatHistoryCustom)
published
property AutoTrim;
property MaxTokensForQuery;
property MaxTokensOfModel;
end;
implementation
{ TOpenAIChatHistoryCustom }
constructor TOpenAIChatHistoryCustom.Create(AOwner: TComponent);
begin
inherited;
FItems := TChatHistory.Create;
end;
destructor TOpenAIChatHistoryCustom.Destroy;
begin
FItems.Free;
inherited;
end;
function TOpenAIChatHistoryCustom.GetAutoTrim: Boolean;
begin
Result := FItems.AutoTrim;
end;
function TOpenAIChatHistoryCustom.GetMaxTokensForQuery: Int64;
begin
Result := FItems.MaxTokensForQuery;
end;
function TOpenAIChatHistoryCustom.GetMaxTokensOfModel: Int64;
begin
Result := FItems.MaxTokensOfModel;
end;
procedure TOpenAIChatHistoryCustom.SetAutoTrim(const Value: Boolean);
begin
FItems.AutoTrim := Value;
end;
procedure TOpenAIChatHistoryCustom.SetMaxTokensForQuery(const Value: Int64);
begin
FItems.MaxTokensForQuery := Value;
end;
procedure TOpenAIChatHistoryCustom.SetMaxTokensOfModel(const Value: Int64);
begin
FItems.MaxTokensOfModel := Value;
end;
end.