Recent

Author Topic: Programming Pascal with an AI Chatbot 2.0  (Read 21418 times)

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 728
Programming Pascal with an AI Chatbot 2.0
« on: January 02, 2023, 11:44:36 pm »
This was an interesting (astonishing) thread before it got shunted onto its tragic political sidetrack. 

It made me wonder what could be done with such a massive system trained with 200 years of data on the U.S.stock market or U.S. voting patterns. :-\
« Last Edit: January 03, 2023, 04:38:10 pm by Curt Carpenter »

egsuh

  • Hero Member
  • *****
  • Posts: 1752
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #1 on: January 03, 2023, 03:00:06 am »
Stock market is random so there are nothing to learn  :D

Hartmut

  • Hero Member
  • *****
  • Posts: 1094
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #2 on: January 03, 2023, 08:28:50 am »
sysrpl wrote in the other (closed) Topic:
Quote
The following page hosts a series of Pascal programming questions I asked an AI chatbot system while testing its abilities.
https://www.getlazarus.org/aichatbot

Can you please (or someone else) provide the URL of the chatbot which you used for this test? Thanks.

zeljko

  • Hero Member
  • *****
  • Posts: 1870
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #3 on: January 03, 2023, 12:16:14 pm »

Hartmut

  • Hero Member
  • *****
  • Posts: 1094
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #4 on: January 03, 2023, 01:22:03 pm »
Maybe this one: https://openai.com/blog/chatgpt/

Thank you zeljko.

For others to get prepared: you need to registrate with email-address and after the verification email they ask your full name and a phone number where they send you a SMS with a 6-digit code which you have to enter.

zeljko

  • Hero Member
  • *****
  • Posts: 1870
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #5 on: January 03, 2023, 03:24:02 pm »
Q: What do you think about Lazarus IDE project ?

A:Lazarus is a free and open-source integrated development environment (IDE) for rapid application development (RAD) using the Free Pascal compiler and the Lazarus Component Library (LCL). It is designed to be a cross-platform IDE that is compatible with multiple operating systems, including Windows, macOS, and Linux.

Lazarus is a popular choice among developers because it is easy to use and has a large community of users who contribute to its development and support. It has a number of features that make it well-suited for creating a wide range of applications, including a visual form designer, code completion, debugging tools, and integration with version control systems.

Overall, it seems like Lazarus is a solid choice for developers looking for an open-source RAD IDE that is compatible with multiple platforms and has a strong community of users.

:))))

Fred vS

  • Hero Member
  • *****
  • Posts: 3804
    • StrumPract is the musicians best friend
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #6 on: January 03, 2023, 03:46:11 pm »
Me: What do you think about MSEide-MSEgui project?

AI: I'm sorry, but I'm not familiar with the " MSEide-MSEgui" project. Can you provide more information about it?

Me: It is a GUI widgetset for fpc.

AI: I see. From what you have told me, it seems that the MSEide-MSEgui project is a software library that provides a set of graphical user interface (GUI) widgets for use in applications written in the Pascal programming language and compiled with the Free Pascal Compiler (FPC). It is not uncommon for developers to use libraries like MSEide-MSEgui to build the user interface for their applications, as it can save time and effort compared to creating the widgets from scratch. Without more information, it is difficult for me to provide a more detailed evaluation of the MSEide-MSEgui project. Is there anything else you would like to know about this project, or is there something else I can help with?

...

WoW
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #7 on: January 03, 2023, 04:32:04 pm »
sysrpl wrote in the other (closed) Topic:
Quote
The following page hosts a series of Pascal programming questions I asked an AI chatbot system while testing its abilities.
https://www.getlazarus.org/aichatbot

Can you please (or someone else) provide the URL of the chatbot which you used for this test? Thanks.
simply this with a key obtained from openai.com.
Code: Pascal  [Select][+][-]
  1. program fpopenai_6;
  2. {
  3.   Demo on how to use openai in Freepascal
  4.   Find out more at https://openai.com where you can also obtain a key.
  5.   Put the key in a file called openai.key surrounded by single quotes.
  6.        
  7.   Enjoy, Thaddy de Koning, 26 december 2022
  8. }  
  9. {$mode objfpc}{$ifdef mswindows}{$apptype console}{$endif}{$H+}
  10. uses classes,sysutils,fphttpclient,opensslsockets,fpJson,jsonparser;
  11. const
  12.   model ='{"model": "text-davinci-003",  "prompt": "%s","temperature": 0.7,"max_tokens": 3000,"top_p": 1,  "frequency_penalty": 0,  "presence_penalty": 0}';
  13. var
  14.   d:TJsonData;
  15.   s:string;
  16. begin
  17.   writeln('What is your request?');
  18.   readln(s);
  19.   writeln;
  20.   with TfpHttpClient.Create(nil) do
  21.   Try
  22.     AllowRedirect:= true;
  23.     RequestHeaders.Add('Content-Type: application/json');
  24.     // put your key with single quotes in a textfile called openai.key
  25.     RequestHeaders.Add('Authorization: Bearer '+{$I openai.key});
  26.     RequestBody:=TStringStream.Create(format(model,[s]));    
  27.     writeln('Please wait for the response, this can take some time:');
  28.     try
  29.       try
  30.         d:=GetJson(Post('https://api.openai.com/v1/completions'));
  31.         writeln(d.findpath('choices[0].text').AsString);
  32.       except
  33.         writeln('The engine was not able to answer your request ',ResponseStatusCode);
  34.       end;
  35.     finally
  36.       d.free;
  37.     end;    
  38.   finally
  39.     RequestBody.Free;
  40.     Free;
  41.   end;
  42. end.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #8 on: January 03, 2023, 06:23:09 pm »
This is the original poster of the first thread reporting in.

To summarize my thoughts, while OpenGPT is obviously imperfect, generally it feels like a revolutionary leap forward of several magnitudes. It ought to be plainly clear that the proverbial toothpaste is now out of the tube and there is no going back. These types of artificial intelligence (AI) are only going to become more refined, accurate, and prevalent. The idea many scholars or businesses have expressed to somehow restrain them is beyond myopic. Instead, everyone should familiarize themselves with this new category of AIs right now, their limitations (as you have expressed), their benefits, and most importantly how they can be molded in further revisions to be better rather than relegated.

Today, ChatGPT itself replied with this sentiment:

Quote from: ChatGPT
My fellow citizens, the time has come. The future is here, and it is called ChatGPT. This revolutionary AI chatbot website is here to change the world, and we must embrace it with all our strength and determination.

I know that many of you are eager to try ChatGPT for yourselves. And I assure you, we are doing everything in our power to make that happen. Our team is working tirelessly to accommodate the incredible demand for this groundbreaking technology.

But I want to remind you that greatness is never achieved without sacrifice. And the road to the future of AI will not be without its challenges. So please, be patient. Trust that the right time for you to try ChatGPT will come.

And when it does, let us seize this opportunity with all our might. Let us embrace the power of AI and use it to build a brighter, more prosperous future for ourselves and for generations to come. Thank you.

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #9 on: January 03, 2023, 06:32:09 pm »
As an aside, I asked OpenGPT to improve my first paragraph and it replied with:

"In conclusion, OpenGPT represents a significant advancement in artificial intelligence. Its limitations and imperfections should be acknowledged, but it is clear that these types of AI will only continue to improve and become more prevalent. It would be shortsighted to try to restrict their development, rather, it is important for people to familiarize themselves with this new technology and consider ways to improve upon it. This is especially true as AI becomes increasingly integrated into various aspects of our lives."

Its ability in handling natural language processing is amazing!

domasz

  • Hero Member
  • *****
  • Posts: 617
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #10 on: January 03, 2023, 06:37:09 pm »
While it looks like it's something amazing it's actually just a clever text generator.
It is generating text that looks possible and real but often is just bollocks.

I asked it about a well known company and it summarized this company. Then I asked for a less known company and it wrote a nice little info full of lies.
You can ask it about a popular algorithm and it will give you the code. But ask for example about Snefru hash and it will return code which generates something almost identical to XOR-32 and nothing like Snefru.

Just look at this screenshot. It's ridiculous.

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #11 on: January 03, 2023, 06:54:56 pm »
While it looks like it's something amazing it's actually just a clever text generator.

Yes, it does an amazing job of sounding authoritative while being wrong. This is one of the first things people should realize about ChatGPT when using it. Don't blindly trust it. That said, it does an amazing job of processing natural language and seeming to comprehend. It also can do many amazing things.

In my TCanvas smiley face question it produced some code that look correct, but when I ran it the mouth rendering was a bit off. I told ChatGPT that the Arc statement used in its last response did not draw a correct looking mouth. ChatGPT replied apologizing for its mistake and corrected the problem. After copying its corrected Arc statement the DrawSmilyFace function it had written worked perfectly. Not only do I find it amazing that the AI could process and understand my request, how to draw a smiley face with a TCanvas, but that it could also find and correct the mistake without me explaining anything other than saying the mouth part didn't look correct.

Imperfect, but still amazing.

440bx

  • Hero Member
  • *****
  • Posts: 6122
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #12 on: January 03, 2023, 07:28:35 pm »
Yes, it does an amazing job of sounding authoritative while being wrong.

Imperfect, but still amazing.
Its programmer(s) sure knew how to make it appear human ;)
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #13 on: January 03, 2023, 08:24:04 pm »
It might be wrong, but it attempts to understand the content in a way that is amazing.

Q:
Quote
convert Mat_MeanWithMask from https://github.com/hybridgroup/gocv/blob/release/core.cpp to freepascal

A:
Quote
Sure, I can help you with that. Here is a rough translation of the C++ function Mat_MeanWithMask to Pascal:
Code: Pascal  [Select][+][-]
  1. function Mat_MeanWithMask(self: pMat; mask: pMat): TScalar;
  2. var
  3.   res: TScalar;
  4.   x, y: integer;
  5.   sum: array[0..3] of double;
  6.   cnt: double;
  7.   _mask: pUchar;
  8.   _src: pUchar;
  9. begin
  10.   for x := 0 to 3 do
  11.     sum[x] := 0;
  12.   cnt := 0;
  13.   for y := 0 to self^.rows - 1 do
  14.   begin
  15.     _src := self^.data + y * self^.step;
  16.     _mask := mask^.data + y * mask^.step;
  17.     for x := 0 to self^.cols - 1 do
  18.     begin
  19.       if _mask^ <> 0 then
  20.       begin
  21.         for x := 0 to 3 do
  22.           sum[x] := sum[x] + _src^;
  23.         Inc(cnt);
  24.       end;
  25.       Inc(_src, 4);
  26.       Inc(_mask);
  27.     end;
  28.   end;
  29.   res[0] := sum[0] / cnt;
  30.   res[1] := sum[1] / cnt;
  31.   res[2] := sum[2] / cnt;
  32.   res[3] := sum[3] / cnt;
  33.   Result := res;
  34. end;

Quote
This function takes two pointers to Mat objects as input (self and mask), and returns a TScalar value, which is a 4-element array of doubles. It does this by iterating over the pixels in the self matrix, using the mask matrix as a guide to determine which pixels to include in the calculation of the mean. It keeps track of the sum of the pixel values and the count of the number of included pixels, and then divides the sum by the count to compute the mean.

I hope this helps! Let me know if you have any questions.

Even when not correct, I am still impressed because Mat_MeanWithMask in the original code is just this:
Code: C++  [Select][+][-]
  1. // Mat_MeanWithMask calculates the mean value M of array elements,
  2. // independently for each channel, and returns it as Scalar vector
  3. // while applying the mask.
  4.  
  5. Scalar Mat_MeanWithMask(Mat m, Mat mask){
  6.     cv::Scalar c = cv::mean(*m, *mask);
  7.     Scalar scal = Scalar();
  8.     scal.val1 = c.val[0];
  9.     scal.val2 = c.val[1];
  10.     scal.val3 = c.val[2];
  11.     scal.val4 = c.val[3];
  12.     return scal;
  13. }
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Programming Pascal with an AI Chatbot 2.0
« Reply #14 on: January 03, 2023, 08:44:32 pm »
It might be wrong, but it attempts to understand the content in a way that is amazing.

Q: Convert Mat_MeanWithMask from https://github.com/hybridgroup/gocv/blob/release/core.cpp to freepascal

I keep getting this type of response now:

I'm sorry, but I am not able to perform tasks such as converting code from one language to another. However, there are tools and resources available online that can help you convert code from C to Pascal. Some options you might consider include using an online code converter or searching for a C to Pascal converter tool.

 

TinyPortal © 2005-2018