Wrapper for creating ChatGPT callable functions from docstrings
Project description
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:
pip install chatgpt-function
Usage
-
Import the
chatgpt_function
module:from chatgpt_function import chatgpt_wrapper
-
Define your function with a docstring using the
@chatgpt_wrapper
decorator:@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
-
Access the function's description using
chatgpt_function()
:function_description = my_function.chatgpt_function()
This will provide you with a JSON-like description that you can use as input to ChatGPT.
-
Use the function in ChatGPT:
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file chatgpt-function-0.1.2.tar.gz
.
File metadata
- Download URL: chatgpt-function-0.1.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93a88d83dee640ac032eafe0c86440b95156e7549dd68181d92faff7a9531706 |
|
MD5 | dcba8ca1058b60ef75483610b86e2da8 |
|
BLAKE2b-256 | 7ed2e579f2d6f493438ffd6eb15e698de0659352eeffd918fb62001c51cd0bd8 |
File details
Details for the file chatgpt_function-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: chatgpt_function-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d14edc6df234b14740198dcd04d6e618684e2f4e2ea1fa76350d2271f74e631c |
|
MD5 | 1f60441d7f9466ad2e15b7edb3696758 |
|
BLAKE2b-256 | 4d8075e3dcffbbf453532febf13b39628c16156a01696f03fcb4759703f9de32 |