Jump to content

CoeurdeLeon

Members
  • Content Count

    34
  • Joined

  • Last visited

Everything posted by CoeurdeLeon

  1. CoeurdeLeon

    ChatGPT Example

    Esegece WOW!!! WOW!!! WOW!!! VERY GOOD!!! IT WORKS VERY WELL. Thank you. Richard Maley
  2. CoeurdeLeon

    ChatGPT Example

    Thank you. No I had not seen this. My only problem is I need to spend more money. And it is not completely clear what TMS product I need to buy. I have already spent a ton of money on Rad Studio Architect and IPWorks. I would like to get IPWorks or Indy working to save a buck. I do thank you for pointing out this solution. Richard Maley
  3. CoeurdeLeon

    ChatGPT Example

    I have 3 functions using IPWorks: Unit ads.ChatGpt; Interface Function ChatWithGPT(Const question, Api_Key: String): String; Function ChatWithGPT2(Const question, Api_Key: String): String; Function ChatWithGPT3(Const question, Api_Key: String): String; Implementation Uses chatgpt_p, ipwcore, ipwhttp, ipwrest, ipwtypes, System.SysUtils, System.NetEncoding; Function ChatWithGPT(Const question, Api_Key: String): String; Var http : TIpwHttp; response: String; Begin http := TIpwHttp.Create(Nil); Try http.AddCookie('Authorization', 'Bearer ' + Api_Key); http.Get('https://api.openai.com/v1/chatgpt/chat?question=' + question); response := http.TransferredData; Result := response; Finally http.Free; End; End; Function ChatWithGPT2(Const question, Api_Key: String): String; Var rest : TipwREST; response: String; Begin rest := TipwREST.Create(Nil); Try rest.ContentType := 'application/json'; rest.OtherHeaders := 'Authorization: Bearer ' + Api_Key; rest.PostData := '{\"model\": \"text-davinci-003\", \"prompt\": \"" + question + "\", \"temperature\": 0, \"max_tokens\": 64}'; rest.Post('https://api.openai.com/v1/completions'); rest.XPath := '/json/choices/[1]/text'; response := rest.XText.Replace('\"', ''); Result := response; Finally FreeAndNil(rest); End; End; Function ChatWithGPT3(Const question, Api_Key: String): String; Var http : TIpwHttp; response: String; Begin http := TIpwHttp.Create(Nil); Try http.OnSSLServerAuthentication:=frmchatgpt.ipwHTTP1SSLServerAuthentication; http.AddCookie('Authorization', 'Bearer ' + Api_Key); http.Get('https://api.openai.com/v1/chatgpt/chat?question=' + TNetEncoding.URL.Encode(question)); response := http.TransferredData; Result := response; Except on E: Exception do Result := 'Error: ' + E.Message; End; http.Free; End; End. The errors are as follows: Function ChatWithGPT(Const question, Api_Key: String): String; Function ChatWithGPT2(Const question, Api_Key: String): String; Function ChatWithGPT3(Const question, Api_Key: String): String; Richard Maley
  4. Can Rad Studio 11.1 and 11.2 coexist? Does Rad Studio 11.2 install over Rad Studio 11.1 or can the 2 versions both exist on the same computer? Thank you Dick Maley
  5. CoeurdeLeon

    Can Rad Studio 11.1 and 11.2 coexist?

    This was my fear. I invested so much time getting 11.1 perfect that I am inclined to wait for the next major release to upgrade. Thank you. Dick Maley
  6. CoeurdeLeon

    DelphiCon 2021 Code Examples

    I attended DelphiCon 2021 and enjoyed it very much, however I cannot find any of the example projects. Are the example projects published and if so where? Thank you Dick Maley
  7. CoeurdeLeon

    DelphiCon 2021 Code Examples

    Does anyone have more presenter code samples from DelphiCon 2021?
  8. CoeurdeLeon

    DelphiCon 2021 Code Examples

    Thank you David.
  9. CoeurdeLeon

    DelphiCon 2021 Code Examples

    Peter That is disappointing that there is not a central location where all presenters can save their code examples and attendees can retrieve this code. If anyone has more urls for DelphiCon 2021 code please respond with the urls. Thank you. Dick Maley
×