Skip to main content

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.

Metadata

Release files for gptclientai 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for gptclientai 0.3.0
File Interpreter ABI Platform
gptclientai-0.3.0-py3-none-any.whl Python 3 none any Details

Release files / gptclientai-0.3.0-py3-none-any.whl

Download URL gptclientai-0.3.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bded3a817e418388cba839faba5c7a06c89d5678a420a2af68634b4c1a05e423
BLAKE2b-256 checksum
How to use checksums
8c0ea85984afcdca13435a89050f123a6cce9716c6153e877b8cbf78a2a9262c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page