from Hacker News

Building a back end using only OpenAI Codex

by zegl on 8/24/22, 10:52 AM with 35 comments

I've published the sources for the code generation and the code that was generated on GitHub: https://github.com/sturdy-dev/codeball-todo-mvc

I've been experimenting with merging prompts together, with a goal to write the full backend in a single prompt.

On the form:

> 1. Setup a flask web server

> 2. Add a /add endpoint

It works reasonably well, but it seems like it's loosing some precision in the prompts... The person that coined the term "prompt engineering" was right, it's really important to learn what words to use to get the AI to do exactly what you want it to do.

  • by akkartik on 8/24/22, 9:46 PM

    This needs a new format for source code. We could call it, oh, Literate Programming. Check in only the prompts to version control, expand them into code during CI, then file bugs when new releases of OpenAI cause regressions.
  • by daenz on 8/24/22, 8:31 PM

    It's very cool, but from an auditing perspective, it's a nightmare. As a reviewer, I can't reason about the code in the same way that I could reason about human code, since there is no coherent formulation of the accomplished task. I can't say "why did it apply CORS to the entire flask app?" and expect reasoning that will fulfill my objective as a reviewer.

    So while it could help blast out large swaths of code quickly, it still needs an expert at the wheel to be accountable for the changes to reviewers.

  • by cbm-vic-20 on 8/25/22, 1:46 AM

    This is cool. Some thoughts:

    > beware: sometimes Codex writes code vulnerable to SQL injection. When that happens tough, I was able to prevent it by adding "safely" to the prompt.

    Oops.

    Anyway, is "the program" actually the prompts? Should that be committed into source control, so future you and others can figure out how the code was built? How long will it be until we can trust Codex enough that the Python code doesn't need to be committed? "Codex, create an Android CRUD UI for this OpenAPI document."

  • by kevincox on 8/24/22, 7:35 PM

    This is mindblowing. The copilot autocomplete was very impressive but actually editing the existing code is incredible.

    I really want to see some examples of failed prompts and attempts to ask it to cache sqlite connections.

  • by sdwr on 8/24/22, 8:51 PM

    I like how the captions scroll along to match the code samples, it's a fun reading experience.

    Got scared for a second (most of what I code is CRUD backends!), until I tried to see it from the perspective of a novice, where all of this is impenetrable anyway.

  • by xrd on 8/24/22, 8:24 PM

    Why did you use sveltekit as the front end (as opposed to just svelte)? Typically SK is used when you want to have both front end and back end in the same app.
  • by nl on 8/24/22, 11:13 PM

    The typo in the submission (like it's loosing [should be losing] some precision) is both inadvertently amusing (losing precision could well be described as being loose) and raises the question of how Codex would deal with missed typos in instructions.
  • by verdverm on 8/24/22, 11:45 PM

    The code on GitHub does not exactly match the post. In particular, the last section about adding seed data is shifted up a few lines on GitHub, into the first database call, making me wonder if it was a stored procedure or a bug.

    Did you have to correct output for the post?

    https://github.com/sturdy-dev/codeball-todo-mvc/blob/main/ap...

    https://github.com/sturdy-dev/codeball-todo-mvc/commit/17992...

  • by keyle on 8/25/22, 12:04 AM

    Any instructions on how one goes ahead and play with openai codex themselves?

    Is this closed? Beta? or .. ?

    As a kid I used to dream to talk to the computer and it would make code happen as a repl. This appears to be close to it.

  • by citizenpaul on 8/25/22, 6:59 PM

    > it's really important to learn what words to use to get the AI to do exactly what you want it to do.

    Now instead of spending years learning to do all that nasty troublesome coding you can just spend years learning to exactly phrase what you want the code generator to do. Wait.... is this an infinite loop joke?

  • by w1zzy on 8/24/22, 7:45 PM

    How much time did it take to wrote app?
  • by hirebackenddev on 8/25/22, 5:25 AM

    This is something interesting. Thanks for posting such content.