• MangoCats@feddit.it
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    9 hours ago

    The first half dozen times I tried AI for code, across the past year or so, it failed pretty much as you describe.

    Finally, I hit on some things it can do. For me: keeping the instructions more general, not specifying certain libraries for instance, was the key to getting something that actually does something. Also, if it doesn’t show you the whole program, get it to show you the whole thing, and make it fix its own mistakes so you can build on working code with later requests.

    • SocialMediaRefugee@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      5 hours ago

      I’ve had good results being very specific, like “Generate some python 3 code for me that converts X to Y, recursively through all subdirectories, and converts the files in place.”

      • MangoCats@feddit.it
        link
        fedilink
        English
        arrow-up
        4
        ·
        5 hours ago

        I have been more successful with baby steps like: “Write a python 3 program that converts X to Y.” Tweak prompt until that’s working as desired, then: “make it work recursively through all subdirectories” - and again tweak with specifics like converting the files in place, etc. Always very specific, also - force it to fix its own bugs so you can move forward with a clean example as you add complexity. Complexity seems to cap out at a couple of pages of code, at which point “Ooops, something went wrong.”

    • vivendi@programming.dev
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      1
      ·
      8 hours ago

      Have you tried insulting the AI in the system prompt (as well as other tunes to the system prompt)?

      I’m not joking, it really works

      For example:

      Instead of “You are an intelligent coding assistant…”

      “You are an absolute fucking idiot who can barely code…”

      • rozodru@lemmy.world
        link
        fedilink
        English
        arrow-up
        8
        ·
        8 hours ago

        “You are an absolute fucking idiot who can barely code…”

        Honestly, that’s what you have to do. It’s the only way I can get through using Claude.ai. I treat it like it’s an absolute moron, I insult it, I “yell” at it, I threaten it and guess what? the solutions have gotten better. not great but a hell of a lot better than what they used to be. It really works. it forces it to really think through the problem, research solutions, cite sources, etc. I have even told it i’ll cancel my subscription to it if it gets it wrong.

        no more “do this and this and then this but do this first and then do this” after calling it a “fucking moron” and what have you it will provide an answer and just say “done.”

          • MangoCats@feddit.it
            link
            fedilink
            English
            arrow-up
            5
            arrow-down
            1
            ·
            7 hours ago

            He’s developing a toxic relationship with his AI agent. I don’t think it’s the best way to get what you want (demonstrating how to be abusive to the AI), but maybe it’s the only method he is capable of getting results with.

      • MangoCats@feddit.it
        link
        fedilink
        English
        arrow-up
        5
        ·
        7 hours ago

        I frequently find myself prompting it: “now show me the whole program with all the errors corrected.” Sometimes I have to ask that two or three times, different ways, before it coughs up the next iteration ready to copy-paste-test. Most times when it gives errors I’ll just write "address: " and copy-paste the error message in - frequently the text of the AI response will apologize, less frequently it will actually fix the error.