Skip to main content

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:

  1. Fork the repository
  2. Create a new branch for your changes (git checkout -b my-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push the branch (git push origin my-feature)
  5. 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

openai-api-wrapper-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

openai_api_wrapper-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file openai-api-wrapper-0.2.0.tar.gz.

File metadata

  • Download URL: openai-api-wrapper-0.2.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

Hashes for openai-api-wrapper-0.2.0.tar.gz
Algorithm Hash digest
SHA256 908df167c5470c2ea1b76b81a9ff17b3bec146d140916e53e2e81b3aa74a1650
MD5 59999b4b0f15c613bc8291b616504eaa
BLAKE2b-256 34f73b96647388a2f98be60b51cd0b3c724d7f0d5f90bbf2853f066cc2ef5939

See more details on using hashes here.

File details

Details for the file openai_api_wrapper-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openai_api_wrapper-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 725931a8907487759cbe3323bf87c7a6fec947a9544405a3400291d0a2cd7cfa
MD5 471ade0471f72ab53e51379422200b1c
BLAKE2b-256 17e4964542f05eef489d701da9ef3de6350746bf7283a26f22201f5b16056746

See more details on using hashes here.

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