landgraf-dev / openai-delphi

OpenAI API client for Delphi and Lazarus/FPC. Use ChatGPT, DALL-E and other products from Pascal language.
MIT License
126 stars 40 forks source link

error with D10.2.3 #1

Closed limelect closed 1 year ago

limelect commented 1 year ago

image

wlandgraf commented 1 year ago

I believe this is not related to the library, but with your local computer trying to access the OpenAI API. From your screenshot, my guess is that you are using an old Windows version?

OpenAI seems to use Let's Encrypt certificate, so I guess you are hitting this issue:

https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

limelect commented 1 year ago

Sorry, this https://github.com/fpiette/DelphiChatGPT project works like a charm. And there is one more both work fine

wlandgraf commented 1 year ago

The mentioned project uses a different library to perform HTTP requests. I don't know what is the "one more" you mentioned. This library doesn't do anything regarding HTTP request. It just uses the built-in Delphi classes, which in turn uses WinHTTP as far as I know.

Maybe you are hitting the TLS 1.2 issue then, you can try this:

https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392

mikelustosa commented 1 year ago

I have the same problem. Windows 8.1 upgraded to Windows server 2012 R2.

wlandgraf commented 1 year ago

@mikelustosa Have you tried the fixes suggested in the link I posted?

mikelustosa commented 1 year ago

@mikelustosa Have you tried the fixes suggested in the link I posted?

Yes. Not work. 😕

wlandgraf commented 1 year ago

So, you installed the root certificate manually, and also enabled TLS 1.2 and TLS 1.3, and neither work? What is the exact error message you get?

limelect commented 1 year ago

I Made my own. I took 2 projects one that works and the other that does not (certificate problem) but has a great screen and merged them It is a VCL and FMX merged together

Screenshot - 23_02_2023 , 10_44_43

wlandgraf commented 1 year ago

There is now an option to use Indy to connect to OpenAI API. You can switch to it using a code like this:

uses {...}, OpenApiRest, OpenApiIndy, IdHTTP;

procedure TMainDataModule.IndyClientCreated(Client: TIdHTTP);
begin
  // Set extra Client properties here
end;

procedure TMainDataModule.DataModuleCreate(Sender: TObject);
var
  Factory: TIndyRestRequestFactory;
begin
  // At the beginning of your application, set the DefaultRequestFactory
  Factory := TIndyRestRequestFactory.Create;
  DefaultRequestFactory := Factory;
  Factory.OnClientCreated := IndyClientCreated;
end;

More info in this link: https://github.com/landgraf-dev/openapi-delphi-generator#client-compatibility

This change will probably allow the client to work better on old Windows versions which don't support the latest ciphers used by the API server.