cbot-command


Namecbot-command JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/graiz/cbot/
SummaryCbot is a simple python command line bot based on GPT3.
upload_time2022-12-13 17:42:02
maintainer
docs_urlNone
authorGregory Raiz
requires_python>=3.6
license
keywords terminal cbot openai gpt3 chatgpt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cbot
Cbot is a simple python command line bot based on GPT3. The bot will lookup what the right command line is for natural questions that you ask. A GPT3 API key is required for this to work. 

## Example usage:
```
$> cbot "How do I count the number of lines in a file?"
   wc -l filename.txt

$> cbot "How do I get the mime type of a file?"        
   file filename.txt

$> cbot "How do I create a file with the text 'hello world'"   
   echo hello world > hello.txt

$> cbot "How do I open php in interactive mode?" 
   php -a

$> cbot "How do I set my email using git config?"
   git config --global user.email "new_email@address.com"

$> cbot What is the current date
   date
```
Note: That you don't have to use quotes, however if you do
   this you can not include a question mark because the shell
   will try to match it with a file.

Use the -x option to execute the command.
```
$> cbot -x How do I create a file test.txt
   touch test.txt"

```

## Cbot Basics
The application is a simple Python script that prompts GPT3 with a couple examples and the OS of the current system. This helps ensure that Linux, Mac, and Windows specific commands tend to be more accurate.  Cbot is based entirely on GPT3 and it's not perfect. The more examples it has, the better it gets however the more examples the more GPT3 may cost per request. If you find examples that improve output or correct mistakes, please feel free to contribute them. Future versions of GPT3 will allow training and fine tuning. 

## Installation

- Add your GPT3 API key into an environmental variable. The easiest way to do this is to add to to your command line shell by adding the line:  export OPENAI_API_KEY="then_enter_your_key"
This is most commonly a file called .zshrc or .bashrc in your home directory.  The API key is something that you can get from: https://beta.openai.com/account/api-keys


```
$> pip install cbot-command
$> cbot "How do I list all files?"    
```
## Testing

If everything is working you should be able to run "cbot" from the command line with a question and it'll return an answer.

# Advanced tricks...

If you're feeling adventurous you can pass the command option **-x** to execute the command. Be careful as this will execute whatever is passed back from GPT3. Using this with simple things may be fine but this is not recommended with any actions that could be destructive.

> **Note:** The **-x** option will go ahead and run the command returned without asking.  Proceed with caution, for added safety sudo commands will not be automatically run.

You can also call cbot with a **-s** option. This will save any command as a shortcut with whatever name you choose. The first parameter is the name of the command and the second is the command itself in quotes. 
```
$> cbot -s nap "pmset sleepnow"
   Saving shortcut nap, will return: pmset sleepnow
$> cbot -x nap
   Sleeping now...
```

To copy a command directly into the clipboard use the **-c** option. Can be useful if you want to execute the command but you don't trust cbot to do so automatically. 

Cbot has a -g option to ask general questions. The results when you ask a general question will not be formated as a command line. This is useful for asking general questions, historical facts or other information not likely to be formated as a command. 
```
$> cbot -g "Who was the 23rd president?"
  Herbert Hoover  
$> cbot -g "What is the meaning of life?"p
   42
```


Cbot saves every command in a SQLite3 database located in the home directory .cbot_cache. You can inspect or delete this directory, you can also directly add or remove shortcuts if needed.



#### Credits
----
Initial version by Gregory Raiz
This code is free to use under the MIT liscense.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/graiz/cbot/",
    "name": "cbot-command",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "terminal cbot openai gpt3 chatgpt",
    "author": "Gregory Raiz",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/90/0c/694f132534d4a68cf68d123521c8d3fee823ae5580bf2dc7b18a712045f3/cbot-command-1.0.3.tar.gz",
    "platform": null,
    "description": "# cbot\nCbot is a simple python command line bot based on GPT3. The bot will lookup what the right command line is for natural questions that you ask. A GPT3 API key is required for this to work. \n\n## Example usage:\n```\n$> cbot \"How do I count the number of lines in a file?\"\n   wc -l filename.txt\n\n$> cbot \"How do I get the mime type of a file?\"        \n   file filename.txt\n\n$> cbot \"How do I create a file with the text 'hello world'\"   \n   echo hello world > hello.txt\n\n$> cbot \"How do I open php in interactive mode?\" \n   php -a\n\n$> cbot \"How do I set my email using git config?\"\n   git config --global user.email \"new_email@address.com\"\n\n$> cbot What is the current date\n   date\n```\nNote: That you don't have to use quotes, however if you do\n   this you can not include a question mark because the shell\n   will try to match it with a file.\n\nUse the -x option to execute the command.\n```\n$> cbot -x How do I create a file test.txt\n   touch test.txt\"\n\n```\n\n## Cbot Basics\nThe application is a simple Python script that prompts GPT3 with a couple examples and the OS of the current system. This helps ensure that Linux, Mac, and Windows specific commands tend to be more accurate.  Cbot is based entirely on GPT3 and it's not perfect. The more examples it has, the better it gets however the more examples the more GPT3 may cost per request. If you find examples that improve output or correct mistakes, please feel free to contribute them. Future versions of GPT3 will allow training and fine tuning. \n\n## Installation\n\n- Add your GPT3 API key into an environmental variable. The easiest way to do this is to add to to your command line shell by adding the line:  export OPENAI_API_KEY=\"then_enter_your_key\"\nThis is most commonly a file called .zshrc or .bashrc in your home directory.  The API key is something that you can get from: https://beta.openai.com/account/api-keys\n\n\n```\n$> pip install cbot-command\n$> cbot \"How do I list all files?\"    \n```\n## Testing\n\nIf everything is working you should be able to run \"cbot\" from the command line with a question and it'll return an answer.\n\n# Advanced tricks...\n\nIf you're feeling adventurous you can pass the command option **-x** to execute the command. Be careful as this will execute whatever is passed back from GPT3. Using this with simple things may be fine but this is not recommended with any actions that could be destructive.\n\n> **Note:** The **-x** option will go ahead and run the command returned without asking.  Proceed with caution, for added safety sudo commands will not be automatically run.\n\nYou can also call cbot with a **-s** option. This will save any command as a shortcut with whatever name you choose. The first parameter is the name of the command and the second is the command itself in quotes. \n```\n$> cbot -s nap \"pmset sleepnow\"\n   Saving shortcut nap, will return: pmset sleepnow\n$> cbot -x nap\n   Sleeping now...\n```\n\nTo copy a command directly into the clipboard use the **-c** option. Can be useful if you want to execute the command but you don't trust cbot to do so automatically. \n\nCbot has a -g option to ask general questions. The results when you ask a general question will not be formated as a command line. This is useful for asking general questions, historical facts or other information not likely to be formated as a command. \n```\n$> cbot -g \"Who was the 23rd president?\"\n  Herbert Hoover  \n$> cbot -g \"What is the meaning of life?\"p\n   42\n```\n\n\nCbot saves every command in a SQLite3 database located in the home directory .cbot_cache. You can inspect or delete this directory, you can also directly add or remove shortcuts if needed.\n\n\n\n#### Credits\n----\nInitial version by Gregory Raiz\nThis code is free to use under the MIT liscense.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Cbot is a simple python command line bot based on GPT3.",
    "version": "1.0.3",
    "split_keywords": [
        "terminal",
        "cbot",
        "openai",
        "gpt3",
        "chatgpt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "28d1a1998fd6bfafde4836a433af3c9c",
                "sha256": "5a7e84454a98e760d2ae62ca43fe7bf185d2fe20464b29c4f1818447f7f0f935"
            },
            "downloads": -1,
            "filename": "cbot_command-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "28d1a1998fd6bfafde4836a433af3c9c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6744,
            "upload_time": "2022-12-13T17:42:00",
            "upload_time_iso_8601": "2022-12-13T17:42:00.257873Z",
            "url": "https://files.pythonhosted.org/packages/16/13/9e6efd13fdb42660a22703d717cba7702c3bbf427a9506e12db5a2a4a490/cbot_command-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "ab8acf25df1aeea9a7ed229687d5f7eb",
                "sha256": "aa8c7c49c79e9efc20afd3d2417e289f0d388aa1dbc75e843a8db0792bfb05df"
            },
            "downloads": -1,
            "filename": "cbot-command-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ab8acf25df1aeea9a7ed229687d5f7eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6406,
            "upload_time": "2022-12-13T17:42:02",
            "upload_time_iso_8601": "2022-12-13T17:42:02.272586Z",
            "url": "https://files.pythonhosted.org/packages/90/0c/694f132534d4a68cf68d123521c8d3fee823ae5580bf2dc7b18a712045f3/cbot-command-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-13 17:42:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "graiz",
    "github_project": "cbot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cbot-command"
}
        
Elapsed time: 0.02579s