GithubHelp home page GithubHelp logo

tom-doerr / zsh_codex Goto Github PK

View Code? Open in Web Editor NEW
1.3K 17.0 61.0 42 KB

This is a ZSH plugin that enables you to use OpenAI's Codex AI in the command line.

License: MIT License

Python 79.40% Shell 20.60%
zsh openai codex ai

zsh_codex's Introduction

⌨️ 🦾 Zsh Codex

AI in the command line.

Repository's starts Issues License
Latest commit GitHub repository size

You just need to write a comment or variable name and the AI will write the corresponding code.

What is it?

This is a ZSH plugin that enables you to use OpenAI's powerful Codex AI in the command line. OpenAI Codex is the AI that also powers GitHub Copilot. To use this plugin you need to get access to OpenAI's Codex API.

How do I install it?

Manual Installation

  1. Install the OpenAI package.
pip3 install openai
  1. Download the ZSH plugin.
git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex 
  1. Add the following to your .zshrc file.

Using oh-my-zsh:

    plugins=(zsh_codex)
    bindkey '^X' create_completion

Without oh-my-zsh:

    # in your/custom/path you need to have a "plugins" folder and in there you clone the repository as zsh_codex
    export ZSH_CUSTOM="your/custom/path"
    source "$ZSH_CUSTOM/plugins/zsh_codex/zsh_codex.plugin.zsh"
    bindkey '^X' create_completion
  1. Create a file called openaiapirc in ~/.config with your SECRET_KEY.
[openai]
secret_key = ...

You can also optionally specify: organization, base_url, model and temperature.

  1. Run zsh, start typing and complete it using ^X!

  2. If you use virtual environments you can set ZSH_CODEX_PYTHON to python executable where openai is installed. e.g. for miniconda you can use:

export ZSH_CODEX_PYTHON="$HOME/miniconda3/bin/python"

Fig Installation

Troubleshooting

Unhandled ZLE widget 'create_completion'

zsh-syntax-highlighting: unhandled ZLE widget 'create_completion'
zsh-syntax-highlighting: (This is sometimes caused by doing `bindkey <keys> create_completion` without creating the 'create_completion' widget with `zle -N` or `zle -C`.)

Add the line

zle -N create_completion

before you call bindkey but after loading the plugin (plugins=(zsh_codex)).

Already exists and is not an empty directory

fatal: destination path '~.oh-my-zsh/custom/plugins'

Try to download the ZSH plugin again.

git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex

Buy Me A Coffee

More usage examples


Fish Version

Traffic Statistics

zsh_codex's People

Contributors

akinazuki avatar clotodex avatar coffebar avatar fbarez avatar ibayramli avatar johnkegd avatar kevinbalkoski avatar luodian avatar manekinekko avatar paulomoreira1180778 avatar rizhiy avatar tom-doerr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zsh_codex's Issues

[BUG] Extra new line is inserted before suggestion

As the title says, there is always an extra line before suggestion.

So when I execute code from demo GIF, I get the following:
image
As can be seen, there is an extra line before suggestion

This is particularly annoying when trying to complete the current command, since it inserts completion on a new line.

Fix engine name

The engine name here should be text-davinci-002

Love what you've done here. Good job!

[NO ISSUE] Guidance fork is alive and well.

Story

I rushed and tried this out. Failed. In so many attempt and even couple of hack-ish methods (I even worked it out without changing anything significantly, just building a bridge between zsh_codex (a base_url injection made) - litellm (simple proxy) - ollama (A nice model was running). As you can imagine where I am now, they didn't work out too.

Fork

LeaveNhA/zsh_sodex

Since, I'm something of a Data Scientist myself, I gathered my mind and simply test out some methods to get a really nice output. Man, I tried couple of things and after some python packaging issues, I succeded on something and pushed.

Reviewe or collaboration?

It would be great to collaborate and work together, I have a million ideas about this fork.

Thanks

Thank you for your all hard work and time (to @tom-doerr and to all contributors).

Port to fish shell?

Hi. This looks like a fantastic idea and I'd like to try it out but I'm currently using fish. Would it be possible to port this as a plugin for Fisher or OMF?

I'm not getting feedback

I'm trying to get it works.
Everything seems to be well configured, but when I'm trying to get some feedback... you can see behavior here.

This is my related .zshrc related configuration:

plugins=(git zsh-syntax-highlighting zsh-autosuggestions history z kubectl kube-aliases docker helm zsh_codex)
zle -N create_completion
bindkey '^X' create_completion

Also, here my ~/.config/open:

[openai]
organization_id = <org_...>
secret_key = <secret_key>

Create `xontrib-codex` for xonsh shell

Hello @tom-doerr and all! Thank you for this extension!

I see the completion was implemented in python and this is the great opportunity to create Codex extension for the python-powered https://xon.sh shell!

How to do it:

  • You can create xonsh xontrib (extension) by using 5-minutes template generator - xontrib-template. In case of examples there are around 100 xontribs on Github - topics/xontrib
  • To understand how to use cursor in prompt-toolkit (xonsh prompt platform) you can review the xontrib-abbrevs code.

So you can create xontrib-codex for xonsh shell. It will be cool!

Thanks!

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

No such model: code-davinci-002

I'm getting the error in title. org_id & secret_key are correct, but I still get the error immediately after pressing ^X.

Anyone else experiences that?

Bash version

Hello,

I'm MB. A very nice and polite guy.

Feature request:

A bash version : )

This is going to happen you know and it will be the biggest thing that ever happened to the Linux terminal.

3573829478367

No such organization: Personal.

When trying to run I get:

echo Traceback (most recent call last): File "/home/tc/.oh-my-zsh/custom/plugins/zsh_codex/create_completion.py", line 67, in <module> response = openai.Completion.create(engine='davinci-codex', prompt=input_prompt, temperature=0.5, max_tokens=32, stream=STREAM) File "/home/tc/.local/lib/python3.9/site-packages/openai/api_resources/completion.py", line 31, in create return super().create(*args, **kwargs) File "/home/tc/.local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 66, in create response, _, api_key = requestor.request( File "/home/tc/.local/lib/python3.9/site-packages/openai/api_requestor.py", line 129, in request resp = self.interpret_response(rbody, rcode, rheaders, stream=stream) File "/home/tc/.local/lib/python3.9/site-packages/openai/api_requestor.py", line 348, in interpret_response return self.interpret_response_line(rbody, rcode, rheaders, stream) File "/home/tc/.local/lib/python3.9/site-packages/openai/api_requestor.py", line 367, in interpret_response_line raise self.handle_error_response( openai.error.AuthenticationError: No such organization: Personal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.