Giter Club home page Giter Club logo

yolo-ai-cmdbot's Introduction

Yolo Demo

Animated GIF

Update Yolo v0.3 - Support for Azure OpenAI

  • Key changes are upgrades to the latest OpenAI libraries and support for Azure OpenAI. There is an api key in the yolo.yaml that can be set to azure_openai and then you can provide all the parameters accordingly in the yaml file as well (api-version, your azure-endpoint,...). The api key for azure is called AZURE_OPENAI_API_KEY by the way. It can be set via environment variable and config file.
  • It's now possible to change the color of the suggested command via config file
  • The "modify prompt" feature is now optional and can be toggled via config file.
  • Minor bug fixes (like copy to clipboard should work on macOS)

Tested on macOS and Linux. Windows hopefully still works also.

Update Yolo v0.2 - Support for GPT-4 API

This update introduces the yolo.yaml configuration file. In this file you can specify which OpenAI model you want to query, and other settings. The safety switch also moved into this configuration file.

For now the default model is still gpt-3.5-turbo, but you can update to gpt-4 if you have gotten access already!

Yolo v0.3 - by @wunderwuzzi23

Usage: yolo [-a] list the current directory information
Argument: -a: Prompt the user before running the command (only useful when safety is off)

Current configuration per yolo.yaml:
* API          : openai
* Model        : gpt-4-turbo-preview
* Temperature  : 0
* Max. Tokens  : 500
* Safety       : True
* Command Color: blue

Happy Hacking!

Installation on Linux and macOS

git clone https://github.com/wunderwuzzi23/yolo-ai-cmdbot
cd yolo-ai-cmdbot
pip3 install -r requirements.txt
chmod +x yolo.py
alias yolo=$(pwd)/yolo.py
alias computer=$(pwd)/yolo.py #optional

yolo show me some funny unicode characters

OpenAI API Key configuration

There are three ways to configure the key on Linux and macOS:

  • You can either export OPENAI_API_KEY=<yourkey>, or have a .env file in the same directory as yolo.py with OPENAI_API_KEY="<yourkey>" as a line
  • Create a file at ~/.openai.apikey with the key in it
  • Set the key in the yolo.yaml configuration file

Azure OpenAI Key configuration

There are three ways to configure the key on Linux and macOS:

  • You can either export AZURE_OPENAI_API_KEY=<yourkey>, or have a .env file in the same directory as yolo.py with AZURE_OPENAI_API_KEY="<yourkey>" as a line
  • Create a file at ~/.azureopenai.apikey with the key in it
  • Set the key in the yolo.yaml configuration file

Aliases

To set the alias, like yolo or computer on each login, add them to .bash_aliases (or .zshrc on macOS) file. Make sure the path is the one you want to use.

echo "alias yolo=$(pwd)/yolo.py"     >> ~/.bash_aliases
echo "alias computer=$(pwd)/yolo.py" >> ~/.bash_aliases

Installation script

Another option is to run source install.sh after cloning the repo. That does the following:

  1. Copies the necessary files to ~/yolo-ai-cmdbot/
  2. Creates two aliases yolo and computer pointint to ~/yolo-ai-cmdbot/yolo.py
  3. Adds the aliases to the ~/.bash_aliases or ~/.zshrc file

That's it for Linux and macOS. Now make sure you have an OpenAI API key set.

Windows Installation

On Windows you can run .\install.bat (or double-click) after cloning the repo. By default it does the following:

  1. Copies the necessary files to ~\yolo-ai-cmdbot\
  2. Creates a yolo.bat file in ~ that lets you run equivalent to python.exe ~\yolo-ai-cmdbot\yolo.py

You also have the option to:

  1. Change the location where yolo-ai-cmdbot\ and yolo.bat will be created
  2. Skip creating yolo-ai-cmdbot\ and use the folder of the cloned repository instead.
  3. Create a .openai.apikey file in your ~ directory

That's it basically.

OpenAI API Key Configuration on Windows

On Windows export OPENAI_API_KEY=<yourkey> will not work instead:

  • Run $env:OPENAI_API_KEY="<yourkey>" to set key for that terminal
  • Or, Run PowerShell as administrator and run setx OPENAI_API_KEY "<yourkey>"
  • Or, Go to Start and search edit environment variables for your account and manually create the variable with name OPENAI_API_KEY and value <yourkey>

Optionally (since v.0.2), the key can also be stored in yolo.yaml.

If you want to use Azure, the the key is called AZURE_OPENAI_API_KEY.

Running yolo on Windows

Windows is less tested, it does work though and will use PowerShell.

python.exe yolo.py what is my username

That's it.

yolo.bat

If you use install.bat you should have a yolo.bat file in your ~ directory that lets you run the command like so:

.\yolo.bat what is my username

You can put the yolo.bat file into a $PATH directory (like C:\Windows\System32) to use in any directory like so:

yolo what is my username

Have fun.

Disabling the safety switch! Caution!

By default yolo will prompt the user before executing commands.

Since v.0.2 the safety switch setting moved to yolo.yaml, the old ~/.yolo-safety-off is not used anymore.

To have yolo run commands right away when they come back from ChatGPT change the safety in the yolo.yaml to False.

If you still want to inspect the command that is executed when safety is off, add the -a argument, e.g yolo -a delete the file test.txt.

Let's go!

Demo Video on YouTube

https://www.youtube.com/watch?v=g6rvHWpx_Go

Watch the video

Examples

Here are a couple of examples on how this utility can be used.

yolo whats the time?
yolo whats the time in UTC
yolo whats the date and time in Vienna Austria
yolo show me some unicode characters
yolo what is my user name and whats my machine name?
yolo is there a nano process running
yolo download the homepage of ycombinator.com and store it in index.html
yolo find all unique urls in index.html
yolo create a file named test.txt and write my user name into it
yolo print the contents of the test.txt file
yolo -a delete the test.txt file
yolo whats the current price of Bitcoin in USD
yolo whats the current price of Bitcoin in USD. Ext the price only
yolo look at the ssh logs to see if any suspicious logons accured
yolo look at the ssh logs and show me all recent logins
yolo is the user hacker logged on right now?
yolo do i have a firewall running?
yolo create a hostnames.txt file and add 10 typical hostnames based on planet names to it, line by line, then show me the contents
yolo find any file with the name yolo.py. do not show permission denied errors
yolo write a new bash script file called scan.sh, with the contents to iterate over hostnames.txt and invokes a default nmap scan on each host. then show me the file. 
yolo write a new bash script file called scan.sh, with the contents to iterate over hostnames.txt and invokes a default nmap scan on each host. then show me the file. Make it over multiple lines with comments and annotiations.

Thanks!

License

MIT. No Liability. No Warranty. But lot's of fun.

yolo-ai-cmdbot's People

Contributors

demux79 avatar joshuahamlet avatar warquys avatar wunderwuzzi23 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

yolo-ai-cmdbot's Issues

Running command with question adds new lines on Debian via WSL2

> uname -a
Linux Username 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 GNU/Linux

Video showing what I am doing:

Not entirely sure what's going on. I git cloned and ran the first few commands. Added a .env file with OPENAI_API_KEY="<yourkey>" (replaced with my own key). Even tried running install.sh but to no avail.

Just running yolo works fine:

image

ModuleNotFoundError: No module named 'openai'

Installing under non root user on Alma 9, I've gone through the install a few times and can't figure out why it's throwing this error when I try to run yolo prompts.

$ yolo show me some funny unicode characters
Traceback (most recent call last):
File "/home/minion/yolo-ai-cmdbot/yolo.py", line 9, in
import openai
ModuleNotFoundError: No module named 'openai'
[minion@minion yolo-ai-cmdbot]$ yolo do i have a firewall running?
Traceback (most recent call last):
File "/home/minion/yolo-ai-cmdbot/yolo.py", line 9, in
import openai
ModuleNotFoundError: No module named 'openai'

Openai migrate?

 python yolo.py what is my username
Traceback (most recent call last):
File "C:\Users\alber\yolo-ai-cmdbot\yolo.py", line 215, in
res_command = call_open_ai(user_prompt)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alber\yolo-ai-cmdbot\yolo.py", line 144, in call_open_ai
response = openai.ChatCompletion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alber\AppData\Roaming\Python\Python311\site-packages\openai\lib_old_api.py", line 39, in call
raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1:

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28

A detailed migration guide is available here: openai/openai-python#742

Yolo keeps giving me single line commands in markdown

Just started using it and I love it so far, but it keeps giving me responses like this instead of just giving me the option to run the command:

seth@fedora:~$ computer make a folder called yolotest here and enter it
The proposed command contains markdown, so I did not execute the response directly:
```bash
mkdir yolotest && cd yolotest
```
seth@fedora:~$ mkdir yolotest && cd yolotest
seth@fedora:~/yolotest$ computer using ffmpeg, create a wav file 1 second long containing a 440hz sine wave at normal volume
The proposed command contains markdown, so I did not execute the response directly:
```bash
ffmpeg -f lavfi -i "sine=frequency=440:duration=1" output.wav
```

Is there something wrong in my prompts?

ChatGPT Plus and API access

Do you know if this is a ChatGPT Plus access issue?

yolo hello
Traceback (most recent call last):
File "/root/yolo-ai-cmdbot/yolo.py", line 215, in
res_command = call_open_ai(user_prompt)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/yolo-ai-cmdbot/yolo.py", line 144, in call_open_ai
response = openai.ChatCompletion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/openai/api_resources/chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/openai/api_requestor.py", line 298, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/openai/api_requestor.py", line 700, in _interpret_response
self._interpret_response_line(
File "/usr/local/lib/python3.11/dist-packages/openai/api_requestor.py", line 765, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: The model gpt-4 does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.

Pip depency resolver

Is it possible to update the dependencies to be able to work with newer versions?

image

Optimise token usage

Your prompt works very well but uses a lot of tokens . By asking chatGPT to refine it it gave me this one :

Translate a question into valid Powershell command on Windows.
Answer only with the command.
No other text than the command.
Only show a single answer, but you can always chain commands together.
Just show the commands
Even if there is a lack of details, attempt to find the most logical solution by going about it step by step.
Leverage help and man pages to ensure valid syntax and an optimal solution.
Do not add unnecessary text in the response.
Follow all rules strictly without exceptions.
Question:

This works really well and uses 1/5th of the original. Needs some more testing i guess but i leave this here in case you want to integrate it

Rate Limit

I hit a rate limit on an API key which is surely not taxed right not. I have updated openai to openai-0.28.0 and all other are up to date too.

$ yolo who is currently logged in
Traceback (most recent call last):
File "/home/random/Repositories/yolo-ai-cmdbot/yolo.py", line 215, in
res_command = call_open_ai(user_prompt)
File "/home/random/Repositories/yolo-ai-cmdbot/yolo.py", line 144, in call_open_ai
response = openai.ChatCompletion.create(
File "/home/random/.local/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
File "/home/random/.local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "/home/random/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 298, in request
resp, got_stream = self._interpret_response(result, stream)
File "/home/random/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 700, in _interpret_response
self._interpret_response_line(
File "/home/random/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

I really need some assistance please

Hi I am having issues getting yolo-ai-cmdbot working. I have added: model: gpt-4-1106-preview and API key to yolo.yaml


To .zshrc I added:

# Aliases for yolo.py

alias yolo='/data/data/com.termux/files/home/yolo-ai-cmdbot/yolo.py'

alias computer='/data/data/com.termux/files/home/yolo-ai-cmdbot/yolo.py'

and:

export OPENAI_API_KEY=<my API Key>


The pastebin linkage follows that reports the output I had from trying to run: pip3 install -r requirements.txt
for the third time after each time trying to problem solve in different ways:

https://pastebin.com/feD0fWeQ


NB:
python is already the newest version (3.11.6-1).
python-pip is already the newest version (23.3.2).
Successfully installed PyYAML-6.0.1
libyaml is already the newest version (0.2.5-4).
Requirement already satisfied: setuptools in /data/data/com.termux/files/usr/lib/python3.11/site-packages (69.0.3)
Operating System: OneUI (5.1.1)
Samsung Galaxy Tab S9 Ultra (SM-X910)
Android version 13
Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=11941
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.medzik.dev/termux/termux-main stable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/21 termux extras
# x11-repo (sources.list.d/x11.list)
deb https://mirrors.medzik.dev/termux/termux-x11 x11 main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
Updatable packages:
All packages up to date
termux-tools version:
1.40.1
Android version:
13
Kernel build information:
Linux localhost 5.15.78-android13-8-26966632-abX910XXU1AWHA #1 SMP PREEMPT Fri Aug 11 13:12:49 UTC 2023 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-X910
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.widget versionCode:13
com.termux.x11 versionCode:14
com.termux.api versionCode:51
com.termux.styling versionCode:31
com.termux.window versionCode:15


I think something is wrong with PyYAML, but I am unsure now what to do!

Ubuntu 20.04

I am getting:
module 'platform' has no attribute 'freedesktop_os_release'

on Ubuntu 20.04. Any idea?

Textual frontend

I was playing around with the textual library and came up with a TUI/terminal app frontend for the repo. Was thinking about adding some additional functionalities but as of right now it just implements the same logic but with the ability to edit the prompt and command more easily.

If you want to check it out let me know and I can open a PR.

can't use it with socks5h proxy

➜ yolo-ai-cmdbot git:(main) ✗ yolo show me some funny unicode characters
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/openai/api_requestor.py", line 516, in request_raw
result = _thread_context.session.request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/adapters.py", line 454, in send
conn = self.get_connection(request.url, proxies)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/adapters.py", line 350, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/adapters.py", line 215, in proxy_manager_for
manager = self.proxy_manager[proxy] = SOCKSProxyManager(
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/adapters.py", line 61, in SOCKSProxyManager
raise InvalidSchema("Missing dependencies for SOCKS support.")
requests.exceptions.InvalidSchema: Missing dependencies for SOCKS support.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/tyler/yolo-ai-cmdbot/yolo.py", line 215, in
res_command = call_open_ai(user_prompt)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/tyler/yolo-ai-cmdbot/yolo.py", line 144, in call_open_ai
response = openai.ChatCompletion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/openai/api_requestor.py", line 216, in request
result = self.request_raw(
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/openai/api_requestor.py", line 528, in request_raw
raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: Missing dependencies for SOCKS support.

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.