Collection of utilities for use with OpenAI's GPT-3 language model
Project description
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
- By importing the GPT class from gpt_utils.core and setting GPT.api_key
- By passing the key as keyword argument api_key to any method which obtains a response from OpenAI's servers
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.generate_stem()
Accepts a string 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'
utils.fix_case()
Adjusts case of input words/phrases for insertion mid-sentence:
>>> utils.fix_case('bicycles on inman street')
'bicycles on Inman Street'
>>> utils.fix_case('An italian restaurant in Somerville')
'an Italian restaurant in Somerville'
utils.dechatify()
Converts Internet/SMS vernacular to standard/written English. Takes an optional reverse keyword argument which, if true, causes the function to convert from standard English to Internet/SMS speak:
>>> utils.dechatify('how r u')
'How are you?'
>>> utils.dechatify("If the implementation is easy to explain, it may be a good idea.", reverse=True)
'if the implementation is easy to explain, it may be a good idea'
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
Hashes for gpt_utils-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e60ebc7e02c2c0dfb3733c82bf52def92dd6132e1bb56e9737b9ad27dbdf0ca4 |
|
MD5 | 45254d5e45652f7c5e4a63a28adf39bc |
|
BLAKE2b-256 | 0ecd635cf2b7aafbca3bcf852864158f95249b33df4560e326d5134539255d10 |