Skip to main content

A Python module for easy integration with GPT-based language models, enabling natural language understanding and generation.

Project description

gptclientai Module

Overview

The gptclientai module provides convenient utility functions for working with chat-based and completion-based responses using various providers. This module includes two main classes: Chat for handling chat conversations and Completion for generating completions.

Installation

You can install the gptclientai module using pip:

pip install gptclientai

Usage

  1. 'Chat' Class

create_chat_response(provider, messages, stream=False)

Returns a string or an iteration for the chat completion.

- Parameters

  • 'provider': The provider to use (e.g., freegpt.Provider.FreeChatGpt).
  • 'messages': Messages of the conversation in a list (e.g., '[{"role": "user", "content": "hello"}]')
  • 'stream' : If "True", returns an iteration; otherwise, returns a string.

- Example

import gptclientai

if __name__ == "__main__":
    res = gptclientai.Chat.create_chat_response(
        provider = gptclientai.Provider.DeepInfra,
        messages = [
            {
                "role": "user",
                "content": "hello"
            }
        ],
        stream = True
    )

    for chunk in res:
        print(chunk)

# -------------------------
import gptclientai

if __name__ == "__main__":
    res = gptclientai.Chat.create_chat_response(
        provider = gptclientai.Provider.DeepInfra,
        messages = [
            {
                "role": "user",
                "content": "hello"
            }
        ],
        stream = False
    )

    print(res)
  1. 'Completion' Class

create_completion(provider, prompt, stream=False)

Returns a string or an iteration for the completion.

- Parameters

  • 'provider': The provider to use (e.g., freegpt.Provider.FreeChatGpt).
  • 'prompt': Messages for the response (e.g., '"Hello!"')
  • 'stream' : If "True", returns an iteration; otherwise, returns a string.

- Example

import gptclientai

if __name__ == "__main__":
    res = gptclientai.Completion.create_create_completion(
        provider = gptclientai.Provider.DeepInfra,
        messages = "Hello",
        stream = True
    )

    for chunk in res:
        print(chunk)

# -------------------------
import gptclientai

if __name__ == "__main__":
    res = gptclientai.Completion.create_create_completion(
        provider = gptclientai.Provider.DeepInfra,
        prompt = "Hello",
        stream = False
    )

    print(res)

License

This module is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 0xseka/sekateur/seka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gptclientai-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file gptclientai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gptclientai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for gptclientai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c0d0fd07074aeb0133808d37fea14b7f2b893f4cc21c48f6b001da8b32bf6ef
MD5 65f9e3c910f8fd79b7948db706449242
BLAKE2b-256 33ec27f47d31f4920b9c5c8ec6e4c6d77f78ffacc155823f831511fe6321ea43

See more details on using hashes here.

Supported by

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