This Python package provides a comprehensive and efficient wrapper for the OpenAI API, designed to support advanced application development based on ChatGPT.
Project description
OpenAI API Wrapper for Advanced ChatGPT Development
This Python package provides a comprehensive and efficient wrapper for the OpenAI API, designed to support advanced application development based on ChatGPT. The package simplifies the integration process and offers additional functionalities such as conversation management, model fine-tuning, retrieval of embeddings, automatic question generation, and offline model execution.
Features
- Easy interaction with the OpenAI API for ChatGPT applications
- Conversation management for multiple chat sessions
- Support for fine-tuning the ChatGPT model
- Retrieval of embeddings for specific text passages
- Automatic question generation for given paragraphs
- Offline model execution with compatible models
Installation
You can install the package using pip:
pip install openai-api-wrapper
Usage
Here is a basic example of how to use the OpenAI API Wrapper:
python
from openai_api_wrapper import Chatbot
# Initialize the Chatbot instance
chatbot = ChatBot()
# Generate a reply_contentto the given prompt.
conversation_id = "conversation_1"
prompt = "What is the capital of France?"
print(f"[{conversation_id}] User message: {prompt}")
reply_content= chatbot.ask(conversation_id, prompt)
print(f"[{conversation_id}] AI Response: {reply_content}")
conversation_turns = chatbot.get_conversation_turns(conversation_id)
print(f"[{conversation_id}] Conversation turns: {conversation_turns}")
# Generate a reply_contentto the given prompt using streaming API.
conversation_id = "conversation_2"
prompt = "Tell me a joke."
print(f"[{conversation_id}] User message: {prompt}")
unfinished_reply_content= ""
for chunked_reply_content in chatbot.ask_stream(conversation_id, prompt):
unfinished_reply_content+= chunked_reply_content
print(unfinished_reply_content)
reply_content= chatbot.get_last_reply_content(conversation_id)
print(f"[{conversation_id}] AI Response: {reply_content}")
conversation_turns = chatbot.get_conversation_turns(conversation_id)
print(f"[{conversation_id}] Conversation turns: {conversation_turns}")
For a more detailed example with all the available features, check out the example.py
file in the repository.
Documentation
You can find the complete documentation for this package in the docs
folder, or check out the source code for more details on the implementation.
Roadmap
We plan to continually improve and expand the functionality of this package. Some of the upcoming features include:
- Integration with various machine learning frameworks
- Support for multi-modal inputs (e.g., text, images, audio)
- Expansion of available pre-trained models
- Simplified deployment options for various platforms
Contributing
We welcome contributions from the community! If you'd like to contribute, please follow these steps:
- Fork the repository
- Create a new branch for your changes (
git checkout -b my-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push the branch (
git push origin my-feature
) - Create a new pull request
Please make sure to add tests and documentation for any new features or changes.
License
This project is licensed under the MIT License. See the LICENSE
file for more details.
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
Built Distribution
File details
Details for the file openai-api-wrapper-0.1.0.tar.gz
.
File metadata
- Download URL: openai-api-wrapper-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc60af5b851c948c7ba7c35a4dbe6140c75ac3d1d0e02b3b6660fb8cc26f51c8 |
|
MD5 | e7452d81f8e0d88263a416cece9a55ef |
|
BLAKE2b-256 | c29dbc5c22ef4243abfcebd19c6bf39c10956758771b3074c0b1000f81478da9 |
File details
Details for the file openai_api_wrapper-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: openai_api_wrapper-0.1.0-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.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a49f2ddf82a7e7b269fc799516a1ef5b9826d405e37190ca4d0afa7bde3b33ce |
|
MD5 | c8efeb1007e465429f4dc60c80893d8f |
|
BLAKE2b-256 | db6f0ce1829368604be1a8a7bdb2cea83bcef44828a742a821911e637368d85a |