Skip to content

Commit 5e2b7e9

Browse files
committed
bk/2024-06-15-0116
1 parent 4f3cebc commit 5e2b7e9

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

Src/AI/DelphiCopilot.AI.ChatGPT.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ constructor TDelphiCopilotAIChatGPT.Create(const ASettings: TDelphiCopilotSettin
3939

4040
function TDelphiCopilotAIChatGPT.GetResponse(const AQuestion: string): string;
4141
var
42+
LQuestion: string;
4243
LApiUrl: string;
4344
LResponse: IResponse;
4445
LReturnValue: TJSONValue;
@@ -52,12 +53,16 @@ function TDelphiCopilotAIChatGPT.GetResponse(const AQuestion: string): string;
5253
Result := '';
5354
LApiUrl := FSettings.BaseUrlOpenAI;
5455

56+
TUtils.ShowMsgSynchronize(AQuestion);
57+
LQuestion := AQuestion.Replace(sLineBreak, '\n', [rfReplaceAll, rfIgnoreCase]);
58+
TUtils.ShowMsgSynchronize(LQuestion);
59+
5560
LResponse := TRequest.New
5661
.BaseURL(LApiUrl)
5762
.ContentType('application/json')
5863
.Accept('application/json')
5964
.Token('Bearer ' + FSettings.ApiKeyOpenAI)
60-
.AddBody(Format(API_JSON_BODY_BASE, [FSettings.ModelOpenAI, AQuestion.Trim]))
65+
.AddBody(Format(API_JSON_BODY_BASE, [FSettings.ModelOpenAI, LQuestion.Trim]))
6166
.Post;
6267

6368
if LResponse.StatusCode <> 200 then

Src/AI/DelphiCopilot.AI.Gemini.pas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ function TDelphiCopilotAIGemini.GetResponse(const AQuestion: string): string;
5151
begin
5252
Result := '';
5353
LApiUrl := FSettings.BaseUrlGemini + FSettings.ModelGemini + '?key=' + FSettings.ApiKeyGemini;
54-
//TUtils.ShowMsgSynchronize(LApiUrl);
5554

5655
LResponse := TRequest.New
57-
.BaseURL(LApiUrl) //API_URL - API_KEY
56+
.BaseURL(LApiUrl)
5857
.Accept('application/json')
5958
.AddBody(Format(API_JSON_BODY_BASE, [AQuestion.Trim]))
6059
.Post;
@@ -78,7 +77,6 @@ function TDelphiCopilotAIGemini.GetResponse(const AQuestion: string): string;
7877
begin
7978
LPartsObj := LPartsArray.Items[j] as TJsonObject;
8079
LJsonText := LPartsObj.GetValue<string>('text');
81-
//FResponse.Add(TUtils.ConfReturnAI(JsonText));
8280
Result := LJsonText;
8381
end;
8482
end;

Src/Test/Test.pas

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@
22

33
interface
44

5+
uses
6+
SysUtils, Classes;
7+
8+
type
9+
// Classe Cliente
10+
TCliente = class
11+
private
12+
FId: Integer;
13+
FNome: String;
14+
FTelefone: String;
15+
FCidade: String;
16+
public
17+
// Propriedades
18+
property Id: Integer read FId write FId;
19+
property Nome: String read FNome write FNome;
20+
property Telefone: String read FTelefone write FTelefone;
21+
property Cidade: String read FCidade write FCidade;
22+
23+
// Construtor
24+
constructor Create(const AId: Integer; const ANome: String; const ATelefone: String; const ACidade: String);
25+
end;
26+
527
implementation
628

29+
// Construtor da classe Cliente
30+
constructor TCliente.Create(const AId: Integer; const ANome: String; const ATelefone: String; const ACidade: String);
31+
begin
32+
FId := AId;
33+
FNome := ANome;
34+
FTelefone := ATelefone;
35+
FCidade := ACidade;
36+
end;
37+
738
end.

0 commit comments

Comments
 (0)