A simple package to make GPT API usage easier
Project description
nicegpt
A Python package that simplifies the usage of the GPT API by providing a convenient class to manage context-driven instances of GPT models. With nicegpt, you can create instances, change models, and obtain context-driven responses from the GPT model.
Usage
First, make sure you have run the config
function to set up your API key and optionally the organization. If you don't have environment variables set up for the key, you need to run this function.
import nicegpt
nicegpt.config("your_api_key", "your_organization")
Next, create a GPT instance using the GPT class. You can choose the GPT model by accessing the Model enum:
gpt_instance = nicegpt.GPT(model=nicegpt.Model.GPT4)
Now you can obtain context-driven responses using the response function:
response = gpt_instance.response("What is the capital of France?")
Set the just_reply
parameter to obtain the raw JSON instead of the message. You can also pass additional kwargs to the response function, which will be forwarded to the GPT API:
json_response = gpt_instance.response("What is the capital of France?", just_reply=False, max_tokens=50, temperature=0.8)
To change the GPT model, use the change_model function:
gpt_instance.change_model(nicegpt.Model.GPT3_5)
To access the message history, use the get_messages function:
message_history = gpt_instance.get_messages()
print(message_history)
License
This project is released under the MIT License.
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 nicegpt-0.0.7.tar.gz
.
File metadata
- Download URL: nicegpt-0.0.7.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3ca708af4ce3d2a0be06f96ef95d6ff17c1891bd6f62d943011daa9a143a7a0 |
|
MD5 | a3b7091e8a20fdd21d985c4dc0d63bad |
|
BLAKE2b-256 | c49b6dfee6a4371e838d469800cf9a3802dbe0e14a4916fc5f694b6dc659dd28 |
File details
Details for the file nicegpt-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: nicegpt-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1afb85e9ae63f80a9ae12f4ad4bd5b9c9177d4184297830d030b795e99423d7 |
|
MD5 | 415637226bdad494fa035da556188aa6 |
|
BLAKE2b-256 | 79bded889d33e99808402b0b6ca381192efb7901ad1fe7437bb56dc434fc1a52 |