Recent

Author Topic: libqt6pas and ChatGPT  (Read 3200 times)

Bogen85

  • Hero Member
  • *****
  • Posts: 612
libqt6pas and ChatGPT
« on: January 06, 2023, 09:29:24 pm »
libqt6pas is working great on Linux.

I can even get ChatGPT to write simple gui apps for free pascal using it, and some of them compile and run as is without modification.

I say "some" because each time you ask it might produce different code, which does not always compile or work.

Code: Pascal  [Select][+][-]
  1. I need a Qt6 graphical hello world in free pascal.
  2. Requirements:
  3. - It will use the qt6 unit
  4. - The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
  5. qt62.pas
  6. - All literal strings must be explicity declared as WideString variables.
  7. - Declared variable names must be prefixed with _
  8. - Address of WideString variables must be used in function calls.
  9. - Everything created must be destroyed.
  10. - Constants must be declared before they are used before variables.
  11. - QApplication_exec does not take an argument.
  12. - Needs objfpc directive.
  13.  

Which produces this:

Code: Pascal  [Select][+][-]
  1. program HelloWorld;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   qt6;
  7.  
  8. var
  9.   _app : QApplicationH;
  10.   _window : QWidgetH;
  11.   _helloWorld : WideString;
  12.  
  13. begin
  14.   _helloWorld := 'Hello World!';
  15.   _app := QApplication_create(@argc, @argv);
  16.   _window := QWidget_create();
  17.   QWidget_setWindowTitle(_window, @_helloWorld);
  18.   QWidget_show(_window);
  19.   QApplication_exec();
  20.   QWidget_destroy(_window);
  21.   QApplication_destroy(_app);
  22. end.
  23.  

Which compiles and runs...

It does not understand how to do event handlers correctly, but it makes an attempt when you say things like this:

Code: Pascal  [Select][+][-]
  1. I need a Qt6 graphical hello world in free pascal.
  2. Requirements:
  3. - It will use the qt6 unit
  4. - The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
  5. qt62.pas
  6. - All literal strings must be explicity declared as WideString variables.
  7. - A text edit will be created in the main window.
  8. - A procedure named 'what' that prints 'how' will be created.
  9. - When a key is pressed in the text edit the procedure 'what' will be called.
  10. - Declared variable names must be prefixed with _
  11. - Address of WideString variables must be used in function calls.
  12. - Everything created must be destroyed.
  13. - Constants must be declared before they are used before variables.
  14. - QApplication_exec does not take an argument.
  15. - Needs objfpc directive.
  16.  

So ChatGPT can't really handle event handlers or filters correctly for libqt6pas.

Those are not hard to do in Free Pascal with libqt6pas using QAbstractButton_hook_hook_*  QObject_hook_hook_events and the like though.
"teaching" ChatGPT to do those things correctly would take some patience...

But any ways, ChatGPT can do some simple things with free pascal and libqt6pas.

Here is the funny thing though, if you make the following request, it produces code that won't work.


Code: Pascal  [Select][+][-]
  1. // @2023-01-06 14:25:27 CST [Sent]
  2. // Show me a graphical hello world using Free Pascal and qt6.
  3. // @2023-01-06 14:25:34 CST [Received]
  4. // This example uses the qt6 library to create a graphical hello world program using Free Pascal.
  5. program HelloWorld;
  6.  
  7. {$mode objfpc}{$H+}
  8.  
  9. uses
  10.   qtwidgets, qtobjects, qtgui;
  11.  
  12. var
  13.   Wnd: QWidgetH;
  14.   Btn: QPushButtonH;
  15.  
  16. begin
  17.   Wnd := QWidget_Create(nil);
  18.   try
  19.     QWidget_SetWindowTitle(Wnd, 'Hello World');
  20.     Btn := QPushButton_Create(Wnd);
  21.     try
  22.       QPushButton_SetText(Btn, 'Hello World');
  23.       QWidget_SetGeometry(Btn, 10, 10, 100, 30);
  24.       QWidget_Show(Btn);
  25.     finally
  26.       QWidget_Destroy(Btn);
  27.     end;
  28.     QApplication_Exec;
  29.   finally
  30.     QWidget_Destroy(Wnd);
  31.   end;
  32. end.
  33.  
« Last Edit: January 07, 2023, 02:32:53 am by Bogen85 »

Bogen85

  • Hero Member
  • *****
  • Posts: 612
Re: libqt6pas and ChatGPT
« Reply #1 on: January 06, 2023, 09:31:17 pm »
I had to say this:
Quote
Declared variable names must be prefixed with _

Because Chat GPT was creating variable names that are free pascal keywords.

Thaddy

  • Hero Member
  • *****
  • Posts: 15639
  • Censorship about opinions does not belong here.
Re: libqt6pas and ChatGPT
« Reply #2 on: January 07, 2023, 06:30:23 am »
You can add  ". Variable names must not be type names or keywords." to the request.
I ran into the same issue.
« Last Edit: January 07, 2023, 07:14:37 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Bogen85

  • Hero Member
  • *****
  • Posts: 612
Re: libqt6pas and ChatGPT
« Reply #3 on: January 16, 2023, 02:56:10 am »
As far as ChatGPT's ability to read current websites...

Quote
Requirements:
- It will use the qt6 unit
- The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
qt62.pas

Even when this I have doubts about that actually understands or has read anything from there.
It appears to have done so, because without using that, the results are incorrect.

However, it will often provide code that refers to things not part of the binding. They look syntactically correct and are referring to things part of q6, but they binding does not have them.

So, I'm not 100% what it is doing. It may possible it assimilated libqt5pas related material from 2019 and prior.

The "success" I've had getting GPT text davinci 3 to use updated material has been spotty at best. And when it has appeared to work, I'm just not completely sure if it was indeed reading the new material.

For documentation pages intended for human, yes. For actual code, no.

 
« Last Edit: January 16, 2023, 03:56:13 am by Bogen85 »

PierceNg

  • Sr. Member
  • ****
  • Posts: 386
    • SamadhiWeb
Re: libqt6pas and ChatGPT
« Reply #4 on: January 16, 2023, 03:35:55 am »
Having seen a few programs written by this AI, is there anything particularly standing out to you with regards to its code formatting style?

For Pascal especially for if-then-begin-end-else-begin-end human programmers have all kinds of styles. Does this bot look like it has one consistent style or more like it switches between different styles (presumably based on what source material it is recalling)? 

Bogen85

  • Hero Member
  • *****
  • Posts: 612
Re: libqt6pas and ChatGPT
« Reply #5 on: January 16, 2023, 03:54:21 am »
Having seen a few programs written by this AI, is there anything particularly standing out to you with regards to its code formatting style?

For Pascal especially for if-then-begin-end-else-begin-end human programmers have all kinds of styles. Does this bot look like it has one consistent style or more like it switches between different styles (presumably based on what source material it is recalling)?

From what I've see it appears to be consistent as to style, when the code is correct. I have seen that often leaves out (not every time though) the begin..end around a multi line if block that is followed by an else.

It somehow sometimes thinks that everything between the then and the else is part of the then.

I've not actually paid much attention there. Anything I consider useful I run though JCF.

But useful is not easy....anything trivial, no point in asking for it from an AI.

Anything complex I see most as an idea about how to approach it, and so far the few things it has made for me that were correct or close to being correct I completely refactored into something I could actually use and maintain.


zeljko

  • Hero Member
  • *****
  • Posts: 1642
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: libqt6pas and ChatGPT
« Reply #6 on: January 16, 2023, 08:45:03 am »
I've tested few weeks ago for events: Write event for textChanged hook

MarkMLl

  • Hero Member
  • *****
  • Posts: 7617
Re: libqt6pas and ChatGPT
« Reply #7 on: January 16, 2023, 11:36:54 am »
From what I've see it appears to be consistent as to style, when the code is correct. I have seen that often leaves out (not every time though) the begin..end around a multi line if block that is followed by an else.

It somehow sometimes thinks that everything between the then and the else is part of the then.

...which is the style adopted by later Wirth languages (Modula-2 and onwards), Ada, ALGOL-68, VHDL etc. as opposed to Pascal, C, ALGOL-W and older. I think that illustrates an interesting limitation to its "understanding" of what's being asked: why is it favouring the less-popular languages (Ada etc.) at the expense of the most popular (Pascal) which almost certainly has the most code examples floating around?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Jiyahana

  • New Member
  • *
  • Posts: 11
Re: libqt6pas and ChatGPT
« Reply #8 on: July 09, 2024, 11:41:03 pm »
As far as ChatGPT's ability to read current websites...

Quote
Requirements:
- It will use the qt6 unit
- The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
qt62.pas

Even when this I have doubts about that actually understands or has read anything from there.
It appears to have done so, because without using that, the results are incorrect.

However, it will often provide code that refers to things not part of the binding. They look syntactically correct and are referring to things part of q6, but they binding does not have them.

So, I'm not 100% what it is doing. It may possible it assimilated libqt5pas related material from 2019 and prior.

The "success" I've had getting GPT text davinci 3 to use updated material has been spotty at best. And when it has appeared to work, I'm just not completely sure if it was indeed reading the new material.

For documentation pages intended for human, yes. For actual code, no.



ChatGPT can't read current websites in real-time. It works with information up to its last update and can't fetch new data from the web or specific URLs while talking to you. This means it can make code that looks right but might not be accurate with new libraries like libqt6pas. It might know older stuff like libqt5pas, but not the latest updates.
ChatGPT can make code based on what you tell it, but if the code has mistakes or wrong references, it's because the info it has is old or incomplete. So, you need to check and fix the code yourself to make sure it's right.
Also, if you use content from GPT directly on your blog, your ranking might drop. I've seen this happen in my six-month journey with a GPT-made website. Google seems to detect AI content and penalizes the page ranking. Now, I use an AI humanizer tool to avoid detection, and my ranking has improved.

Jiyahana

  • New Member
  • *
  • Posts: 11
Re: libqt6pas and ChatGPT
« Reply #9 on: September 14, 2024, 10:35:37 am »
As far as ChatGPT's ability to read current websites...

Quote
Requirements:
- It will use the qt6 unit
- The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
qt62.pas

Even when this I have doubts about that actually understands or has read anything from there.
It appears to have done so, because without using that, the results are incorrect.

However, it will often provide code that refers to things not part of the binding. They look syntactically correct and are referring to things part of q6, but they binding does not have them.

So, I'm not 100% what it is doing. It may possible it assimilated libqt5pas related material from 2019 and prior.

The "success" I've had getting GPT text davinci 3 to use updated material has been spotty at best. And when it has appeared to work, I'm just not completely sure if it was indeed reading the new material.

For documentation pages intended for human, yes. For actual code, no.



ChatGPT can't read current websites in real-time. It works with information up to its last update and can't fetch new data from the web or specific URLs while talking to you. This means it can make code that looks right but might not be accurate with new libraries like libqt6pas. It might know older stuff like libqt5pas, but not the latest updates.
ChatGPT can make code based on what you tell it, but if the code has mistakes or wrong references, it's because the info it has is old or incomplete. So, you need to check and fix the code yourself to make sure it's right.
Also, if you use content from GPT directly on your blog, your ranking might drop. I've seen this happen in my six-month journey with a GPT-made website. Google seems to detect AI content and penalizes the page ranking. Now, I use an AI humanizer tool like https://texthumanizer.ai/ to avoid detection, and my ranking has improved.

Bogen85

  • Hero Member
  • *****
  • Posts: 612
Re: libqt6pas and ChatGPT
« Reply #10 on: September 15, 2024, 02:21:26 am »
ChatGPT can't read current websites in real-time. It works with information up to its last update and can't fetch new data from the web or specific URLs while talking to you. This means it can make code that looks right but might not be accurate with new libraries like libqt6pas. It might know older stuff like libqt5pas, but not the latest updates.
ChatGPT can make code based on what you tell it, but if the code has mistakes or wrong references, it's because the info it has is old or incomplete. So, you need to check and fix the code yourself to make sure it's right.
Also, if you use content from GPT directly on your blog, your ranking might drop. I've seen this happen in my six-month journey with a GPT-made website. Google seems to detect AI content and penalizes the page ranking. Now, I use an AI humanizer tool to avoid detection, and my ranking has improved.

I'm aware of all that. I don't use AI generated content for anything other (at this point) than getting over the hump on something and having it analyze a section of code, or give me some ideas on something.

Also, you replied to a post from January of 2023, not that there is anything wrong with that...

 

TinyPortal © 2005-2018