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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b87e32a76fd6d05086dfa9085ff82f70544f199dee67152b34a44d32f009937 |
|
MD5 | 5e4f48132fe2b9a7f0eba0464ee22137 |
|
BLAKE2b-256 | 23051f8601684fed592a191e85b6af9919b77256757c288ba729e11e58563bb7 |