gpt-utils
Helper tools for use with OpenAI's GPT-3 API.
The API key can be provided in three ways:
- In the environment variable
OPENAI_API_KEY - Via class attribute
GPT.api_keyof classGPTin modulegpt_utils.core - Via keyword argument
api_keyin any method or function which obtains a response from OpenAI's servers
Disclaimer
These don't work perfectly.
gpt_utils.utils
from gpt_utils import utils
utils contains simple functions which transform text in a specific way. Some functions are bidirectional; these take an optional reverse keyword argument which reverses the conversion's input and output.
utils.case
>>> from gpt_utils.utils import case
Contains functions which modify the case of words in a string. These functions are meant to selectively preserve the case of proper nouns, etc. with minimal involvement. The first, title(), takes a str containing a word or phrase with proper capitalization for use in a heading or title:
>>> case.title('the ant: an introduction')
'The Ant: An Introduction'
The second, mid_sentence(), adjusts the case of input words/phrases for insertion mid-sentence:
>>> case.mid_sentence('bicycles on inman street')
'bicycles on Inman Street'
>>> case.mid_sentence('An italian restaurant in somerville')
'an Italian restaurant in Somerville'
utils.location
>>> from gpt_utils.utils import location
Currently contains one function, fix_location(), which takes an unformatted string containing a location and formats it properly for display:
>>> location.fix_location('lenox ma')
'Lenox, MA'
utils.number
>>> from gpt_utils.utils import number
Contains two functions which convert numbers to strings. The first, number_to_str(), takes an int or float and writes out the same number as a str:
>>> number.number_to_str(83)
'eighty-three'
>>> number.number_to_string(3.14)
'three point one four'
The second, number_to_ordinal(), takes an int and returns it in ordinal form as a str:
>>> number.number_to_ordinal(43)
'forty-third'
utils.dechatify()
I have found that GPT tends to produce output of lower quality when it is prompted with text containing Internet/SMS vernacular. As a remedy, dechatify() converts text to standard/written English:
>>> utils.dechatify('how r u')
'How are you?'
>>> utils.dechatify('if the implementation is easy to explain then it might b a good idea')
'If the implementation is easy to explain, then it might be a good idea.'
utils.generate_stem()
This function accepts a str containing a word/phrase and returns a sentence stem pairing the word/phrase with the appropriate form of the verb "to be":
>>> utils.generate_stem('GitHub')
'GitHub is'
>>> utils.generate_stem("pleiades")
'The Pleiades are'
Metadata
Release files for gpt-utils 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gpt_utils-1.2.0.tar.gz | 11.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gpt_utils-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.6 kB
Release files / gpt_utils-1.2.0.tar.gz
| Download URL | gpt_utils-1.2.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e587af3cb74d543c61ee03b5c736e812b59a41798c17528bee82cf319cc8efc9
|
|
BLAKE2b-256 checksum How to use checksums |
15055cb68e5342b6fea730a9f10ceeb5cfe26641d47ef23b013b8ed543e9ebbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.2
|
Release files / gpt_utils-1.2.0-py3-none-any.whl
| Download URL | gpt_utils-1.2.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f201c61e32645b2b2bced9776d6f0658065a4944728e5cee9b7ef187f4c1315
|
|
BLAKE2b-256 checksum How to use checksums |
bf4e33a4540e1051775971f061b495be4ff6bfbe29bbbee8692b79cae003065b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.2
|
Security for gpt-utils 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.