-
Notifications
You must be signed in to change notification settings - Fork 2
/
AutoGPT.Options.pas
69 lines (61 loc) · 1.96 KB
/
AutoGPT.Options.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
unit AutoGPT.Options;
interface
uses
IniFiles,SysUtils;
type
TAutoGPTOptions = class
private
FOpenAIApiKey:string;
FGoogleCustomSearchApiKey:string;
FWorkingDir:string;
FGPT3Only:Boolean;
FGoogleSearchEngineID:string;
public
property OpenAIApiKey:string read FOpenAIApiKey write FOpenAIApiKey;
property GoogleCustomSearchApiKey:string read FGoogleCustomSearchApiKey write FGoogleCustomSearchApiKey;
property WorkingDir:string read FWorkingDir write FWorkingDir;
property GoogleSearchEngineID:string read FGoogleSearchEngineID write FGoogleSearchEngineID;
property GPT3Only:Boolean read FGPT3Only write FGPT3Only;
constructor Create;
procedure LoadFromIni(const AIniFileName:string);
procedure SaveToIni(const AIniFileName:string);
end;
implementation
{ TAutoGPTOptions }
constructor TAutoGPTOptions.Create;
begin
end;
procedure TAutoGPTOptions.LoadFromIni(const AIniFileName: string);
var
LIni:TIniFile;
begin
if FileExists(AIniFileName) then
begin
LIni:=TIniFile.Create(AIniFileName);
try
FWorkingDir:= LIni.ReadString('OPTIONS','WORKING_DIR','.\');
FOpenAIApiKey:= LIni.ReadString('API_KEYS','OPEN_AI','');
FGoogleCustomSearchApiKey:= LIni.ReadString('API_KEYS','GOOGLE_CUSTOM_SEARCH','');
FGoogleSearchEngineID:= LIni.ReadString('API_KEYS','GOOGLE_SEARCH_ENGINE_ID','');
FGPT3Only:=LIni.ReadBool('OPTIONS','GPT3ONLY',False);
finally
LIni.Free;
end;
end;
end;
procedure TAutoGPTOptions.SaveToIni(const AIniFileName: string);
var
LIni:TIniFile;
begin
LIni:=TIniFile.Create(AIniFileName);
try
LIni.WriteString('OPTIONS','WORKING_DIR',FWorkingDir);
LIni.WriteString('API_KEYS','OPEN_AI',FOpenAIApiKey);
LIni.WriteString('API_KEYS','GOOGLE_CUSTOM_SEARCH',FGoogleCustomSearchApiKey);
LIni.WriteString('API_KEYS','GOOGLE_SEARCH_ENGINE_ID',FGoogleSearchEngineID);
LIni.WriteBool('OPTIONS','GPT3ONLY',FGPT3Only);
finally
LIni.Free;
end;
end;
end.