ChatGPT responses to actual code

For everything that's not in any way related to PureBasic. General chat etc...
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: ChatGPT responses to actual code

Post by Bitblazer »

BarryG wrote: Sat Jan 21, 2023 12:15 pm But they've said they don't use search engines (Googling, Binging, etc). So why do you assert that they do? That's what I don't get.
That's just a minor technicality to me. Let's say they use the same data "in general", but collect it with their own scraping tools instead of using search engine API's - big whoop ;)

Technically i would use my own scraping and parsing and database technology too. Especially the data access for natural language processing likely makes that necessary.

Anyway, the real problem with chatGPT is not the data or storage technology, but that it currently can't be easily verified why it gives a specific answer and which data sources it actually processed. That makes it often (currently) be as useful as an idiot and there are plenty examples where chatGPT vigorously defends complete nonsense or even dangerous replies. It is a very stubborn idiot to me currently ;)

The same is valid for the methods how to trick it into giving answers it should not give (like how to build bombs).
webpage - discord chat links -> purebasic GPT4All
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ChatGPT responses to actual code

Post by BarryG »

Bitblazer wrote: Sat Jan 21, 2023 12:17 pm[they] collect it with their own scraping tools instead of using search engine API's - big whoop
But the developers say it doesn't access the internet at all, so scraping would be impossible. How does it know the answer if it doesn't access the internet and couldn't scrape it? The below code is from one of my own apps, which is NOT available online to scrape, and ChatGPT described what it does perfectly - in plain English and right down to mentioning milliseconds when there's no clue to that being the unit of time.

Image
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: ChatGPT responses to actual code

Post by Bitblazer »

BarryG wrote: Sat Jan 21, 2023 12:33 pm But the developers say it doesn't access the internet at all, so scraping would be impossible.


That is scraping to me. They just "outsourced" it ;)

But ok - i don't know how they exactly use that data. But i have seen several chatGPT responses or communications that clearly show the use of stuff like wikipedia data.
webpage - discord chat links -> purebasic GPT4All
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ChatGPT responses to actual code

Post by BarryG »

Okay, thanks - that's made it clear, then! The FAQ that I quoted left that out (probably on purpose to mislead). Thanks for patiently explaining it to me.
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

Re: ChatGPT responses to actual code

Post by Tenaja »

Bitblazer wrote: Sat Jan 21, 2023 12:09 pm
BarryG wrote: Sat Jan 21, 2023 11:23 am Not according to the FAQ -> https://help.openai.com/en/articles/682 ... ow-about-x

Quote: "[ChatGPT] cannot access the internet, search engines, databases, or any other sources of information outside of its own model."
They already work on "live searches" (aka googling ;) - yes basically it is done by interfacing with a bunch of search engine API's, but that is just an implementation detail and might make it less responsive ..., but thats just a minor technicality to me, like the natural language interface that a tech mag already did - for the show effect).
"Outside of it's own model" is the key phrase. They build the model by scraping the internet in the background, and when you ask a question, it doesn't access the internet at that second, because it's already built a model it uses.

But by tomorrow, the model is updated because it's doing it in the background. At least, that's my presumption, based on the language used and what makes sense. (Otherwise, it could not add new information.)
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: ChatGPT responses to actual code

Post by jacdelad »

Barry, Chat-GPT has already proven to cite googled stuff, give sources that don't exist and not even learn from its own errors (repeats them a few minutes after being corrected, even though the bot confirmed the correction). It is not an AI nor even close. I can give you a link to a trustworthy computer experts site, but it's in German.
About what the developers say...what do you want to hear? Tesla promotes it's "self-driving" feature, but in reality it's far from that. Every company points out the good sides and covers the bad ones. That's why there's too much sugar in our food and tobacco companies still sell their stuff. And people still think cryptocurrencies are the future...it's all a scam.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: ChatGPT responses to actual code

Post by Mijikai »

Chat-GPT is there to collect data.
It basically sets you up for exploitation.
Tell me all your needs and wants, rest assured i act in you interest. 8)
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ChatGPT responses to actual code

Post by BarryG »

Okay, relax - I already thanked Bitblazer above for explaining more info about it with a link. Don't shoot me anymore, lol.
User avatar
tj1010
Enthusiast
Enthusiast
Posts: 623
Joined: Mon Feb 25, 2013 5:51 pm
Location: US or Estonia
Contact:

Re: [Solved] ChatGPT responses to actual code

Post by tj1010 »

I made it parse DirectX DDS and RTSP, so it does do full protocol and algorithm stuff if you stage questions right.. Here are some random tests for PB.


Code: Select all

;CCTV motion detection
; Load the directory path where the images are stored
image_path$ = "C:\path\to\images\"

; Load the list of jpg files in the directory
image_files$ = Dir$(image_path$ + "*.jpg")

; Initialize the variables
prev_image = 0
threshold = 0.1

; Loop through each image file
For i = 0 To NumberOfElements(image_files$) - 1
    ; Load the current image
    curr_image = LoadImage(image_path$ + image_files$[i])

    ; If this is not the first image, compare it with the previous image
    If prev_image <> 0
        diff_pixels = 0
        For x = 0 To ImageWidth(curr_image) - 1
            For y = 0 To ImageHeight(curr_image) - 1
                curr_pixel = GetPixel(curr_image, x, y)
                prev_pixel = GetPixel(prev_image, x, y)
                diff = Abs(curr_pixel - prev_pixel)
                If diff > threshold
                    diff_pixels = diff_pixels + 1
                EndIf
            Next
        Next

        ; If there are changed pixels, display the filename
        If diff_pixels > 0
            Debug "Motion detected in " + image_files$[i]
        EndIf
    EndIf

    ; Store the current image as the previous image for the next iteration
    prev_image = curr_image
Next



Code: Select all

; --- Example of using PB_Crypto library to encrypt and decrypt a string with ChaCha20 ---

; Load the PB_Crypto library
If OpenLibrary(#PB_Any, "PB_Crypto.pb", 0) = 0
  MessageRequester("Error", "Could not load PB_Crypto library!", 0)
  End
EndIf

; Define the key and nonce
Global Key.s = "0123456789ABCDEF0123456789ABCDEF"  ; 256-bit key
Global Nonce.s = "01234567"                       ; 64-bit nonce

; Define the plaintext string to be encrypted
Global Plaintext.s = "This is a test string to be encrypted with ChaCha20."

; Encrypt the plaintext string
Global Ciphertext.s = PB_Crypto_ChaCha20_Encrypt(Plaintext, Key, Nonce)

; Print the encrypted ciphertext
PrintN("Ciphertext: " + Ciphertext)

; Decrypt the ciphertext string
Global DecryptedPlaintext.s = PB_Crypto_ChaCha20_Decrypt(Ciphertext, Key, Nonce)

; Print the decrypted plaintext
PrintN("Decrypted plaintext: " + DecryptedPlaintext)

; Unload the PB_Crypto library
CloseLibrary(0)


Code: Select all

;manually load a exe
; Define the path to the executable file
Define ExePath$ = "C:\Path\To\Executable.exe"

; Open the file and read it into a buffer
Protected ExeData.i, ExeSize.i
OpenFile(ExePath$, #PB_Open_Read | #PB_Open_Binary)
ExeSize = FileSize(ExePath$)
AllocateMemory(ExeData, ExeSize)
ReadFile(ExePath$, ExeData, ExeSize)
CloseFile(ExePath$)

; Get the DOS header
Protected DosHeader.s = PeekS(ExeData, 0)

; Get the offset of the NT headers
Protected NtHeaderOffset.i = PeekL(ExeData, 0x3C)

; Get the NT header
Protected NtHeader.s = PeekS(ExeData, NtHeaderOffset)

; Get the entry point address
Protected EntryPoint.i = PeekL(ExeData, NtHeaderOffset + 0x28)

; Jump to the entry point
CallFunction(ExeData + EntryPoint)

Code: Select all

;Simple PE section compresn in PureBasic
; This program compresses the code section of a PE file and creates a new compressed PE file that can still be executed.

; Define constants
Enumeration
    MAX_PATH = 260
    BUF_SIZE = 8192
EndEnumeration

; Declare variables
Protected inPath.s, outPath.s, inFile.s, outFile.s
Protected inHandle.i, outHandle.i
Protected fileSize.i, bytesRead.i, bytesWritten.i
Protected buffer.i, compressedBuffer.i, compressedSize.i
Protected i.i, codeSize.i, compressedCodeSize.i, compressedCodeOffset.i
Protected entryPoint.i, decompressedCodeOffset.i

; Get the input file path
inPath = RequestFile("Select input file", "", "", #PB_FileRequest_ExistingFile)
If inPath = ""
    Debug "No input file selected"
    End
EndIf

; Open the input file for reading
inHandle = OpenFile(inPath, #PB_File_Read)
If inHandle = 0
    Debug "Could not open input file"
    End
EndIf

; Get the input file size
fileSize = FileSize(inHandle)

; Read the input file into a buffer
buffer = AllocateMemory(BUF_SIZE)
Do
    bytesRead = ReadBytes(inHandle, buffer, BUF_SIZE)
Until bytesRead = 0

; Find the code section in the input file
For i = 0 To fileSize - 4
    If PeekL(buffer + i) = &H4065632E ; "e.c@"
        codeSize = PeekL(buffer + i + 8)
        compressedBuffer = AllocateMemory(codeSize)
        compressedCodeOffset = i + 24
        compressedCodeSize = CompressLZ77(buffer + compressedCodeOffset, compressedBuffer, codeSize)
        Exit
    EndIf
Next

If codeSize = 0
    Debug "Could not find code section in input file"
    End
EndIf

; Set the entry point to the original entry point of the input file
entryPoint = PeekL(buffer + 40)

; Get the output file path
outPath = RequestFile("Select output file", "", "", #PB_FileRequest_Save)
If outPath = ""
    Debug "No output file selected"
    End
EndIf

; Open the output file for writing
outHandle = OpenFile(outPath, #PB_File_Write)
If outHandle = 0
    Debug "Could not open output file"
    End
EndIf

; Write the input file header to the output file
inFile = ExtractFilename(inPath)
bytesRead = BUF_SIZE
While bytesRead = BUF_SIZE
    bytesRead = ReadBytes(inHandle, buffer, BUF_SIZE)
    bytesWritten = WriteBytes(outHandle, buffer, bytesRead)
Wend

; Write the decompression routine to the output file
decompressedCodeOffset = fileSize + compressedCodeSize
bytesWritten = WriteBytes(outHandle, "B9" + Hex(entryPoint, 8) + "E9" + Hex(decompressedCodeOffset - entryPoint - 5, 8))
If bytesWritten <> 5
    Debug "Error writing to output file"
    End
EndIf

; Write the compressed code section to the output file
bytesWritten = WriteBytes(outHandle, compressedBuffer, compressedCodeSize)
If bytesWritten <> compressedCodeSize
    Debug "Error writing to output file"
    End
EndIf

; Write the rest of the input file to the output file
Do
   

Code: Select all

;Neural network 
; Declare constants
HiddenLayerSize = 4
InputSize = 2
OutputSize = 1
LearningRate = 0.5

; Declare variables
input[InputSize]
hiddenLayer[HiddenLayerSize]
output[OutputSize]
hiddenWeights[InputSize, HiddenLayerSize]
outputWeights[HiddenLayerSize, OutputSize]

; Initialize weights randomly
For i = 0 To InputSize - 1
  For j = 0 To HiddenLayerSize - 1
    hiddenWeights[i, j] = Random(0, 1)
  Next
Next

For i = 0 To HiddenLayerSize - 1
  For j = 0 To OutputSize - 1
    outputWeights[i, j] = Random(0, 1)
  Next
Next

; Declare activation function (sigmoid)
Function Sigmoid(x.f)
  Return 1 / (1 + Exp(-x))
EndFunction

; Declare training function
Procedure TrainNetwork(targetOutput.f)
  ; Calculate output of hidden layer
  For i = 0 To HiddenLayerSize - 1
    hiddenLayer[i] = 0
    For j = 0 To InputSize - 1
      hiddenLayer[i] += input[j] * hiddenWeights[j, i]
    Next
    hiddenLayer[i] = Sigmoid(hiddenLayer[i])
  Next
  
  ; Calculate output of output layer
  For i = 0 To OutputSize - 1
    output[i] = 0
    For j = 0 To HiddenLayerSize - 1
      output[i] += hiddenLayer[j] * outputWeights[j, i]
    Next
    output[i] = Sigmoid(output[i])
  Next
  
  ; Calculate error and adjust weights
  outputError = targetOutput - output[0]
  
  For i = 0 To HiddenLayerSize - 1
    hiddenError = outputError * outputWeights[i, 0] * hiddenLayer[i] * (1 - hiddenLayer[i])
    For j = 0 To InputSize - 1
      hiddenWeights[j, i] += LearningRate * hiddenError * input[j]
    Next
    outputWeights[i, 0] += LearningRate * outputError * hiddenLayer[i]
  Next
EndProcedure

; Train the network on some example inputs and target outputs
For i = 1 To 10000
  input[0] = 0
  input[1] = 0
  TrainNetwork(0)
  
  input[0] = 0
  input[1] = 1
  TrainNetwork(1)
  
  input[0] = 1
  input[1] = 0
  TrainNetwork(1)
  
  input[0] = 1
  input[1] = 1
  TrainNetwork(0)
Next

; Test the network on some example inputs
input[0] = 0
input[1] = 0
TrainNetwork(0)
Debug output[0]

input[0] = 0
input[1] = 1
TrainNetwork(1)
Debug output[0]

input[0] = 1
input[1] = 0
TrainNetwork(1)
Debug output[0]

input[0] = 1
input[1] = 1
TrainNetwork(0)
Debug output[0]

Code: Select all

;RNN
; Declare constants
NumInputs = 2
NumHidden = 4
NumOutputs = 1
LearningRate = 0.1

; Declare variables
input[NumInputs]
hidden[NumHidden]
output[NumOutputs]
hiddenWeights[NumHidden, NumHidden + NumInputs]
outputWeights[NumOutputs, NumHidden]

; Initialize weights randomly
For i = 0 To NumHidden - 1
  For j = 0 To NumHidden + NumInputs - 1
    hiddenWeights[i, j] = Random(0, 1)
  Next
Next

For i = 0 To NumOutputs - 1
  For j = 0 To NumHidden - 1
    outputWeights[i, j] = Random(0, 1)
  Next
Next

; Declare activation function (sigmoid)
Function Sigmoid(x.f)
  Return 1 / (1 + Exp(-x))
EndFunction

; Declare training function
Procedure TrainNetwork(targetOutput.f)
  ; Calculate output of hidden layer
  For i = 0 To NumHidden - 1
    hidden[i] = 0
    For j = 0 To NumInputs - 1
      hidden[i] += input[j] * hiddenWeights[i, j]
    Next
    For j = 0 To NumHidden - 1
      hidden[i] += hidden[j] * hiddenWeights[i, j + NumInputs]
    Next
    hidden[i] = Sigmoid(hidden[i])
  Next
  
  ; Calculate output of output layer
  For i = 0 To NumOutputs - 1
    output[i] = 0
    For j = 0 To NumHidden - 1
      output[i] += hidden[j] * outputWeights[i, j]
    Next
    output[i] = Sigmoid(output[i])
  Next
  
  ; Calculate error and adjust weights
  outputError = targetOutput - output[0]
  
  For i = 0 To NumOutputs - 1
    For j = 0 To NumHidden - 1
      outputWeights[i, j] += LearningRate * outputError * hidden[j]
    Next
  Next
  
  For i = 0 To NumHidden - 1
    hiddenError = outputError * outputWeights[0, i] * hidden[i] * (1 - hidden[i])
    For j = 0 To NumInputs - 1
      hiddenWeights[i, j] += LearningRate * hiddenError * input[j]
    Next
    For j = 0 To NumHidden - 1
      hiddenWeights[i, j + NumInputs] += LearningRate * hiddenError * hidden[j]
    Next
  Next
  
  ; Update previous hidden layer for next iteration
  previousHidden[] = hidden[]
EndProcedure

; Train the network on some example inputs and target outputs
previousHidden[NumHidden]
For i = 1 To 10000
  input[0] = 0
  input[1] = 0
  TrainNetwork(0)
  
  input[0] = 0
  input[1] = 1
  TrainNetwork(1)
  
  input[0] = 1
  input[1] = 0
  TrainNetwork(1)
  
  input[0] = 1
  input[1] = 1
  TrainNetwork(0)
Next

; Test the network on some example inputs
previousHidden[] = 0
input[0] = 0
input[1] = 0

Code: Select all

;LSTM(used for stock/time-series index predictions)
; Declare constants
NumInputs = 2
NumHidden = 4
NumOutputs = 1
LearningRate = 0.1

; Declare variables
input[NumInputs]
cell[NumHidden]
hidden[NumHidden]
output[NumOutputs]
cellWeights[NumHidden, NumHidden + NumInputs]
hiddenWeights[NumOutputs, NumHidden]
forgetGateWeights[NumHidden, NumHidden + NumInputs]
inputGateWeights[NumHidden, NumHidden + NumInputs]
outputGateWeights[NumHidden, NumHidden + NumInputs]
forgetGate[NumHidden]
inputGate[NumHidden]
outputGate[NumHidden]
cellInput[NumHidden]
cellState[NumHidden]
previousCell[NumHidden]
previousHidden[NumHidden]

; Initialize weights randomly
For i = 0 To NumHidden - 1
  For j = 0 To NumHidden + NumInputs - 1
    cellWeights[i, j] = Random(0, 1)
    forgetGateWeights[i, j] = Random(0, 1)
    inputGateWeights[i, j] = Random(0, 1)
    outputGateWeights[i, j] = Random(0, 1)
  Next
Next

For i = 0 To NumOutputs - 1
  For j = 0 To NumHidden - 1
    hiddenWeights[i, j] = Random(0, 1)
  Next
Next

; Declare activation function (sigmoid)
Function Sigmoid(x.f)
  Return 1 / (1 + Exp(-x))
EndFunction

; Declare activation function (tanh)
Function Tanh(x.f)
  Return (Exp(x) - Exp(-x)) / (Exp(x) + Exp(-x))
EndFunction

; Declare training function
Procedure TrainNetwork(targetOutput.f)
  ; Calculate output of input and forget gates
  For i = 0 To NumHidden - 1
    cellInput[i] = 0
    For j = 0 To NumInputs - 1
      cellInput[i] += input[j] * cellWeights[i, j]
    Next
    For j = 0 To NumHidden - 1
      cellInput[i] += previousHidden[j] * cellWeights[i, j + NumInputs]
    Next
    cellInput[i] = Tanh(cellInput[i])
    
    forgetGate[i] = 0
    For j = 0 To NumInputs - 1
      forgetGate[i] += input[j] * forgetGateWeights[i, j]
    Next
    For j = 0 To NumHidden - 1
      forgetGate[i] += previousHidden[j] * forgetGateWeights[i, j + NumInputs]
    Next
    forgetGate[i] = Sigmoid(forgetGate[i])
  Next
  
  ; Calculate output of input gate
  For i = 0 To NumHidden - 1
    inputGate[i] = 0
    For j = 0 To NumInputs - 1
      inputGate[i] += input[j] * inputGateWeights[i, j]
    Next
    For j = 0 To NumHidden - 1
      inputGate[i] += previousHidden[j] * inputGateWeights[i, j + NumInputs]
    Next
    inputGate[i] = Sigmoid(inputGate[i])
  Next
  
  ; Calculate output of output gate
  For i = 0 To NumHidden - 1
    outputGate[i] = 0
    For j = 0 To NumInputs - 1
      outputGate[i
    outputGate[i] += previousHidden[j] * outputGateWeights[i, j + NumInputs]
  Next
    outputGate[i] = Sigmoid(outputGate[i])
  Next
  
  ; Calculate new cell state
  For i = 0 To NumHidden - 1
    cellState[i] = forgetGate[i] * previousCell[i] + inputGate[i] * cellInput[i]
  Next
  
  ; Calculate new hidden state and output
  For i = 0 To NumOutputs - 1
    For j = 0 To NumHidden - 1
      hidden[j] = Sigmoid(cellState[j]) * outputGate[j]
      output[i] = 0
      For k = 0 To NumHidden - 1
        output[i] += hidden[k] * hiddenWeights[i, k]
      Next
    Next
  Next
  
  ; Calculate error
  error = targetOutput - output[0]
  
  ; Update weights
  For i = 0 To NumHidden - 1
    For j = 0 To NumInputs - 1
      cellWeights[i, j] += LearningRate * error * hiddenWeights[0, i] * outputGate[i] * (1 - Tanh(cellInput[i]) ^ 2) * input[j]
      forgetGateWeights[i, j] += LearningRate * error * hiddenWeights[0, i] * previousCell[i] * forgetGate[i] * (1 - forgetGate[i]) * input[j]
      inputGateWeights[i, j] += LearningRate * error * hiddenWeights[0, i] * cellInput[i] * inputGate[i] * (1 - inputGate[i]) * input[j]
      outputGateWeights[i, j] += LearningRate * error * hiddenWeights[0, i] * Sigmoid(cellState[i]) * outputGate[i] * (1 - outputGate[i]) * input[j]
    Next
    For j = 0 To NumHidden - 1
      cellWeights[i, j + NumInputs] += LearningRate * error * hiddenWeights[0, i] * outputGate[i] * (1 - Tanh(cellInput[i]) ^ 2) * previousHidden[j]
      forgetGateWeights[i, j + NumInputs] += LearningRate * error * hiddenWeights[0, i] * previousCell[i] * forgetGate[i] * (1 - forgetGate[i]) * previousHidden[j]
      inputGateWeights[i, j + NumInputs] += LearningRate * error * hiddenWeights[0, i] * cellInput[i] * inputGate[i] * (1 - inputGate[i]) * previousHidden[j]
      outputGateWeights[i, j + NumInputs] += LearningRate * error * hiddenWeights[0, i] * Sigmoid(cellState[i]) * outputGate[i] * (1 - outputGate[i]) * previousHidden[j]
    Next
  Next
  
  For i = 0 To NumOutputs - 1
    For j = 0 To NumHidden - 1
      hiddenWeights[i, j] += LearningRate * error * hidden[j]
    Next
  Next
  
  ; Update previous cell and hidden states
  For i = 0 To NumHidden - 1
    previousCell[i] = cellState[i]
    previousHidden[i] = hidden[i]
  Next
EndProcedure
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: [Solved] ChatGPT responses to actual code

Post by Caronte3D »

All wrong, right? :lol:
User avatar
tj1010
Enthusiast
Enthusiast
Posts: 623
Joined: Mon Feb 25, 2013 5:51 pm
Location: US or Estonia
Contact:

Re: [Solved] ChatGPT responses to actual code

Post by tj1010 »

Caronte3D wrote: Wed Feb 15, 2023 10:00 am All wrong, right? :lol:
  • Syntax errors about every 5 lines
  • Powerful functions it doesn't declare, and when you ask it to it's got the same problems as the rest of the code
  • It doesn't get core syntax naming right
  • Actual code flow is usually broken
  • About the ONLY use of it is to get a very-rough idea of an algorithm or protocol
  • Begs to question... If it can't get clearly defined primitive stuff right how accurate can it be with social sciences and multi-stage mathematics?
The truth hurts.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: [Solved] ChatGPT responses to actual code

Post by Lunasole »

How do you like my code, CommunistGPT :)
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Solved] ChatGPT responses to actual code

Post by Fred »

Indeed it's far from perfect but it's not bad for a fully generated code (ie: not copy/paste from actual code) for a not mainstream language and it will probably improve very quickly. I did some tests as well, and I was surprised to see the results and the explanation of each lines. For example, I just asked 'Can you generate a source code for calculator program in PureBasic ?' and here is the result:

Code: Select all

; Calculator Program in PureBasic

; Declare variables
Global num1, num2, result As Float
Global operator As String

; Get user input
InputRequest("Enter first number: ", "", num1)
InputRequest("Enter second number: ", "", num2)
InputRequest("Enter operator (+, -, *, /): ", "", operator)

; Perform calculation based on operator input
Select operator
  Case "+"
    result = num1 + num2
  Case "-"
    result = num1 - num2
  Case "*"
    result = num1 * num2
  Case "/"
    result = num1 / num2
  Default
    MessageRequester("Error", "Invalid operator entered.", #PB_MessageRequester_OK)
EndSelect

; Display result
MessageRequester("Result", "The answer is: " + Str(result), #PB_MessageRequester_OK)
It doesn't compile but it's not completely wrong as well.
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: [Solved] ChatGPT responses to actual code

Post by Caronte3D »

I think exists a way to feed ChatGPT through API. Would be awesome if the whole PB forum feed it
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: [Solved] ChatGPT responses to actual code

Post by NicTheQuick »

There is no way to feed ChatGPT. That would be very dumb. We all know what happens if you let an AI learn from anonymous person. It takes a day or two and then the AI becomes a women-hating racist.

That being said, I don't understand what you all expect from ChatGPT here. Of course it is not better at programming a niche programming language than you are here. But it is and remains fascinating that Purebasic has made it so far into its "brain" that it can produce approximately correct code.

And it is also logical that the learning data had to come from somewhere. And of course it came from the internet, but only from selected sources. The entire Internet was not simply scanned wildly and a neural network was trained with it.

Since GPT-4 is out now which is very impressive, I don't think it will need 5 more years to make it nearly perfect. It is already a game changer.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply