forked from HuichanKIM/Ollama-Delphi-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit_Main.pas
2958 lines (2644 loc) · 101 KB
/
Unit_Main.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Unit_Main;
{$B-} { Enable partial boolean evaluation }
{$T-} { Untyped pointers }
{$X+} { Enable extended syntax }
{$H+} { Use long strings }
{$J+} { Allow typed constant to be modified }
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
System.TypInfo,
System.JSON,
System.ImageList,
System.Actions,
System.Types,
System.Generics.Defaults,
System.Generics.Collections,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ExtCtrls,
Vcl.ComCtrls,
Vcl.Buttons,
Vcl.BaseImageCollection,
Vcl.ImageCollection,
Vcl.ImgList,
Vcl.VirtualImageList,
Vcl.Imaging.pngimage,
Vcl.Imaging.jpeg,
Vcl.Imaging.GIFImg,
Vcl.ActnList,
Vcl.ExtDlgs,
Vcl.Menus,
Vcl.Skia,
Vcl.Samples.Gauges,
System.Skia,
SVGIconImageCollection,
SVGIconVirtualImageList,
Data.Bind.Components,
Data.Bind.ObjectScope,
REST.Types,
REST.Client,
Vcl.OleServer,
Vcl.CheckLst,
SpeechLib_TLB,
Unit_Common,
Unit_MRUManager,
Unit_ImageDropDown,
Unit_Welcome,
Unit_ChattingBoxClass,
Unit_DosCommander;
type
IChangedCommon = interface
['{B3803857-A467-4AB0-A295-CEC4FDD376A0}']
procedure ApplyChange;
end;
TForm_RestOllama = class(TForm, IChangedCommon)
Button_StartRequest: TButton;
Button_Abort: TButton;
PageControl_Chatting: TPageControl;
Tabsheet_Chatting: TTabSheet;
Button_About: TButton;
StatusBar1: TStatusBar;
Panel_Options: TPanel;
Panel_Toolbar: TPanel;
Label_StartRequest: TLabel;
Button_Options: TButton;
SVGIconVirtualImageList1: TSVGIconVirtualImageList;
SVGIconImageCollection1: TSVGIconImageCollection;
ActionList_Ollma: TActionList;
Action_Options: TAction;
Action_Exit: TAction;
Action_StartRequest: TAction;
Action_Chatting: TAction;
Action_Logs: TAction;
Action_InetAlive: TAction;
Action_SendRequest: TAction;
Action_Pop_CopyText: TAction;
Action_Pop_DeleteItem: TAction;
Action_Pop_ScrollToTop: TAction;
Action_Pop_ScrollToBottom: TAction;
Action_Pop_SaveAllText: TAction;
Button_Chatting: TButton;
GroupBox_BaseURL: TGroupBox;
GroupBox_Model: TGroupBox;
ComboBox_Models: TComboBox;
Label_Caption: TLabel;
TabSheet_ChatLogs: TTabSheet;
Memo_LogWin: TMemo;
Panel_ChatRequestBox: TPanel;
Edit_ReqContent: TEdit;
Button_SendRequest: TButton;
Panel_Models: TPanel;
Panel_ChattingButtons: TPanel;
Panel_CaptionModelTopics: TPanel;
RadioGroup_PromptType: TRadioGroup;
Panel_Chatting: TPanel;
Label_BaseURL: TLabel;
GroupBox_Username: TGroupBox;
Edit_Nickname: TEdit;
Panel_RequestButtons: TPanel;
GroupBox_Llava: TGroupBox;
Image_Llva: TImage;
OpenPictureDialog1: TOpenPictureDialog;
SaveTextFileDialog1: TSaveTextFileDialog;
GroupBox_Description: TGroupBox;
Image_Logo: TImage;
Panel_Setting: TPanel;
GroupBox_GlobalFontSize: TGroupBox;
Label_FontSize: TLabel;
TrackBar_GlobalFontSize: TTrackBar;
SpeedButton_ScrollTop: TSpeedButton;
SpeedButton_ScrollBottom: TSpeedButton;
SpeedButton_DeleteChatMessage: TSpeedButton;
SpeedButton_CopyToClipboard: TSpeedButton;
SpeedButton_SaveAllText: TSpeedButton;
SpeedButton_ClearChatBox: TSpeedButton;
SpeedButton_DefaultSet: TSpeedButton;
Action_Abort: TAction;
SkAnimatedImage_ChatProcess: TSkAnimatedImage;
CheckBox_AutoLoadTopic: TCheckBox;
GroupBox_TopicOption: TGroupBox;
Action_Home: TAction;
Button_Home: TButton;
Label_Description: TLabel;
SpeedButton_LoadModel: TSpeedButton;
SpeedButton_TTS: TSpeedButton;
Action_TTS: TAction;
Timer_System: TTimer;
SpeedButton_ListModels: TSpeedButton;
GroupBox_Tranlation: TGroupBox;
SpeedButton_Translate: TSpeedButton;
Action_TransMessage: TAction;
ComboBox_TransSource: TComboBox;
ComboBox_TransTarget: TComboBox;
Label_TransDir: TLabel;
SkAnimatedImage_Chat: TSkAnimatedImage;
GroupBox_TTSEngine: TGroupBox;
GroupBox_CPUMem: TGroupBox;
Label_MemUsage: TLabel;
Gauge_MemUsage: TGauge;
Label_MemTotal: TLabel;
Label_MemAvailable: TLabel;
Label_TotalMemory: TLabel;
Label_Available: TLabel;
SpeedButton_CPUMemUsage: TSpeedButton;
Label_Counter: TLabel;
Panel_CaptionLog: TPanel;
SpeedButton_ClearLogBox: TSpeedButton;
GroupBox_Topics: TGroupBox;
TreeView_Topics: TTreeView;
SpeedButton_AddToTopics: TSpeedButton;
CheckBox_UseTopicSeed: TCheckBox;
Label_SeedGet: TLabel;
Edit_TopicSeed: TEdit;
Action_TransMessagePush: TAction;
Button_DosCommand: TButton;
Action_TransPrompt: TAction;
Action_TransPromptPush: TAction;
Panel_TopicButtons: TPanel;
SpeedButton_AddTopic: TSpeedButton;
SpeedButton_DeleteTopic: TSpeedButton;
SpeedButton_RunRequest: TSpeedButton;
Label_NodeSeed: TLabel;
SpeedButton_NewRootnode: TSpeedButton;
SpeedButton_ExpandFull: TSpeedButton;
CheckBox_AutoTranslation: TCheckBox;
PopupMenu_Topics: TPopupMenu;
pmn_RenameTopic: TMenuItem;
SpeedButton_RenameTopic: TSpeedButton;
Panel_ImageLlavaBase: TPanel;
Action_DefaultRefresh: TAction;
Action_DosCommand: TAction;
Action_ClearChatting: TAction;
Panel_OptionsTop: TPanel;
SpeedButton_GotoChatting: TSpeedButton;
Action_LoadImageLlava: TAction;
Action_RequestDialog: TAction;
SpeedButton_OllamaAlive: TSpeedButton;
CheckBox_DebugToLog: TCheckBox;
SpeedButton_SystemInfo: TSpeedButton;
ComboBox_TTSEngine: TComboBox;
Label4: TLabel;
TrackBar_Rate: TTrackBar;
Label_Rate: TLabel;
Label5: TLabel;
TrackBar_Volume: TTrackBar;
Label_Volume: TLabel;
ProgressBar_TTS: TProgressBar;
Shape_TTS: TShape;
GroupBox_Memo: TGroupBox;
Memo_Memo: TMemo;
SpeedButton_TTSPlay: TSpeedButton;
SpeedButton_TTSPause: TSpeedButton;
SpeedButton_TTSStop: TSpeedButton;
Action_About: TAction;
Shape_Memory: TShape;
CheckBox_SaveOnCLose: TCheckBox;
Panel_ChattingBase: TPanel;
Label_Font_Size: TLabel;
SpeedButton_LlavaLoad: TSpeedButton;
pmn_ClearAll: TMenuItem;
N2: TMenuItem;
Frame_ChattingBox: TFrame_ChattingBoxClass;
SpeedButton_SelectionColor: TSpeedButton;
Action_SelectionColor: TAction;
SpeedButton_TtsControl: TSpeedButton;
SpeedButton_SaveAllLoges: TSpeedButton;
Action_CustomFontColor: TAction;
Action_TTSControl: TAction;
SpeedButton_ReqDummy: TSpeedButton;
Action_HelpShortcuts: TAction;
SpeedButton_Help: TSpeedButton;
Label1: TLabel;
Action_ApplyChange: TAction;
Panel_ServerChatting: TPanel;
Memo_ServerChattings: TMemo;
Panel_RemoteBroker: TPanel;
Splitter1: TSplitter;
SpeedButton_ShutdownClients: TSpeedButton;
SpeedButton_ShowRmBroker: TSpeedButton;
SpeedButton_GetIPs: TSpeedButton;
SpeedButton_SetFont: TSpeedButton;
FontDialog1: TFontDialog;
SpeedButton_ActivateBroker: TSpeedButton;
SpeedButton_Broker: TSpeedButton;
SkSvg_Broker: TSkSvg;
SkSvg_OllamaAlive: TSkSvg;
Label_IP_Port: TLabel;
Panel_BanList: TPanel;
Label2: TLabel;
CheckListBox_ConnIPs: TCheckListBox;
Panel_RemoteChattBase: TPanel;
RESTClient_Ollama: TRESTClient;
RESTRequest_Ollama: TRESTRequest;
RESTResponse_Ollama: TRESTResponse;
// for Get Llava Thumb
ImageList_LLAVA: TImageList;
SpeedButton_LavaPrev: TSpeedButton;
SpeedButton_LavaNext: TSpeedButton;
Action_SHowBroker: TAction;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
// Messagw Proc ...
procedure WM_NETHTTPMESSAGE(var Msg: TMessage); Message WM_NETHTTP_MESSAGE;
procedure WF_DMMESSAGE(var Msg: TMessage); Message WF_DM_MESSAGE;
// ...
procedure Action_OptionsExecute(Sender: TObject);
procedure Action_ExitExecute(Sender: TObject);
procedure Action_StartRequestExecute(Sender: TObject);
procedure Action_ChattingExecute(Sender: TObject);
procedure Action_InetAliveExecute(Sender: TObject);
procedure Action_LogsExecute(Sender: TObject);
procedure Action_SendRequestExecute(Sender: TObject);
procedure Action_HomeExecute(Sender: TObject);
procedure Action_Pop_CopyTextExecute(Sender: TObject);
procedure Action_Pop_DeleteItemExecute(Sender: TObject);
procedure Action_Pop_ScrollToTopExecute(Sender: TObject);
procedure Action_Pop_ScrollToBottomExecute(Sender: TObject);
procedure Action_Pop_SaveAllTextExecute(Sender: TObject);
procedure Action_AbortExecute(Sender: TObject);
procedure Action_TTSExecute(Sender: TObject);
procedure Action_TranslationCommon(Sender: TObject);
procedure Action_DefaultRefreshExecute(Sender: TObject);
procedure Action_DosCommandExecute(Sender: TObject);
procedure Action_ClearChattingExecute(Sender: TObject);
procedure Action_LoadImageLlavaExecute(Sender: TObject);
procedure Action_RequestDialogExecute(Sender: TObject);
procedure Action_AboutExecute(Sender: TObject);
procedure Action_SelectionColorExecute(Sender: TObject);
procedure Action_TTSControlExecute(Sender: TObject);
procedure Action_HelpShortcutsExecute(Sender: TObject);
procedure Action_ApplyChangeExecute(Sender: TObject);
procedure ActionList_OllmaUpdate(Action: TBasicAction; var Handled: Boolean);
procedure RadioGroup_PromptTypeClick(Sender: TObject);
procedure PageControl_ChattingResize(Sender: TObject);
procedure PageControl_ChattingChange(Sender: TObject);
procedure Edit_ReqContentKeyPress(Sender: TObject; var Key: Char);
procedure Edit_NicknameChange(Sender: TObject);
procedure ComboBox_ModelsChange(Sender: TObject);
procedure ComboBox_TTSEngineChange(Sender: TObject);
procedure SkLabel_IntroClick(Sender: TObject);
procedure SkLabel_IntroWords5Click(Sender: TObject);
procedure SkAnimatedImage_ChatClick(Sender: TObject);
procedure Timer_SystemTimer(Sender: TObject);
procedure SpeedButton_ClearLogBoxClick(Sender: TObject);
procedure SpeedButton_LoadModelClick(Sender: TObject);
procedure SpeedButton_CPUMemUsageClick(Sender: TObject);
procedure SpeedButton_ListModelsClick(Sender: TObject);
procedure SpeedButton_AddToTopicsClick(Sender: TObject);
procedure SpeedButton_AddTopicClick(Sender: TObject);
procedure SpeedButton_RunRequestClick(Sender: TObject);
procedure SpeedButton_DeleteTopicClick(Sender: TObject);
procedure SpeedButton_NewRootnodeClick(Sender: TObject);
procedure SpeedButton_ExpandFullClick(Sender: TObject);
procedure SpeedButton_TTSPlayClick(Sender: TObject);
procedure SpeedButton_SystemInfoClick(Sender: TObject);
procedure SpeedButton_SaveAllLogesClick(Sender: TObject);
procedure SpeedButton_HelpClick(Sender: TObject);
procedure SpeedButton_GetIPsClick(Sender: TObject);
procedure SpeedButton_SetFontClick(Sender: TObject);
procedure SpeedButton_ShowRmBrokerClick(Sender: TObject);
procedure SpeedButton_ShutdownClientsClick(Sender: TObject);
procedure SpeedButton_ActivateBrokerClick(Sender: TObject);
procedure TreeView_TopicsClick(Sender: TObject);
procedure TreeView_TopicsDblClick(Sender: TObject);
procedure TreeView_TopicsCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
procedure TreeView_TopicsDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure TreeView_TopicsDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
procedure TreeView_TopicsChange(Sender: TObject; Node: TTreeNode);
procedure pmn_RenameTopicClick(Sender: TObject);
procedure pmn_ClearAllClick(Sender: TObject);
procedure PopupMenu_TopicsPopup(Sender: TObject);
procedure TrackBar_GlobalFontSizeChange(Sender: TObject);
procedure TrackBar_RateChange(Sender: TObject);
procedure TrackBar_VolumeChange(Sender: TObject);
procedure Label_DescriptionClick(Sender: TObject);
procedure CheckBox_SaveOnCLoseClick(Sender: TObject);
procedure CheckListBox_ConnIPsClickCheck(Sender: TObject);
//
procedure OnRESTRequest_OllamaAfterRequest;
procedure OnRESTRequest_OllamaError(Sender: TObject);
procedure RESTClient_OllamaReceiveData(const Sender: TObject; AContentLength, AReadCount: Int64; var AAbort: Boolean);
procedure RESTClient_OllamaSendData(const Sender: TObject; AContentLength, AWriteCount: Int64; var AAbort: Boolean);
//
procedure SkSvg_BrokerClick(Sender: TObject);
procedure Action_SHowBrokerExecute(Sender: TObject);
procedure Image_LlvaDblClick(Sender: TObject);
procedure Label_SeedGetClick(Sender: TObject);
private
FInitialized: Boolean;
FFrameWelcome: TFrame_Welcome;
FTopicsMRU: TMRU_Manager;
FImage_DropDown: TImageDropDown;
FSpVoice: TSpVoice;
//
FModelsList: TStringList;
FRequest_Type: TRequest_Type;
FDisplay_Type: TDisplay_Type;
FRequestingFlag: Boolean;
FIniFileName: string;
FLastRequest: string;
FAbortingFlag: Boolean;
FTranlateMode: TTranlateMode;
FTopic_Seleced: string;
FModel_Selected: string;
FBeenPaused, FStreamJustStarted: Boolean;
FTTS_Speaking: Boolean;
FTTS_EngineName: string;
FMemMonitoringFlag: Boolean;
FDoneSoundFlag: Boolean;
FSaveLogsOnCLoseFlag: Boolean;
FSelectionNode: TTreeNode;
// for Get Llava Thumb
FLavaIndexFlag: Integer;
procedure Load_ConfigIni(const AFlag: Integer = 0);
procedure Save_ConfigIni(const AFlag: Integer = 0);
// Interface ...
procedure ApplyChange;
private
// Request / Respomse ...
procedure Common_RestSettings(const AFlag: Integer);
procedure Do_StartRequest(const Aflag: Integer; const APrompt: string='');
procedure Do_Abort(const AFlag: Integer=0);
//
procedure Add_LogWin (const ALog: string) ;
procedure Push_LogWin(const AFlag: Integer = 0; const ALog: string = '');
procedure Do_DisplayJson(const RespStr: string);
procedure Do_LoadModel(const AIndex: Integer);
procedure Do_ListModels(const AIndex: Integer = 0);
procedure Do_DisplayJson_Models(const RespStr: string);
procedure Do_TransLate(const AMode: TTranlateMode; const ACodepage: Integer; const ASrc: string);
procedure Do_AddToRequest(const AFlag: Integer);
procedure Do_ListUpTopic(const AFlag: Integer; const ANode: TTreeNode; const APrompt: string);
procedure Add_ChattingMessage(const AFlag, ALocation, ALvTag: Integer; const APrompt: string);
procedure Insert_ChattingTranslate(const AIndex, ALocation: Integer; const ATranslation: string);
procedure Action_StartRequestMode(const AMode: Integer = 0);
procedure Return_FocusToVST(const AFlag: Integer = 0);
procedure Set_OllamaAlive(const ALiveFlag: Boolean);
procedure Try_SetFocus(AControl: TWinControl);
// for Get Llava Thumb
procedure DropDownLoadImageEvent(Sender: TObject; const ALoadFile: string);
procedure DropDownLoadIndexEvent(Sender: TObject; const AIndex: Integer);
// property ...
procedure SetRequestingFlag(const Value: Boolean);
procedure SetRequest_Type(const Value: TRequest_Type);
procedure SetDisplay_Type(const Value: TDisplay_Type);
procedure SetTopicSeleced(const Value: string);
procedure SetModelSelected(const Value: string);
procedure SetMemMonitoringFlag(const Value: Boolean);
procedure SetDoneSoundFlag(const Value: Boolean);
procedure SetSaveLogsOnCLoseFlag(const Value: Boolean);
// Dos Command ...
procedure DOSCommandProc(var Msg : TMessage); Message DOS_MESSAGE;
procedure DM_DosCommandProc(const AFlag: Integer; const AText: string ='');
// Text to Speech ...
procedure SpVoiceAudioLevel(Sender: TObject; StreamNumber: Integer; StreamPosition: OleVariant; AudioLevel: Integer);
procedure SpVoiceSentence(Sender: TObject; StreamNumber: Integer; StreamPosition: OleVariant; CharacterPosition, Length: Integer);
procedure SpVoiceStartStream(Sender: TObject; StreamNumber: Integer; StreamPosition: OleVariant);
procedure SpVoiceEndStream(Sender: TObject; StreamNumber: Integer; StreamPosition: OleVariant);
procedure Do_TTSSpeak_Ex(const AFlag: Integer; const ASource: string);
procedure Do_TTSSpeak_Stop(const AFlag: Integer = 0);
procedure SetTTS_Speaking(const Value: Boolean);
function GetTTS_Speaking: Boolean;
function Get_TTSText(): string;
// Remote Broker ...
procedure Log_Server(const AFlag: Integer; const ALog: string);
procedure Build_BanListUp(const AFlag: Integer = 0);
procedure ResetRESTComponentsToDefaults;
procedure SetLavaIndexFlag(const Value: Integer);
public
procedure Do_ChangeStyleCustom(const AFlag: Integer = 0);
procedure Do_TTS_Speak(const AFlag: Integer; const ASource: string);
function Get_ReadyRequest(): Boolean;
procedure GetResizedImage_SKIA(const ASource: string; const AStream: TMemoryStream);
// Property ...
property RequestingFlag: Boolean read FRequestingFlag write SetRequestingFlag;
property Request_Type: TRequest_Type read FRequest_Type write SetRequest_Type;
property Display_Type: TDisplay_Type read FDisplay_Type write SetDisplay_Type;
property Topic_Seleced: string read FTopic_Seleced write SetTopicSeleced;
property Model_Selected: string read FModel_Selected write SetModelSelected;
property TTS_Speaking: Boolean read GetTTS_Speaking write SetTTS_Speaking;
property MemMonitoringFlag: Boolean read FMemMonitoringFlag write SetMemMonitoringFlag;
property DoneSoundFlag: Boolean read FDoneSoundFlag write SetDoneSoundFlag;
property SaveLogsOnCLoseFlag: Boolean read FSaveLogsOnCLoseFlag write SetSaveLogsOnCLoseFlag;
property ModelsList: TStringList read FModelsList;
property LavaIndexFlag: Integer read FLavaIndexFlag write SetLavaIndexFlag;
end;
var
Form_RestOllama: TForm_RestOllama;
implementation
uses
System.UITypes,
SVGInterfaces,
SkiaSVGFactory,
System.JSON.Types,
System.Threading,
System.Diagnostics,
System.Math,
System.IniFiles,
Winapi.PsAPI,
Winapi.ShellAPI,
Vcl.Themes,
Vcl.Styles,
Vcl.StyleAPI,
Vcl.Clipbrd,
Unit_AliveOllama,
Unit_Translator,
Unit_About,
Unit_RequestDialog,
Unit_DMServer,
Unit_RMBroker;
{$R *.dfm}
resourcestring
R_Aya =
'Aya 23, released by Cohere, is a new family of state-of-the-art, multilingual, '+
'generative large language research model (LLM) covering 23 different languages.';
R_Phi3 =
'Phi-3 Mini is a 3.8B parameters, lightweight, state-of-the-art open model by Microsoft. '+
'Trained with the Phi-3 datasets that includes both synthetic data and the filtered publicly available websites data '+
'with a focus on high-quality and reasoning dense properties.';
R_Llama3 =
'Meta Llama 3, a family of models developed by Meta Inc. are new state-of-the-art. '+
'Llama 3 instruction-tuned models are fine-tuned and optimized for dialogue/chat use cases and '+
'outperform many of the available open-source chat models on common benchmarks.';
R_Llama2 =
'Llama 2 is released by Meta Platforms, Inc. This model is trained on 2 trillion tokens, and by default supports a context length of 4096. '+
'Llama 2 Chat models are fine-tuned on over 1 million human annotations, and are made for chat.';
R_Gemma =
'Gemma is a family of lightweight, state-of-the-art open models built by Google DeepMind. '+
'Updated to version 1.1. It¡¯s inspired by Gemini models at Google.';
R_Llava =
'LLaVA is a novel end-to-end trained large multimodal model that combines a vision encoder '+
'and Vicuna for general-purpose visual and language understanding. Updated to version 1.6.';
R_Codegemma =
'CodeGemma is a collection of powerful, lightweight models that can perform a variety of coding tasks like fill-in-the-middle code completion, '+
'code generation, natural language understanding, mathematical reasoning, and instruction following.';
R_DolphiMistral =
'The uncensored Dolphin model based on Mistral that excels at coding tasks. Updated to version 2.8. '+
'The Dolphin model by Eric Hartford, based on Mistral version 0.2 released in March 2024.';
R_Mistral =
'Mistral is a 7B parameter model, distributed with the Apache license. '+
'It is available in both instruct (instruction following) and text completion.';
R_QWen2 =
'Qwen2 is a new series of large language models from Alibaba group.';
const
C_CaptionFormat = 'Model - %s / Topic - %s';
C_SectionData = 'Data';
C_SectionOptions = 'Options';
C_LlavaPromptContent = 'Describe this image'; // 'What is in this picture?';
C_OllamaAlive: array [Boolean] of string = (' * Ollama is dead.',' * Ollama is running.');
C_ModelDesc: array [0 .. 9] of string = (R_Aya, R_Phi3, R_Llama3, R_Llama2, R_Gemma, R_Llava, R_Codegemma, R_DolphiMistral, R_Mistral, R_QWen2);
const
C_TimestampFontSize = 8;
const
CF_Memos = 'memos.txt';
CF_ModalList = 'modelslist.txt';
const
// SPRUNSTATE flags
SPRS_DONE = 1 shl 0;
SPRS_IS_SPEAKING = 1 shl 1;
// SPEAKFLAGS flags
SPF_DEFAULT = 0;
SPF_ASYNC = 1 shl 0;
const
C_TTS_Play = 0;
C_TTS_Pause = 1;
C_TTS_Stop = 2;
C_TOPIC_Add = 0;
C_TOPIC_Run = 1;
C_CHATLOC_Left = 0;
C_CHATLOC_Right = 1;
C_CHATUser_Ollama = 0;
C_CHATUser_Model = 1;
C_CHATOllama_Model = 2;
C_CHATOllama_System = 3;
C_DefLavaWidth = 64;
C_DefLavaHeight = 60;
var
V_BuffLogLines: string;
V_StopWatch :TStopWatch;
V_BaseURL: string = GC_BaseURL_Chat;
V_LoadModelFlag: Boolean = False;
V_Username: string = 'User';
V_LoadModelIndex: Integer = 0;
V_MyModel: string = 'phi3';
V_MyContentPrompt: string = 'Hello';
V_BaseURLarray: array [TRequest_Type] of string = (GC_BaseURL_Generate, GC_BaseURL_Chat);
V_LlavaSource: string = 'logollama.png';
V_DummyFlag: Integer = 0;
V_TaskSystem: ITask;
V_ElapsedInterval: Int64;
{ ... }
procedure GetResizedImage_WIC(const ASource: string; ADest: TImage; const ANewWidth, ANewHeight: Integer);
begin
var _WIC := TWICImage.Create;
_WIC.LoadFromFile(ASource);
var _WIC2 := _WIC.CreateScaledCopy(ANewWidth, ANewHeight);
try
ADest.Picture.Assign(_WIC2);
finally
_WIC.Free;
_WIC2.Free;
end;
end;
{ TForm_RestOllama }
procedure TForm_RestOllama.FormCreate(Sender: TObject);
begin
{ Version ... }
Self.Caption := GC_MainCaption0;
{$WARNINGS OFF}
ReportMemoryLeaksOnShutdown := (DebugHook <> 0);
{$WARNINGS ON}
Randomize;
FInitialized := False;
Unit_Common.InitializePaths();
FIniFileName := ExtractFileName(ChangeFileExt(ParamStr(0), '.ini'));
var _SkinStyle:= TStyleManager.ActiveStyle.Name;
with System.Inifiles.TMemIniFile.Create(FIniFileName) do
try
GV_CheckingAliveStart := ReadBool(C_SectionData, 'Check_Alive', True);
_SkinStyle := ReadString(C_SectionData, 'Skin_Style', 'Windows11 Impressive Dark');
finally
Free;
end;
var _default := TStyleManager.ActiveStyle.Name;
if not SameText(_default, _SkinStyle) then
TStyleManager.TrySetStyle(_SkinStyle);
FFrameWelcome := TFrame_Welcome.Create(Self);
with FFrameWelcome do
begin
Parent := Self;
Align := alClient;
SkLabel_Intro.OnClick := SkLabel_IntroClick;
SkSvg_ICon.OnClick := SkLabel_IntroClick;
SkLabel_Clicktohome.OnClick := SkLabel_IntroClick;
SkLabel_Intro.Words[5].OnClick := SkLabel_IntroWords5Click;
Visible := True;
//
AnimationFlag := GV_CheckingAliveStart;
//
BringToFront;
end;
GV_AliveOllamaFlag := True;
if GV_CheckingAliveStart then
begin
GV_AliveOllamaFlag := False;
CheckAlive_Ollama(1);
end;
{ Load Image from Resource ... }
var _stream := Unit_Common.TResourceStream_Ex.Create(HInstance, 'OLOGO', RT_RCDATA);
if _stream.Size > 1 then
try
_stream.Position := 0;
Image_Llva.Picture.LoadFromStream(_stream);
_stream.Re_Initialize(HInstance, PChar('OWAITTING'), RT_RCDATA);
_stream.Position := 0;
SkAnimatedImage_ChatProcess.LoadFromStream(_stream);
_stream.Re_Initialize(HInstance, PChar('OWIN'), RT_RCDATA);
_stream.Position := 0;
SkAnimatedImage_Chat.LoadFromStream(_stream);
finally
_stream.Free;
end;
{... }
with Memo_LogWin.Lines do
begin
Clear;
Add('* Welcome to Ollama Client GUI 2024 ');
Add('* Start at : '+ FormatDateTime('YYYY.MM.DD HH:NN:SS', Now));
Add('* Ini File: ' + FIniFileName);
Add('');
end;
TreeView_Topics.Items.Clear;
CheckListBox_ConnIPs.Items.Clear;
FTopicsMRU := TMRU_Manager.Create(TreeView_Topics);
FModelsList := TStringList.Create;
var _fmodels := CV_AppPath+CF_ModalList;
if FileExists(_fmodels) then
begin
FModelsList.LoadFromFile(_fmodels) ;
ComboBox_Models.Items.Assign(FModelsList);
ComboBox_Models.ItemIndex := 0;
end;
// TTS Engine ------------------------------------------------------------- //
FSpVoice := TSpVoice.Create(Self);
with FSpVoice do
begin
AutoConnect := True;
ConnectKind := Vcl.OleServer.ckRunningOrNew;
OnStartStream := SpVoiceStartStream;
OnEndStream := SpVoiceEndStream;
OnSentence := SpVoiceSentence;
OnAudioLevel := SpVoiceAudioLevel;
EventInterests := SVEAllEvents;
end;
SkSvg_OllamaAlive.Svg.Source := C_Connection_Svg0;
SkSvg_Broker.Svg.Source := C_RemoteConn_Svg0;
ComboBox_TTSEngine.Clear;
var _SOTokens: ISpeechObjectTokens := FSpVoice.GetVoices('', '');
var _SOToken: ISpeechObjectToken;
for var _i := 0 to _SOTokens.Count - 1 do
begin
_SOToken := _SOTokens.Item(_i);
ComboBox_TTSEngine.Items.AddObject(_SOToken.GetDescription(0), TObject(Pointer(_SOToken)));
_SOToken._AddRef;
end;
if ComboBox_TTSEngine.Items.Count > 0 then
begin
ComboBox_TTSEngine.ItemIndex := 0;
ComboBox_TTSEngine.OnChange(ComboBox_TTSEngine);
end;
TrackBar_Rate.Position := FSpVoice.Rate;
Label_Rate.Caption := IntToStr(TrackBar_Rate.Position);
TrackBar_Volume.Position := FSpVoice.Volume;
Label_Volume.Caption := IntToStr(TrackBar_Volume.Position);
// TTS Engine ------------------------------------------------------------- //
Action_TTS.Enabled := False;
Tabsheet_Chatting.TabVisible := False;
TabSheet_ChatLogs.TabVisible := False;
GroupBox_CPUMem.Visible := False;
GroupBox_TTSEngine.Visible := False;
SpeedButton_ExpandFull.Tag := 1;
FRequest_Type := TRequest_Type.ort_Chat;
FDisplay_Type := TDisplay_Type.disp_Content;
FTranlateMode := TTranlateMode.otm_MessageView;
Gauge_MemUsage.Progress := 0;
FLavaIndexFlag := 0;
with ImageList_LLAVA do
begin
ColorDepth := cd32Bit;
DrawingStyle := dsTransparent;
Width := C_DefLavaWidth;
Height := C_DefLavaHeight;
end;
var _bstream := TMemoryStream.Create;
Image_Llva.Picture.SaveToStream(_bstream);
GetResizedImage_SKIA('', _bstream); // -> _bstream.free ...
GV_ReservedColor[0] := GC_SkinSelColor;
GV_ReservedColor[1] := GC_SkinHeadColor;
GV_ReservedColor[2] := GC_SkinBodyColor;
GV_ReservedColor[3] := GC_SkinFootColor;
// ------------------------------------------------------------------------------------------ //
with Frame_ChattingBox do
begin
InitializeEx(GV_ReservedColor[1], GV_ReservedColor[2] , GV_ReservedColor[3] );
pmn_TextToSpeech.OnClick := SpeedButton_TTS.OnClick;
pmn_ScrollToTop.OnClick := SpeedButton_ScrollTop.OnClick;
pmn_ScrollToBottom.OnClick := SpeedButton_ScrollBottom.OnClick;
pmn_ClearChattingBox.onClick := SpeedButton_ClearChatBox.OnClick;
pmn_ShowLogs.OnClick := Action_LogsExecute;
//
VST_ChattingBox.ThumbLists := ImageList_LLAVA;
end;
// ------------------------------------------------------------------------------------------ //
FImage_DropDown := TImageDropDown.Create(Image_Llva, Panel_ImageLlavaBase);
with FImage_DropDown do
begin
LavaPrevButton := SpeedButton_LavaPrev;
LavaNextButton := SpeedButton_LavaNext;
OnLoadImage := DropDownLoadImageEvent;
OnLoadIndex := DropDownLoadIndexEvent;
CurrentIndex := -1;
end;
// ------------------------------------------------------------------------------------------ //
Label_Caption.Caption := 'Model / Topic';
FModel_Selected := '';
FTopic_Seleced := '';
Label_Description.Tag := 1;
Label_Description.Caption := C_ModelDesc[0];
// Remote Server Chatting ...
Memo_ServerChattings.Clear;
Panel_ServerChatting.Visible := (DM_ACTIVATECODE = 1);
Splitter1.Visible := (DM_ACTIVATECODE = 1);
end;
procedure TForm_RestOllama.FormDestroy(Sender: TObject);
begin
for var _i := 0 to ComboBox_TTSEngine.Items.Count - 1 do
ISpeechObjectToken(Pointer(ComboBox_TTSEngine.Items.Objects[_i]))._Release;
FreeAndNil(FSpVoice);
end;
procedure TForm_RestOllama.Do_ChangeStyleCustom(const AFlag: Integer);
begin
if TStyleManager.IsCustomStyleActive then { Custom style ... }
begin
LockWindowUpdate(Self.Handle);
try
TreeView_Topics.StyleElements := [seBorder];
Panel_CaptionModelTopics.StyleElements := [seBorder];
Panel_ChattingButtons.StyleElements := [seBorder];
Panel_OptionsTop.StyleElements := [seBorder];
Memo_LogWin.StyleElements := [seBorder];
Memo_Memo.StyleElements := [seBorder];
Memo_ServerChattings.StyleElements := [seBorder];
CheckListBox_ConnIPs.StyleElements := [seBorder];
var _spanelcolor := StyleServices.GetStyleColor(scWindow);
var _topcolor := StyleServices.GetStyleColor(scGrid);
TreeView_Topics.color := _spanelcolor;
Memo_LogWin.Color := _spanelcolor;
Memo_Memo.Color := _spanelcolor;
Memo_ServerChattings.Color := _spanelcolor;
CheckListBox_ConnIPs.Color := _spanelcolor;
Panel_CaptionModelTopics.Color := _topcolor;
Panel_ChattingButtons.Color := _topcolor;
Panel_OptionsTop.Color := _topcolor;
//
Frame_ChattingBox.VST_ChattingBox.StyleElements := [seBorder];
Frame_ChattingBox.VST_ChattingBox.Color := _spanelcolor;
if AFlag = 1 then
begin
FTopicsMRU.Update_Topics;
Frame_ChattingBox.VST_ChattingBox.Repaint;
end;
finally
LockWindowUpdate(0);
end;
end;
end;
procedure TForm_RestOllama.FormShow(Sender: TObject);
begin
if not FInitialized then
begin
Global_TrimAppMemorySizeEx(0); // Once ...
SVGIconVirtualImageList1.UpdateImageList;
Do_ChangeStyleCustom(0);
Panel_CaptionLog.Caption := ' LOGs from '+FormatDateTime('yyyy.mm.dd HH:NN:SS', Now);
Panel_ChatRequestBox.Enabled := GV_AliveOllamaFlag;
Action_StartRequest.Enabled := GV_AliveOllamaFlag;
SetRequestingFlag(False);
StatusBar1.Panels[0].Width := Self.Width div 2;
Do_ListUpTopic(GC_MRU_NewRoot, nil, 'Hello'); { Topic Initilization }
FTopicsMRU.Read_JsonToTreeView;
for var _i := 0 to GC_LanguageCnt-1 do
begin
ComboBox_TransSource.Items[_i] := GC_LanguageCode[_i];
ComboBox_TransTarget.Items[_i] := GC_LanguageCode[_i];
end;
ComboBox_TransSource.ItemIndex := 0;
ComboBox_TransTarget.ItemIndex := 0;
SpeedButton_ShowRmBroker.Enabled := (DM_ACTIVATECODE = 1);
SkSvg_Broker.Enabled := (DM_ACTIVATECODE = 1);
SkSvg_Broker.Visible := (DM_ACTIVATECODE = 1);
var _fmemo := CV_AppPath+CF_Memos;
if FileExists(_fmemo) then
Memo_Memo.Lines.LoadFromFile(_fmemo);
// ---------------------------------------------------------------------- //
Load_ConfigIni();
// ---------------------------------------------------------------------- //
var _index := ComboBox_TTSEngine.Items.IndexOf(FTTS_EngineName);
if _index >= 0 then
ComboBox_TTSEngine.ItemIndex := _index;
Edit_ReqContent.Text := FLastRequest;
Edit_Nickname.Text := V_Username;
ComboBox_Models.ItemIndex := V_LoadModelIndex;
ComboBox_ModelsChange(Self);
GroupBox_Description.Height := 40;
SkAnimatedImage_Chat.Left := (PageControl_Chatting.Width - SkAnimatedImage_Chat.Width) div 2;
SkAnimatedImage_Chat.Top := (PageControl_Chatting.Height - SkAnimatedImage_Chat.Height) div 2;
if TreeView_Topics.items.Count > 0 then
Topic_Seleced := TreeView_Topics.items.GetFirstNode.Text;
FInitialized := True;
StatusBar1.Panels[1].Text := 'Elapsed time';
if GV_CheckingAliveStart then
begin
StatusBar1.Panels[0].Text := 'Waiting response from Ollama';
Application.ProcessMessages; // for Waiting Ollama Response ...
end
else
Set_OllamaAlive(GV_AliveOllamaFlag);
FFrameWelcome.BringToFront;
end;
end;
procedure TForm_RestOllama.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FTopicsMRU.free;
FModelsList.Free;
FImage_DropDown.Free;
end;
procedure TForm_RestOllama.Load_ConfigIni(const AFlag: Integer);
begin
var _indexid := ComboBox_TransTarget.Items.IndexOf(CV_LocaleID);
if _indexid >= 0 then
ComboBox_TransTarget.ItemIndex := _indexid;
Action_Options.Tag := 1;
var _IniFile := System.Inifiles.TMemIniFile.Create(FIniFileName);
with _IniFile do
try
FLastRequest := ReadString(C_SectionData, 'LastRequest', 'Who are you ?');
V_Username := ReadString(C_SectionData, 'Nickname', 'User');
V_LoadModelIndex := ReadInteger(C_SectionData, 'Loaded_Model', 0);
Action_Options.Tag := ReadInteger(C_SectionOptions, 'Action_Options_Tag', 1);
ComboBox_TransSource.ItemIndex := ReadInteger(C_SectionOptions, 'TTS_Source', 0);
ComboBox_TransTarget.ItemIndex := ReadInteger(C_SectionOptions, 'TTS_Target', _indexid);
CheckBox_AutoTranslation.Checked :=
ReadBool(C_SectionOptions, 'Auto_Trans', False);
FTTS_EngineName := ReadString(C_SectionOptions, 'TTS_Engine', '');
TrackBar_Volume.Position := ReadInteger(C_SectionOptions, 'TTS_Volume', 80);
CheckBox_AutoLoadTopic.Checked := ReadBool(C_SectionOptions, 'AutoLoadTopic', True);
SaveLogsOnCLoseFlag := ReadBool(C_SectionOptions, 'Save_Logs', False);
CheckBox_UseTopicSeed.Checked := ReadBool(C_SectionOptions, 'Use_TopicSeed', False);
DoneSoundFlag := ReadBool(C_SectionOptions, 'Done_Beep', True);
MRU_MAX_ROOT := ReadInteger(C_SectionOptions, 'Mru_Root_Max', 20);
MRU_MAX_CHILD := ReadInteger(C_SectionOptions, 'Mru_Child_Max', 30);
var _color0: Integer := ReadInteger(C_SectionOptions, 'Node_Selected_Color', GC_SkinSelColor);
var _color1: Integer := ReadInteger(C_SectionOptions, 'Node_HeaderFont_Color', GC_SkinHeadColor);
var _color2: Integer := ReadInteger(C_SectionOptions, 'Node_BodyFont_Color', GC_SkinBodyColor);
var _color3: Integer := ReadInteger(C_SectionOptions, 'Node_FooterFont_Color', GC_SkinFootColor);
var _fontname: string := ReadString(C_SectionOptions, 'VST_FontName', Self.Font.Name);
var _fontsize: Integer := ReadInteger(C_SectionOptions, 'VST_FontSize', 10);
Panel_Options.Visible := Action_Options.Tag = 1;
TrackBar_GlobalFontSize.Position := _fontsize;
Frame_ChattingBox.Do_SetCustomFont(0, _fontname, _fontsize);
Frame_ChattingBox.Do_SetCustomColor(0, TColor(_color0), TColor(_color1), TColor(_color2), TColor(_color3));
finally
Free;
end;
end;
procedure TForm_RestOllama.Save_ConfigIni(const AFlag: Integer);
begin
var _IniFile := System.Inifiles.TMemIniFile.Create(FIniFileName);
with _IniFile do
try
WriteString(C_SectionData, 'Skin_Style', TStyleManager.ActiveStyle.Name);
WriteBool(C_SectionData, 'Check_Alive', GV_CheckingAliveStart);
WriteString(C_SectionData, 'LastRequest', FLastRequest);
WriteString(C_SectionData, 'Nickname', V_Username);
WriteInteger(C_SectionData, 'Loaded_Model', V_LoadModelIndex);
WriteInteger(C_SectionOptions, 'Action_Options_Tag', Action_Options.Tag);
WriteInteger(C_SectionOptions, 'TTS_Source', ComboBox_TransSource.ItemIndex);
WriteInteger(C_SectionOptions, 'TTS_Target', ComboBox_TransTarget.ItemIndex);
WriteBool(C_SectionOptions, 'Auto_Trans', CheckBox_AutoTranslation.Checked);
WriteString(C_SectionOptions, 'TTS_Engine', FTTS_EngineName);
WriteInteger(C_SectionOptions, 'TTS_Volume', TrackBar_Volume.Position);
WriteBool(C_SectionOptions, 'AutoLoadTopic', CheckBox_AutoLoadTopic.Checked);
WriteBool(C_SectionOptions, 'Save_Logs', FSaveLogsOnCLoseFlag);
WriteBool(C_SectionOptions, 'Use_TopicSeed', CheckBox_UseTopicSeed.Checked);
WriteBool(C_SectionOptions, 'Done_Beep', FDoneSoundFlag);
WriteInteger(C_SectionOptions, 'Mru_Root_Max', MRU_MAX_ROOT);
WriteInteger(C_SectionOptions, 'Mru_Child_Max', MRU_MAX_CHILD);
WriteInteger(C_SectionOptions, 'Node_Selected_Color', Frame_ChattingBox.VST_NSelectionColor);
WriteInteger(C_SectionOptions, 'Node_HeaderFont_Color', Frame_ChattingBox.VST_NHeaderColor);
WriteInteger(C_SectionOptions, 'Node_BodyFont_Color', Frame_ChattingBox.VST_NBodyColor);
WriteInteger(C_SectionOptions, 'Node_FooterFont_Color', Frame_ChattingBox.VST_NFooterColor);
WriteString(C_SectionOptions, 'VST_FontName', Frame_ChattingBox.VST_FontName);
WriteInteger(C_SectionOptions, 'VST_FontSize', Frame_ChattingBox.VST_FontSize);
finally
UpdateFile;
Free;
end;
var _skinstyle := TStyleManager.ActiveStyle.Name;
var _skinfile := CV_AppPath+'skincfg.txt';
IOUtils_WriteAllText(_skinfile, _skinstyle);
end;
procedure TForm_RestOllama.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := False;
GV_AppCloseFlag := True;
Winapi.Windows.ShowWindowAsync(Application.Handle, SW_HIDE ); // Trick - Prevent Form-Flickering ...
Do_TTSSpeak_Stop();
Do_Abort(5);
if Assigned(V_TaskSystem) then
V_TaskSystem.Cancel;
Application.ProcessMessages; { ??? }
Timer_System.Enabled := False;
Save_ConfigIni();
if CheckBox_SaveOnCLose.Checked then
begin
var _slog := Format('%s%s%s', ['Log_',FormatDateTime('yyyymmdd_hhnnss', Now()), '.txt']);
Memo_LogWin.Lines.SaveToFile(CV_LogPath+_slog);
end;
var _fmemo := CV_AppPath+CF_Memos;
Memo_Memo.Lines.SaveToFile(_fmemo);
if FModelsList.Count > 0 then