Skip to content

Commit

Permalink
Added and updated models.
Browse files Browse the repository at this point in the history
  • Loading branch information
FMXExpress committed Aug 2, 2023
1 parent 20535d9 commit 518e304
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 29 deletions.
1 change: 0 additions & 1 deletion CodeDroidAI.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<DCC_ExeOutput>.\</DCC_ExeOutput>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Release>1</VerInfo_Release>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.1.0;Comments=</VerInfo_Keys>
Expand Down
51 changes: 51 additions & 0 deletions Win32/Release/ConsoleProgram.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
program test;

uses System.Net.HttpClientComponent;

procedure MakeChatGPTRestAPICall(const Endpoint: String; const Payload: String);
var
HTTPRequest: TNetHttpRequest;
HTTPResponse: TNetHttpResponse;
JSONData: TJsonObject;
begin
// Create a new HTTP request
HTTPRequest := TNetHttpRequest.Create(nil);
HTTPRequest.Open('POST', Endpoint, False);

// Set the request headers
HTTPRequest.AddHeader('Content-Type', 'application/json');

// Set the request payload
HTTPRequest.Write(Payload);

// Send the request
HTTPResponse := TNetHttpResponse.Create(nil);
HTTPResponse.StatusCode := HTTPRequest.Send;

// Check the response status code
if HTTPResponse.StatusCode = 200 then
begin
// Parse the response JSON data
JSONData := TJsonObject.Parse(HTTPResponse.Content);

// Return the JSON data as a string
Result := JSONData.ToString;
end
else
begin
// Return an error message
Result := 'Error: ' + HTTPResponse.StatusText;
end;
end;

end.

// Example usage:

procedure MyProcedure;
begin
// Call the MakeChatGPTRestAPICall function
MakeChatGPTRestAPICall('https://api.openai.com/v1/chat/gpt', '{"prompt": "Hello, chatbot! How are you today?"}');
end;

end.
Loading

0 comments on commit 518e304

Please sign in to comment.