Live data from Hacker News

Like Clippy but for the CLI

github.com

1–10 of 41 posts

Re: Like Clippy but for the CLI

#3
post #2

Given how much GPT models hallucinate perfectly realistic commands, this sounds super dangerous. "Hey, CLI Clippy thingy, how do I do (harmless activity)?" "rm -rf / --yes-do-what-I-say"

but the hallucinations don't look like that, because rm -rf is a real command. a hallucinations is more likely to be something like "to export your tailacale config, try: tailscale export" but which unfortunately doesn't exist.

Re: Like Clippy but for the CLI

#4
Thanks for sharing, but I am really not happy to install PHP (or using it) on my local system. I see you state you may re-write it in Python, if this happens I look forward to trying it!

Re: Like Clippy but for the CLI

#5
post #4

Thanks for sharing, but I am really not happy to install PHP (or using it) on my local system. I see you state you may re-write it in Python, if this happens I look forward to trying it!

Just use brew to install it in your home directory. There is nothing unsafe about PHP.

Re: Like Clippy but for the CLI

#6
post #3
post #2

Given how much GPT models hallucinate perfectly realistic commands, this sounds super dangerous. "Hey, CLI Clippy thingy, how do I do (harmless activity)?" "rm -rf / --yes-do-what-I-say"

but the hallucinations don't look like that, because rm -rf is a real command. a hallucinations is more likely to be something like "to export your tailacale config, try: tailscale export" but which unfortunately doesn't exist.

Unfortunately, I have seen GPT give a response equivalent to the insanity I described above; it gave a very real, very working answer that was extremely harmful and was entirely inappropriate for the question.

`tailscale export` is probably the more common form of hallucinating, totally harmless wishful thinking that doesn't work.

Re: Like Clippy but for the CLI

#7
post #4

Thanks for sharing, but I am really not happy to install PHP (or using it) on my local system. I see you state you may re-write it in Python, if this happens I look forward to trying it!

Just use brew to install it in your home directory. There is nothing unsafe about PHP.

I didn't ask how to install it, and made no reference to safety. I also do not have access to an Apple device where I could use brew.

Re: Like Clippy but for the CLI

#8
post #7

Earlier quoted context omitted.

Just use brew to install it in your home directory. There is nothing unsafe about PHP.

I didn't ask how to install it, and made no reference to safety. I also do not have access to an Apple device where I could use brew.

Homebrew works well on Linux (or wsl2) these days if that helps.

Re: Like Clippy but for the CLI

#9
That seems handy, maybe this way I can keep using jq on the command line without ever having to learn jq's syntax.

I made a pure bash version since I don't always have php installed:

    gpt () {
        api_key=$(cat ~/.config/openai.key)
        verbose=false
        if [[ $1 = -v ]]; then
            verbose=true
            shift
        fi
        userinput="$*"
        # shellcheck disable=SC2016
        system='You are an interactive shell command line shell agent.
    You just get things done, rather than trying to explain.
    Do your best to respond with 1 command that will meet the requirements.
    Start a line with `$ ` to have it sent directly to the shell VERBATIM.
    All other output is just echoed.
    Favor 1 line shell commands.
    Be terse.
    Important: Every command you output will automatically be executed in this env: bash'
        systemj="$(jq -Rs . &2
            return 1
        else
            $verbose && echo "RESULT: ${res}"
            jq -r '.choices[0].message.content' 
-----

I even tried using GPT to help me develop it!

    $ gpt -v get the actual completion from an openai /completions request using jq
    RESULT: {
      "id": "chatcmpl-8IZvb4lQaFgcDdnSnsU4t6zhFRrbN",
      "object": "chat.completion",
      "created": 1699438703,
      "model": "gpt-3.5-turbo-0613",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "$ jq '.choices[0].text'"
          },
          "finish_reason": "stop"
        }
      ],
      "usage": {
        "prompt_tokens": 116,
        "completion_tokens": 9,
        "total_tokens": 125
      }
    }
… there's probably a lesson in there.
Post reply on HN