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
- '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)
- '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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gptclientai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gptclientai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66888cb6e8307c29e7402946d3f60ccc24f9049815e2c132dd80bf613766ec77
|
|
| MD5 |
2d214328378bd0263ec84a90214ff3fb
|
|
| BLAKE2b-256 |
73d2d0f252a943bc2f7c35a4629635a893517c59a48a93c998a29ea313f49d6a
|