chatgpt-function


Namechatgpt-function JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/rrhd/chatgpt_function
SummaryWrapper for creating ChatGPT callable functions from docstrings
upload_time2023-10-10 01:12:41
maintainer
docs_urlNone
authorRon Heichman
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ChatGPT Function Wrapper

## Overview

This project provides a Python function wrapper that simplifies the process of converting functions with docstrings into callable functions for ChatGPT. It parses the docstring of a function and creates a description that ChatGPT can use.

## Installation

You can install this package using pip:

```bash
pip install chatgpt-function
```

## Usage

1. Import the `chatgpt_function` module:

   ```python
   from chatgpt_function import chatgpt_wrapper
   ```

2. Define your function with a docstring using the `@chatgpt_wrapper` decorator:

   ```python
   @chatgpt_wrapper
   def my_function(my_arg: str) -> str:
       '''This is my function.

       Args:
           my_arg (str): This is my argument.

       Returns:
           str: This is my return value.
       '''
       return "Hello World!" + my_arg
   ```

3. Access the function's description using `chatgpt_function()`:

   ```python
   function_description = my_function.chatgpt_function()
   ```

   This will provide you with a JSON-like description that you can use as input to ChatGPT.

4. Use the function in ChatGPT:

   ```python
   from openai import ChatCompletion

   response = ChatCompletion.create(
       messages=messages,
       functions=[function_description],
       **kwargs
   )
   ```

## License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2023 Ron Heichman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rrhd/chatgpt_function",
    "name": "chatgpt-function",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ron Heichman",
    "author_email": "ronheichman@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/d2/e579f2d6f493438ffd6eb15e698de0659352eeffd918fb62001c51cd0bd8/chatgpt-function-0.1.2.tar.gz",
    "platform": null,
    "description": "# ChatGPT Function Wrapper\n\n## Overview\n\nThis project provides a Python function wrapper that simplifies the process of converting functions with docstrings into callable functions for ChatGPT. It parses the docstring of a function and creates a description that ChatGPT can use.\n\n## Installation\n\nYou can install this package using pip:\n\n```bash\npip install chatgpt-function\n```\n\n## Usage\n\n1. Import the `chatgpt_function` module:\n\n   ```python\n   from chatgpt_function import chatgpt_wrapper\n   ```\n\n2. Define your function with a docstring using the `@chatgpt_wrapper` decorator:\n\n   ```python\n   @chatgpt_wrapper\n   def my_function(my_arg: str) -> str:\n       '''This is my function.\n\n       Args:\n           my_arg (str): This is my argument.\n\n       Returns:\n           str: This is my return value.\n       '''\n       return \"Hello World!\" + my_arg\n   ```\n\n3. Access the function's description using `chatgpt_function()`:\n\n   ```python\n   function_description = my_function.chatgpt_function()\n   ```\n\n   This will provide you with a JSON-like description that you can use as input to ChatGPT.\n\n4. Use the function in ChatGPT:\n\n   ```python\n   from openai import ChatCompletion\n\n   response = ChatCompletion.create(\n       messages=messages,\n       functions=[function_description],\n       **kwargs\n   )\n   ```\n\n## License\n\nThis project is licensed under the MIT License.\n\nMIT License\n\nCopyright (c) 2023 Ron Heichman\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Wrapper for creating ChatGPT callable functions from docstrings",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/rrhd/chatgpt_function"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d8075e3dcffbbf453532febf13b39628c16156a01696f03fcb4759703f9de32",
                "md5": "1f60441d7f9466ad2e15b7edb3696758",
                "sha256": "d14edc6df234b14740198dcd04d6e618684e2f4e2ea1fa76350d2271f74e631c"
            },
            "downloads": -1,
            "filename": "chatgpt_function-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f60441d7f9466ad2e15b7edb3696758",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3771,
            "upload_time": "2023-10-10T01:12:40",
            "upload_time_iso_8601": "2023-10-10T01:12:40.311979Z",
            "url": "https://files.pythonhosted.org/packages/4d/80/75e3dcffbbf453532febf13b39628c16156a01696f03fcb4759703f9de32/chatgpt_function-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ed2e579f2d6f493438ffd6eb15e698de0659352eeffd918fb62001c51cd0bd8",
                "md5": "dcba8ca1058b60ef75483610b86e2da8",
                "sha256": "93a88d83dee640ac032eafe0c86440b95156e7549dd68181d92faff7a9531706"
            },
            "downloads": -1,
            "filename": "chatgpt-function-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "dcba8ca1058b60ef75483610b86e2da8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3496,
            "upload_time": "2023-10-10T01:12:41",
            "upload_time_iso_8601": "2023-10-10T01:12:41.714712Z",
            "url": "https://files.pythonhosted.org/packages/7e/d2/e579f2d6f493438ffd6eb15e698de0659352eeffd918fb62001c51cd0bd8/chatgpt-function-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-10 01:12:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rrhd",
    "github_project": "chatgpt_function",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "chatgpt-function"
}
        
Elapsed time: 1.18850s