xontrib-openai


Namexontrib-openai JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/anki-code/xontrib-openai
SummaryUse Open AI models in xonsh shell.
upload_time2023-03-26 18:33:45
maintainer
docs_urlNone
authoranki-code
requires_python>=3.8
licenseMIT
keywords xontrib xonsh
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
Use Open AI models in xonsh shell.
</p>

<p align="center">  
If you like the idea click ⭐ on the repo and <a href="https://twitter.com/intent/tweet?text=Nice%20xontrib%20for%20the%20xonsh%20shell!&url=https://github.com/anki-code/xontrib-openai" target="_blank">tweet</a>.
</p>


## Installation

To install use pip:

```xsh
xpip install -U xontrib-openai
# or: xpip install -U git+https://github.com/anki-code/xontrib-openai
```

## Usage

```python
$OPENAI_API_KEY = 'abcd1234'  # https://platform.openai.com/account/api-keys

# Defaults:
# $OPENAI_MODEL = 'text-davinci-003'  # https://platform.openai.com/docs/models/overview
# $OPENAI_MAX_TOKENS = 500

xontrib load openai

ai! hello
# Hello! How are you?
```
In case you need addon with new model:
```python
aliases['ai4'] = "$OPENAI_MODEL='gpt-4' $OPENAI_MAX_TOKENS=1000 @('ai')"

ai4! hello gpt-4
# Hello human
```

### Get shell commands
```python
ai! how to git commit. Give me only command
# git commit -m "Commit message"
```
```python
ai! how to remove all containers and images in docker. Only commands please
# docker stop $(docker ps -a -q)
# docker rm $(docker ps -a -q)
# docker rmi $(docker images -a -q)
```

### Get Python code
```python
ai! send post request with json data on python
# import requests
# import json
# 
# url = 'http://example.com/api/1/users'
# data = {
#   "first_name": "John",
#   "last_name": "Smith"
# }
# 
# headers = {'Content-type': 'application/json'}
# response = requests.post(url, data=json.dumps(data), headers=headers)
```

### Generate data
```python
ai! give me json where keys are fruits and values are most common fruit color
# {
#     "Apple": "Red",
#     "Banana": "Yellow",
#     "Orange": "Orange",
#     "Grape": "Purple",
#     "Strawberry": "Red",
#     "Lemon": "Yellow",
#     "Kiwi": "Green",
#     "Cherry": "Red",
#     "Watermelon": "Green"
# }
```
Using the data:
```python
import json
j = json.loads($(ai give me small json))
j
# {'name': 'John', 'age': 25}
```

## Known issues

To use [`gpt-4`](https://platform.openai.com/docs/models/gpt-4) model join [wait list](https://openai.com/waitlist/gpt-4-api).

## Credits

This package was created with [xontrib template](https://github.com/xonsh/xontrib-template).


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/anki-code/xontrib-openai",
    "name": "xontrib-openai",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "xontrib,xonsh",
    "author": "anki-code",
    "author_email": "a@a.a",
    "download_url": "https://files.pythonhosted.org/packages/fc/bd/56413c4ce62b6a6f211201a60ad1d190ce842037dafa192eaab5c8ab3fef/xontrib_openai-0.1.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\nUse Open AI models in xonsh shell.\n</p>\n\n<p align=\"center\">  \nIf you like the idea click \u2b50 on the repo and <a href=\"https://twitter.com/intent/tweet?text=Nice%20xontrib%20for%20the%20xonsh%20shell!&url=https://github.com/anki-code/xontrib-openai\" target=\"_blank\">tweet</a>.\n</p>\n\n\n## Installation\n\nTo install use pip:\n\n```xsh\nxpip install -U xontrib-openai\n# or: xpip install -U git+https://github.com/anki-code/xontrib-openai\n```\n\n## Usage\n\n```python\n$OPENAI_API_KEY = 'abcd1234'  # https://platform.openai.com/account/api-keys\n\n# Defaults:\n# $OPENAI_MODEL = 'text-davinci-003'  # https://platform.openai.com/docs/models/overview\n# $OPENAI_MAX_TOKENS = 500\n\nxontrib load openai\n\nai! hello\n# Hello! How are you?\n```\nIn case you need addon with new model:\n```python\naliases['ai4'] = \"$OPENAI_MODEL='gpt-4' $OPENAI_MAX_TOKENS=1000 @('ai')\"\n\nai4! hello gpt-4\n# Hello human\n```\n\n### Get shell commands\n```python\nai! how to git commit. Give me only command\n# git commit -m \"Commit message\"\n```\n```python\nai! how to remove all containers and images in docker. Only commands please\n# docker stop $(docker ps -a -q)\n# docker rm $(docker ps -a -q)\n# docker rmi $(docker images -a -q)\n```\n\n### Get Python code\n```python\nai! send post request with json data on python\n# import requests\n# import json\n# \n# url = 'http://example.com/api/1/users'\n# data = {\n#   \"first_name\": \"John\",\n#   \"last_name\": \"Smith\"\n# }\n# \n# headers = {'Content-type': 'application/json'}\n# response = requests.post(url, data=json.dumps(data), headers=headers)\n```\n\n### Generate data\n```python\nai! give me json where keys are fruits and values are most common fruit color\n# {\n#     \"Apple\": \"Red\",\n#     \"Banana\": \"Yellow\",\n#     \"Orange\": \"Orange\",\n#     \"Grape\": \"Purple\",\n#     \"Strawberry\": \"Red\",\n#     \"Lemon\": \"Yellow\",\n#     \"Kiwi\": \"Green\",\n#     \"Cherry\": \"Red\",\n#     \"Watermelon\": \"Green\"\n# }\n```\nUsing the data:\n```python\nimport json\nj = json.loads($(ai give me small json))\nj\n# {'name': 'John', 'age': 25}\n```\n\n## Known issues\n\nTo use [`gpt-4`](https://platform.openai.com/docs/models/gpt-4) model join [wait list](https://openai.com/waitlist/gpt-4-api).\n\n## Credits\n\nThis package was created with [xontrib template](https://github.com/xonsh/xontrib-template).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Use Open AI models in xonsh shell.",
    "version": "0.1.0",
    "split_keywords": [
        "xontrib",
        "xonsh"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f06915f79a38d6ff04eccfee23141f69f76952303fbc0078f40b81a6d3716853",
                "md5": "107bb8473801a72c2b83e0d4ab2fea1a",
                "sha256": "a22331364affa1a726437f61941974a618bd8d93971c00f4ddcdfc7047ef59da"
            },
            "downloads": -1,
            "filename": "xontrib_openai-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "107bb8473801a72c2b83e0d4ab2fea1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 3423,
            "upload_time": "2023-03-26T18:33:43",
            "upload_time_iso_8601": "2023-03-26T18:33:43.484948Z",
            "url": "https://files.pythonhosted.org/packages/f0/69/15f79a38d6ff04eccfee23141f69f76952303fbc0078f40b81a6d3716853/xontrib_openai-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fcbd56413c4ce62b6a6f211201a60ad1d190ce842037dafa192eaab5c8ab3fef",
                "md5": "8a27cdab53071296786181f521304f23",
                "sha256": "0c10632c94bb19f97540b6f114e886b0c7820b57892dbd71d44899b6fdd05da0"
            },
            "downloads": -1,
            "filename": "xontrib_openai-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8a27cdab53071296786181f521304f23",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3082,
            "upload_time": "2023-03-26T18:33:45",
            "upload_time_iso_8601": "2023-03-26T18:33:45.123465Z",
            "url": "https://files.pythonhosted.org/packages/fc/bd/56413c4ce62b6a6f211201a60ad1d190ce842037dafa192eaab5c8ab3fef/xontrib_openai-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-26 18:33:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "anki-code",
    "github_project": "xontrib-openai",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "xontrib-openai"
}
        
Elapsed time: 0.04921s