Using AI models ? (deepseek and ...)

Everything else that doesn't fall into one of the other PB categories.
User avatar
STARGÅTE
Addict
Addict
Posts: 2231
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Using AI models ? (deepseek and ...)

Post by STARGÅTE »

BarryG wrote: Thu Feb 13, 2025 7:40 am You don't need to pay for a ChatGPT account, if that's stopping you? I use the free version. :)

Screenshots of its answers are below. Note: I had to shrink the zoom level of the last screenshot.
It's not the money, it's the need of a phone number, which stops me.

It is interesting to see that ChatGPT knows the use of the tilde as you can see in the second answer for the double quote, but didn't use it for the third question to enter a line feed ~"\n" directly in the string.
Thanks for your replay
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Using AI models ? (deepseek and ...)

Post by BarryG »

STARGÅTE wrote:It's not the money, it's the need of a phone number, which stops me.
You don't need a phone number to sign up with ChatGPT. I never did, and I just tested it again with a new account using https://10minutemail.com for my email. Just sent me a verification code to the email, then asked my name (just put Barry) and date of birth (just put 01/01/1970). The account was then active.
STARGÅTE wrote:It is interesting to see that ChatGPT knows the use of the tilde as you can see in the second answer for the double quote, but didn't use it for the third question to enter a line feed ~"\n" directly in the string.
Check it out:

Image
tj1010
Enthusiast
Enthusiast
Posts: 716
Joined: Mon Feb 25, 2013 5:51 pm

Re: Using AI models ? (deepseek and ...)

Post by tj1010 »

ShadowStorm wrote: Wed Feb 12, 2025 10:14 pm @tj1010, have you ever used DeepSeek (Deep Think V1)?
Take a look and tell me it's rubbish, just for laughs :mrgreen:

That's a reasoning model, but okay..

DeepSeek V3 R1
Full Output: https://pastebin.com/g3Jz9STT
Code

Code: Select all

; RSA 4096 Encryption/Decryption using Windows CNG in PureBasic

; Constants
#STATUS_SUCCESS = $00000000
#BCRYPT_RSAPUBLIC_BLOB = "RSAPUBLICBLOB"
#BCRYPT_PAD_PKCS1 = 2

; Prototypes for BCrypt functions
Prototype.l BCryptOpenAlgorithmProvider(phAlgorithm, pszAlgId.p-unicode, pszImplementation.p-unicode, dwFlags.l)
Prototype.l BCryptGenerateKeyPair(hAlgorithm, phKey, dwLength.l, dwFlags.l)
Prototype.l BCryptFinalizeKeyPair(hKey, dwFlags.l)
Prototype.l BCryptExportKey(hKey, hExportKey, pszBlobType.p-unicode, pbOutput, cbOutput.l, pcbResult, dwFlags.l)
Prototype.l BCryptImportKey(hAlgorithm, hImportKey, pszBlobType.p-unicode, phKey, pbKeyObject, cbKeyObject.l, pbInput, cbInput.l, dwFlags.l)
Prototype.l BCryptEncrypt(hKey, pbInput, cbInput.l, pPaddingInfo, pbIV, cbIV.l, pbOutput, cbOutput.l, pcbResult, dwFlags.l)
Prototype.l BCryptDecrypt(hKey, pbInput, cbInput.l, pPaddingInfo, pbIV, cbIV.l, pbOutput, cbOutput.l, pcbResult, dwFlags.l)
Prototype.l BCryptCloseAlgorithmProvider(hAlgorithm, dwFlags.l)
Prototype.l BCryptDestroyKey(hKey)

; Load BCrypt library and functions
Global hBCrypt = OpenLibrary(#PB_Any, "bcrypt.dll")
If Not hBCrypt
  MessageRequester("Error", "Failed to load bcrypt.dll")
  End
EndIf

Global BCryptOpenAlgorithmProvider.BCryptOpenAlgorithmProvider = GetFunction(hBCrypt, "BCryptOpenAlgorithmProvider")
Global BCryptGenerateKeyPair.BCryptGenerateKeyPair = GetFunction(hBCrypt, "BCryptGenerateKeyPair")
Global BCryptFinalizeKeyPair.BCryptFinalizeKeyPair = GetFunction(hBCrypt, "BCryptFinalizeKeyPair")
Global BCryptExportKey.BCryptExportKey = GetFunction(hBCrypt, "BCryptExportKey")
Global BCryptImportKey.BCryptImportKey = GetFunction(hBCrypt, "BCryptImportKey")
Global BCryptEncrypt.BCryptEncrypt = GetFunction(hBCrypt, "BCryptEncrypt")
Global BCryptDecrypt.BCryptDecrypt = GetFunction(hBCrypt, "BCryptDecrypt")
Global BCryptCloseAlgorithmProvider.BCryptCloseAlgorithmProvider = GetFunction(hBCrypt, "BCryptCloseAlgorithmProvider")
Global BCryptDestroyKey.BCryptDestroyKey = GetFunction(hBCrypt, "BCryptDestroyKey")

; Validate all functions loaded
If Not BCryptOpenAlgorithmProvider Or Not BCryptGenerateKeyPair Or Not BCryptFinalizeKeyPair Or 
   Not BCryptExportKey Or Not BCryptImportKey Or Not BCryptEncrypt Or Not BCryptDecrypt Or 
   Not BCryptCloseAlgorithmProvider Or Not BCryptDestroyKey
  MessageRequester("Error", "Failed to load BCrypt functions")
  End
EndIf

; Main process
Procedure Main()
  ; Initialize variables
  Protected hAlg, hKey, hPublicKey, result.l, publicKeySize.l, *publicKeyBlob
  Protected plainText$, plainSize.l, *plainData, encryptedSize.l, *encryptedData
  Protected decryptedSize.l, *decryptedData, decryptedText$

  ; 1. Open RSA algorithm provider
  result = BCryptOpenAlgorithmProvider(@hAlg, "RSA", #Null$, 0)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptOpenAlgorithmProvider failed: " + Hex(result))
    ProcedureReturn
  EndIf

  ; 2. Generate 4096-bit RSA key pair
  result = BCryptGenerateKeyPair(hAlg, @hKey, 4096, 0)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptGenerateKeyPair failed: " + Hex(result))
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  ; 3. Finalize key pair
  result = BCryptFinalizeKeyPair(hKey, 0)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptFinalizeKeyPair failed: " + Hex(result))
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  ; 4. Export public key
  result = BCryptExportKey(hKey, 0, #BCRYPT_RSAPUBLIC_BLOB, 0, 0, @publicKeySize, 0)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptExportKey (size) failed: " + Hex(result))
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  *publicKeyBlob = AllocateMemory(publicKeySize)
  result = BCryptExportKey(hKey, 0, #BCRYPT_RSAPUBLIC_BLOB, *publicKeyBlob, publicKeySize, @publicKeySize, 0)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptExportKey failed: " + Hex(result))
    FreeMemory(*publicKeyBlob)
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  ; 5. Import public key
  result = BCryptImportKey(hAlg, 0, #BCRYPT_RSAPUBLIC_BLOB, @hPublicKey, 0, 0, *publicKeyBlob, publicKeySize, 0)
  FreeMemory(*publicKeyBlob)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptImportKey failed: " + Hex(result))
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  ; Prepare plaintext
  plainText$ = "Hello World! This is a secret message."
  plainSize = StringByteLength(plainText$, #PB_UTF8)
  *plainData = AllocateMemory(plainSize)
  PokeS(*plainData, plainText$, -1, #PB_UTF8)

  ; 6. Encrypt data
  result = BCryptEncrypt(hPublicKey, *plainData, plainSize, 0, 0, 0, 0, 0, @encryptedSize, #BCRYPT_PAD_PKCS1)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptEncrypt (size) failed: " + Hex(result))
    FreeMemory(*plainData)
    BCryptDestroyKey(hPublicKey)
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  *encryptedData = AllocateMemory(encryptedSize)
  result = BCryptEncrypt(hPublicKey, *plainData, plainSize, 0, 0, 0, *encryptedData, encryptedSize, @encryptedSize, #BCRYPT_PAD_PKCS1)
  FreeMemory(*plainData)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptEncrypt failed: " + Hex(result))
    FreeMemory(*encryptedData)
    BCryptDestroyKey(hPublicKey)
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  ; 7. Decrypt data
  result = BCryptDecrypt(hKey, *encryptedData, encryptedSize, 0, 0, 0, 0, 0, @decryptedSize, #BCRYPT_PAD_PKCS1)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptDecrypt (size) failed: " + Hex(result))
    FreeMemory(*encryptedData)
    BCryptDestroyKey(hPublicKey)
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  *decryptedData = AllocateMemory(decryptedSize)
  result = BCryptDecrypt(hKey, *encryptedData, encryptedSize, 0, 0, 0, *decryptedData, decryptedSize, @decryptedSize, #BCRYPT_PAD_PKCS1)
  FreeMemory(*encryptedData)
  If result <> #STATUS_SUCCESS
    MessageRequester("Error", "BCryptDecrypt failed: " + Hex(result))
    FreeMemory(*decryptedData)
    BCryptDestroyKey(hPublicKey)
    BCryptDestroyKey(hKey)
    BCryptCloseAlgorithmProvider(hAlg, 0)
    ProcedureReturn
  EndIf

  ; Show results
  decryptedText$ = PeekS(*decryptedData, decryptedSize, #PB_UTF8)
  MessageRequester("Success", "Decrypted text: " + decryptedText$)

  ; Cleanup
  FreeMemory(*decryptedData)
  BCryptDestroyKey(hPublicKey)
  BCryptDestroyKey(hKey)
  BCryptCloseAlgorithmProvider(hAlg, 0)
EndProcedure

Main()
CloseLibrary(hBCrypt)
OMG I'm so obviously wrong..


For my own entertainment
What is deep think v1?
Deep Think V1 is likely an early version or iteration of a deep learning model, AI system, or software designed for advanced data analysis, reasoning, or problem-solving. However, without specific context, it's difficult to provide precise details. It could refer to:

1. **A proprietary AI model**: Developed by a company or research group for tasks like natural language processing, decision-making, or predictive analytics.
2. **A conceptual framework**: A theoretical approach to deep learning or cognitive computing.
3. **A project or product name**: Used in a specific industry or application, such as finance, healthcare, or robotics.

If you have more context or details about Deep Think V1, I can provide a more accurate explanation!
Again, if you're going to grift on the internet make it take longer than five-minutes to see through by anyone with a web browser.. Literally anyone can open another browser-tab and immediately see all the models are unreliable, or just look at any standardized benchmarks; which Grok, OpenAI, DeepSeek, Anthropic themselves frequently share on blogs and social-media, and they -ALL- reflect exactly what I'm saying here; as do interviews with anyone from any of those companies everywhere..
What is illusion in ML?
In machine learning (ML), an **illusion** refers to a situation where a model perceives or generates patterns, features, or outputs that do not actually exist in the data or reality. This can occur due to various reasons, such as overfitting, biases in the training data, or limitations in the model's architecture. Illusions in ML are often unintended and can lead to incorrect or misleading results.

Here are some common examples of illusions in ML:

1. **Overfitting**:
- A model learns noise or irrelevant details in the training data, creating the illusion of patterns that do not generalize to new, unseen data.
- For example, a model might "memorize" random fluctuations in the training data and incorrectly assume they are meaningful.

2. **Adversarial Examples**:
- Small, carefully crafted perturbations in input data can create the illusion of a different class or output. For instance, an image classifier might misclassify a slightly modified image of a panda as a gibbon, even though the change is imperceptible to humans.

3. **Data Bias**:
- If the training data contains biases, the model may learn and perpetuate those biases, creating the illusion that the biased patterns are inherent to the problem. For example, a facial recognition system trained primarily on one demographic might perform poorly on others, creating the illusion that the system is universally accurate.

4. **Hallucinations in Generative Models**:
- Generative models, such as those used in text generation (e.g., GPT) or image synthesis (e.g., GANs), can produce outputs that appear realistic but are factually incorrect or nonsensical. For example, a text generator might produce a coherent-sounding paragraph with false information.

5. **Spurious Correlations**:
- Models might detect and rely on correlations in the training data that are coincidental or irrelevant, creating the illusion of a causal relationship. For example, a model might associate the presence of a certain object in an image with a specific label, even though the object is unrelated to the label.

6. **Optical Illusions in Computer Vision**:
- Models trained on visual data might misinterpret certain patterns or textures, similar to how humans perceive optical illusions. For instance, a model might misclassify an image due to unusual lighting or perspective.

### Addressing Illusions in ML
To mitigate illusions in ML, practitioners can:
- Use regularization techniques to prevent overfitting.
- Employ adversarial training to make models more robust to adversarial examples.
- Ensure diverse and representative training data to reduce biases.
- Validate models on independent datasets to test generalization.
- Use interpretability tools to understand model decisions and identify spurious patterns.

By addressing these issues, ML models can be made more reliable and less prone to creating or relying on illusions.
It might help to learn what a LSTM, RNN, or even MLP are before preaching AI branding hysteria and telling the public what it is and isn't..
User avatar
CDXbow
Enthusiast
Enthusiast
Posts: 100
Joined: Mon Aug 12, 2019 5:32 am
Location: Oz

Re: Using AI models ? (deepseek and ...)

Post by CDXbow »

I haven't tried PB with much success but I noticed the Copilot at Github has got much better with web stuff. It managed to build me a image editor with some special effects. When i tried to do it with one prompt it failed, but when I did it in small steps it succeeded with the odd stumble. Took about half an hour, for me to code that from scratch would take scores of hours. You can see the web app here:
https://teamxbow.web.fc2.com/site/ai-ex ... index.html
You can see the conversation here:
https://github.com/copilot/share/801f02 ... 49a00669dc
Note how polite and encouraging I am. When the silicon overlords take over I want them to remember how kind I was to them when they were just infants. I'll have a go with something similar in PB
User avatar
Kiffi
Addict
Addict
Posts: 1500
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Using AI models ? (deepseek and ...)

Post by Kiffi »

CDXbow wrote: Fri Feb 14, 2025 12:46 pmNote how polite and encouraging I am. When the silicon overlords take over I want them to remember how kind I was to them when they were just infants.
:mrgreen:
Hygge
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: Using AI models ? (deepseek and ...)

Post by ShadowStorm »

Kiffi wrote: Fri Feb 14, 2025 1:32 pm
CDXbow wrote: Fri Feb 14, 2025 12:46 pmNote how polite and encouraging I am. When the silicon overlords take over I want them to remember how kind I was to them when they were just infants.
:mrgreen:
I didn't want to say anything, but since you mentioned it, I agree with you :mrgreen:
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
tj1010
Enthusiast
Enthusiast
Posts: 716
Joined: Mon Feb 25, 2013 5:51 pm

Re: Using AI models ? (deepseek and ...)

Post by tj1010 »

I'm going to be a politically-incorrect/troll/fascist again and point out that all benchmarks are accurate and transformation models are all unreliable. Especially with code-generation, and even more so with languages like PB that have less public code than Python and Javascript.

It's immediately-provable by anyone willing to spend five-minutes in another tab while posting a reply.. I still don't get why there are people on PB forum trying to brand-push these things as copy-paste-robust-code solutions..
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: Using AI models ? (deepseek and ...)

Post by ShadowStorm »

tj1010 wrote: Sat Feb 15, 2025 1:44 am I'm going to be a politically-incorrect/troll/fascist again and point out that all benchmarks are accurate and transformation models are all unreliable. Especially with code-generation, and even more so with languages like PB that have less public code than Python and Javascript.

It's immediately-provable by anyone willing to spend five-minutes in another tab while posting a reply.. I still don't get why there are people on PB forum trying to brand-push these things as copy-paste-robust-code solutions..
Yes, it’s true, you’re right. In general, AIs are still very limited and not always reliable. I agree with this statement without any problem. However, I find that DeepSeek with reasoning performs better than the others. That said, some AIs code much better in certain languages, like Python, because they seem to be developed using that language— at least, that appears to be the case for ChatGPT , it seems.

Best regards.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
CDXbow
Enthusiast
Enthusiast
Posts: 100
Joined: Mon Aug 12, 2019 5:32 am
Location: Oz

Re: Using AI models ? (deepseek and ...)

Post by CDXbow »

Look Ma', no hands.
I did a little experiment with github/copilot, to produce html/js/css apps and not help the ai, see if can produce code all itself. Disappointing describes my previous attempts using prompt generated ai and the ai's have been best called cheerfully incompetent, reminiscent of the elevators of the Sirius Cybernetic Corporation. This time 2 out of 3 worked without me touching the code. It took about 5 hours and to generate, test, deploy, and document. I was pretty happy with the HMTL editor, it's reasonably professional and I can produce css, js and ts clones. The only bit I have touched is the insert tags, as I made a mistake with my request, I asked for ASCII symbols by mistake, when I wanted other symbols. I left the code there and decided to repurpose it to insert tags. Otherwise it all works in a very application like way with code highlighting
HTML Editor - https://teamxbow.web.fc2.com/site/webde ... index.html

I tried a bigger project with node,js that failed dismally and ended stuck in a loop of non working fixes. That was a complete fail. It only took 4 requests to make this small image editor, with filters, resizing, rotation and application like file open and save.
https://teamxbow.web.fc2.com/site/ai-ex ... index.html

Then I tried Purebasic to make a small text editor. I think we got off on the wrong foot, because 25 requests later, it's still not working, stuck in the eternal loop of non working fixes. When I'm feeling patient I will try again with different steps. For PB it really doesn't work well at this time. It's pretty magic when it does with the HTML/JS/CSS. I did make a few 'notes to self' which might help some folks

1. start simple, break it into digestible bits for both you and the ai,
2. don't keep digging the hole deeper, recognise early it's stuffed, restart or roll back to working version.
3. Copilot/gihub is easy to use and currently works well for producing web stuff autonomously.
4. Most problems occurred with the gui in these examples, reflecting it as the site of most complexity

The first big question to me is how do we get the machines to produce better PB code? Posters have alluded to improving training, how do we assist that? If I correct the ai errors to get the code working does that help? Does it learn from my session? Posting on Github must potentially help because most of the references when it tried to fix error were references to it. Also raises the issue of quality of code, if it's mainly learning from github, then how is the quality ensured? What does an ai training pipeline look like for a programming language? So many questions, so liitle time.

I think for Fred and the Devs, and the PB community, the issue of improving the training of the ai's should be a priority. It's necessary first step. Perhaps a community project.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Using AI models ? (deepseek and ...)

Post by BarryG »

CDXbow wrote: Mon Feb 17, 2025 12:54 amI tried Purebasic to make a small text editor. I think we got off on the wrong foot, because 25 requests later, it's still not working
I asked ChatGPT -> using purebasic, create a small text editor app

And it came up with the below. I only had to correct two things: it forgot the file extension when saving the text, and told it that OpenFile() can't be used as a procedure name (which it fixed, but it also fixed SaveFile() automatically to match as well - wow!). I'm impressed that it knew why ("to avoid conflicts with PureBasic's built-in functions") and that code is so cleanly structured. :shock:

Image

Code: Select all

; Simple Text Editor in PureBasic

EnableExplicit
OpenWindow(0, 100, 100, 600, 400, "Simple Text Editor", #PB_Window_SystemMenu | #PB_Window_SizeGadget)

If CreateMenu(0, WindowID(0))
  MenuTitle("File")
  MenuItem(1, "Open")
  MenuItem(2, "Save")
  MenuItem(3, "Exit")
EndIf

EditorGadget(0, 10, 10, 580, 350)

Procedure OpenTextFile()
  Protected file.s
  file = OpenFileRequester("Open a text file", "", "Text files|*.txt|All files|*.*", 0)
  If file
    If ReadFile(0, file)
      SetGadgetText(0, ReadString(0, #PB_File_IgnoreEOL))
      CloseFile(0)
    Else
      MessageRequester("Error", "Unable to open file.")
    EndIf
  EndIf
EndProcedure

Procedure SaveTextFile()
  Protected file.s
  file = SaveFileRequester("Save text file", "*.txt", "Text files|*.txt|All files|*.*", 0)
  If file
    If Right(file, 4) <> ".txt"
      file + ".txt"
    EndIf
    If CreateFile(0, file)
      WriteString(0, GetGadgetText(0))
      CloseFile(0)
    Else
      MessageRequester("Error", "Unable to save file.")
    EndIf
  EndIf
EndProcedure

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Menu
      Select EventMenu()
        Case 1 : OpenTextFile()
        Case 2 : SaveTextFile()
        Case 3 : Break
      EndSelect
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
Quin
Addict
Addict
Posts: 1133
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Using AI models ? (deepseek and ...)

Post by Quin »

BarryG wrote: Mon Feb 17, 2025 1:28 am
CDXbow wrote: Mon Feb 17, 2025 12:54 amI tried Purebasic to make a small text editor. I think we got off on the wrong foot, because 25 requests later, it's still not working
I asked ChatGPT -> using purebasic, create a small text editor app

And it came up with the below. I only had to correct two things: it forgot the file extension when saving the text, and told it that OpenFile() can't be used as a procedure name (which it fixed, but it also fixed SaveFile() automatically to match as well - wow!). I'm impressed that it knew why ("to avoid conflicts with PureBasic's built-in functions") and that code is so cleanly structured. :shock:

Image

Code: Select all

; Simple Text Editor in PureBasic

EnableExplicit
OpenWindow(0, 100, 100, 600, 400, "Simple Text Editor", #PB_Window_SystemMenu | #PB_Window_SizeGadget)

If CreateMenu(0, WindowID(0))
  MenuTitle("File")
  MenuItem(1, "Open")
  MenuItem(2, "Save")
  MenuItem(3, "Exit")
EndIf

EditorGadget(0, 10, 10, 580, 350)

Procedure OpenTextFile()
  Protected file.s
  file = OpenFileRequester("Open a text file", "", "Text files|*.txt|All files|*.*", 0)
  If file
    If ReadFile(0, file)
      SetGadgetText(0, ReadString(0, #PB_File_IgnoreEOL))
      CloseFile(0)
    Else
      MessageRequester("Error", "Unable to open file.")
    EndIf
  EndIf
EndProcedure

Procedure SaveTextFile()
  Protected file.s
  file = SaveFileRequester("Save text file", "*.txt", "Text files|*.txt|All files|*.*", 0)
  If file
    If Right(file, 4) <> ".txt"
      file + ".txt"
    EndIf
    If CreateFile(0, file)
      WriteString(0, GetGadgetText(0))
      CloseFile(0)
    Else
      MessageRequester("Error", "Unable to save file.")
    EndIf
  EndIf
EndProcedure

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Menu
      Select EventMenu()
        Case 1 : OpenTextFile()
        Case 2 : SaveTextFile()
        Case 3 : Break
      EndSelect
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
Well I'll be damned. That's some of the best PB code I've ever seen out of an AI.
And it even used Explicit!
User avatar
CDXbow
Enthusiast
Enthusiast
Posts: 100
Joined: Mon Aug 12, 2019 5:32 am
Location: Oz

Re: Using AI models ? (deepseek and ...)

Post by CDXbow »

Congratulations.
Like I said, I got stuck in a loop in my PB attempt, it was a bit weird because it kept forgetting SaveTextFile(), said it fixed it, but didn't. Remember this was hands off, so not really as you would do it in the real world.
User avatar
Skipper
User
User
Posts: 55
Joined: Thu Dec 19, 2024 1:26 pm
Location: NW-Europe

Re: Using AI models ? (deepseek and ...)

Post by Skipper »

I've been playing with ChatGPT as well. The really simple stuff it can now do in PureBasic, but as soon as requests are added, it starts to 'forget' previous features, even when you explicitly instruct it to merely add the new additional request and retain the old requests. That might be caused by a lack of framing and context from my side, I don't know, I'm new to this. Apparently, prompt engineering is an art...
<< Win-11 (x64) / Mint linux (x64) / MacOS Monterey (x64) >>
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Using AI models ? (deepseek and ...)

Post by BarryG »

Skipper wrote: Mon Feb 17, 2025 4:37 pmit starts to 'forget' previous features, even when you explicitly instruct it to merely add the new additional request and retain the old requests
Hasn't been my experience. Everything I taught it, or corrected it, still works when I go back days later and ask for an example. I don't understand why it differs for you, or why it failed to do a text editor for CDXbow. As you can see, my prompt to create one couldn't be simpler.
Quin
Addict
Addict
Posts: 1133
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Using AI models ? (deepseek and ...)

Post by Quin »

BarryG wrote: Tue Feb 18, 2025 12:41 am
Skipper wrote: Mon Feb 17, 2025 4:37 pmit starts to 'forget' previous features, even when you explicitly instruct it to merely add the new additional request and retain the old requests
Hasn't been my experience. Everything I taught it, or corrected it, still works when I go back days later and ask for an example. I don't understand why it differs for you, or why it failed to do a text editor for CDXbow. As you can see, my prompt to create one couldn't be simpler.
This is the scary and frustrating thing about AI's, they're both unpredictable and inconsistent :(
Post Reply