not-poma / lazyshell

GPT powered Zsh completion script
MIT License
370 stars 26 forks source link

modified to use chatGPT API - faster and lower cost #1

Closed Psyf closed 1 year ago

Psyf commented 1 year ago

Oh geez, you also just committed the 3.5-tubo upgrade hahahahaha

Nice stuff 🙌🏽

Psyf commented 1 year ago

Leaving the PR open because I did a few tweaks to the prompts that you might find interesting.

not-poma commented 1 year ago

Those are some interesting ideas, I'll incorporate them. I'll write a function to fetch the current OS distribution so that it's cross platform.

What's your motivation for adding You are the world leading expert and Always make the best guess if you do not have enough information.? Does it improve the output?

not-poma commented 1 year ago

Added the __get_distribution_name function and some other changes from this PR. Couldn't merge directly because of the conflicts. Thanks for your input!

Psyf commented 1 year ago

What's your motivation for adding You are the world leading expert. Does it improve the output?

Just a trick I found and have been using since. Anecdotally (my experience), it does seem to improve the output lol https://twitter.com/labenz/status/1628447989051150336

and Always make the best guess if you do not have enough information.?

See the cheese example below.

Psyf commented 1 year ago

Couldn't merge directly because of the conflicts

fwiw, here are a couple more inputs:

  1. asking it to output a single command without backticks doesn't always work so your implementation of stripping the backticks out afterwards is more robust I think
  2. my POST requests don't work when I use --data instead of -d on the curl -X POST. --data seems to insert an & after the end of the request body (verified by running a python http.server)
Psyf commented 1 year ago

__get_distribution_name

This is a nice addition.

I've been meaning to add a LOT more context for gpt about the environment:

  1. tools. I have cheese installed on the machine, but when I ask the query open the camera it seems to either say "I don't have access" (which is where my excess prompt helps) or talk too much ("you can install cheese bla bla bla"). If it knew about a lot of the tools on my env (compgen -c is A LOT tho)

  2. environment. Just giving it the ls and the cwd might be useful enough as a start.

  3. Command history so that it sees the interaction over time and customizes accordingly.

Anyways, this thread seems to be going too off-track.

Thanks!

not-poma commented 1 year ago

I did a bunch of experiments in the playground and You are the world leading expert either has no effect, or (rarely) makes the answer more complex. It also sometimes started to complain when there is OS version after 2021 in the user query if the query is difficult to answer. And it sometimes talks too much like refusing to answer queries like disable keyboard

I've experimented further and borrowed prompt parts from amazing-prompts repo, and arrived to this intro that seems to yield the best results: You are a zsh autocomplete script. All your answers are a single command for Ubuntu 22.04.2 LTS, and nothing else. You do not write any human-readable explanations., and user query can be submitted as is. Commited the new version.

I was also thinking about giving instructions what to do if it can't answer, but didn't think of a good solution. Maybe instruct it to start its excuse with a comment # symbol but I think it doesn't make much difference.

not-poma commented 1 year ago

Now that I tested it some more, the intro really helps, it now answers even stupid queries like my disk is full and fix the wi-fi

not-poma commented 1 year ago

As for giving GPT more context - it might raise a lot of privacy concerns for many users, especially with command history, I think I'll avoid doing it for now.