Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nicegpt-0.0.7.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

nicegpt-0.0.7-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page