ChatGPT

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ChatGPT

OmegaKV
It is worth looking at ChatGPT. You have to make an account to use it, but other than that it is free.

I asked it to generate code using a somewhat obscure software library we use for work, and to my surprise it did it. All I had to do was say the library name and what I wanted it to do, which was to write an image processing driver that squares every pixel. It is kind of scary that it wrote everything correctly.

I gave it another task, which was to write a python interface to a serial to telnet device, and gave it the model of the specific device I wanted. This is a much easier task, for me at least. But it wrote the interface from the serial side instead of the telnet side, which is not very useful, and trivial to do. I tried to be more specific that I wanted it on the telnet side, but it didn't seem to get it.

Overall though, I found it pretty scary that technology has reached the point that it can do this.
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

OmegaKV
Here is a conversation I just had with it:

Me:
Write a "hello world" server in Luan.

ChatGPT:
Here is a basic "Hello World" server in Lua:
local socket = require("socket")

local server = assert(socket.bind("*", 8080))
local ip, port = server:getsockname()
print("Server running on http://localhost:" .. port)

while true do
  local client = server:accept()
  client:send("HTTP/1.1 200 OK\r\n\r\nHello World\r\n")
  client:close()
end
This server listens on port 8080 and returns the text "Hello World" in response to any HTTP request received.

Me:
Not Lua, Luan.

ChatGPT:
I'm sorry, but there is no programming language called "Luan." If you meant to ask for an example in Lua, I provided one in my previous answer. If you could specify what you're looking for, I would be happy to help.
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

OmegaKV
I asked it to make a website in python that generates a PDF resume given a name, education, and work experience and this is what it gave:

from flask import Flask, request, make_response
from fpdf import FPDF

app = Flask(__name__)

def generate_pdf(name, education, work_experience):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=12)
    pdf.cell(200, 10, txt=f"Resume for {name}", ln=1, align="C")
    pdf.cell(200, 10, txt="Contact Information:", ln=1, align="L")
    pdf.cell(200, 10, txt=f"Name: {name}", ln=1, align="L")
    pdf.cell(200, 10, txt="Email: your_email@example.com", ln=1, align="L")
    pdf.cell(200, 10, txt="Phone: (555) 555-5555", ln=1, align="L")
    pdf.cell(200, 10, txt="Summary:", ln=1, align="L")
    pdf.cell(200, 10, txt=f"A highly motivated individual with experience in {work_experience} and education in {education}.", ln=1, align="L")
    pdf.cell(200, 10, txt="Education:", ln=1, align="L")
    pdf.cell(200, 10, txt=education, ln=1, align="L")
    pdf.cell(200, 10, txt="Work Experience:", ln=1, align="L")
    pdf.cell(200, 10, txt=work_experience, ln=1, align="L")
    response = make_response(pdf.output(dest='S').encode('latin1'))
    response.headers.set('Content-Disposition', 'attachment', filename='resume.pdf')
    response.headers.set('Content-Type', 'application/pdf')
    return response

@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "GET":
        return '''
        <form method="post">
          Name: <input type="text" name="name"><br>
          Education: <input type="text" name="education"><br>
          Work Experience: <input type="text" name="work_experience"><br>
          <input type="submit" value="Submit">
        </form>
        '''
    else:
        name = request.form["name"]
        education = request.form["education"]
        work_experience = request.form["work_experience"]
        return generate_pdf(name, education, work_experience)

if __name__ == "__main__":
    app.run()
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

fschmidt
Administrator
In reply to this post by OmegaKV
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

Clarkton
In reply to this post by OmegaKV
What does this imply?
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

OmegaKV
Nothing really, just a non-cherrypicked example. Luan is the programming language fschmidt created.
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

OmegaKV
I run a translation wiki and am using pywikibot to write a script for importing data from another site. I needed to know how to how to replace an existing page with a given text. Surprisingly none of its documented functions do this. I Googled my question and the only instance of someone asking it that I found is here:

https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/thread/Y6FSITSRH256RQKQOWDALO36M4FNLBOW/

The moron who responded recommends first deleting a page, which in my opinion is a bad solution since it requires admin privileges, whereas none should be needed to do this. The other solution he gave was to write a regex expression to replace the entire page, but in my opinion this is horrible since writing a regex expression requires one to think whereas thinking shouldn't be required for this.

Unsatisfied with these answers I looked through the source code of pywikibot and found there is a "save" function of the page class, which replaces a page with given text. This straightforward and does exactly what I want.

Afterwards I decided to test ChatGPT to see if it would figure this out on its own, even though the answer to this problem doesn't seem to exist online. So I asked ChatGPT to write a script using pywikibot that replaces a page with a given text. And it did it. It provided a simple and correct solution, which basically just uses the "save" function.

I spent a good half hour or so on this, which could have been avoided if I had used ChatGPT.
Reply | Threaded
Open this post in threaded view
|

Re: ChatGPT

fschmidt
Administrator
This post was updated on .
I think ChatGPT will be a useful search tool, and this is basically a search question about programming.  I do several programming search queries every day, and I will start using ChatGPT along with Google for my searches.


Actually I just tried "How does one upload an image and shrink its file size in javascript.".  It does write better code than most modern programmers.