PyGPTs: Seamless Integration with Hugging Face and AI APIs
PyGPTs simplifies interaction with various AI models, including Hugging Face Transformers and pre-trained models available through APIs like Google Gemini. It provides a streamlined interface for managing models, pipelines, and tokenizers, handling rate limits, and accessing different model configurations.
Key Features
- Hugging Face Integration: Easily load and utilize pre-trained models from Hugging Face's
transformerslibrary. Configure models, tokenizers, and pipelines with flexible settings. - Gemini API Support: Interact with Google's Gemini models through a dedicated wrapper. Manage API keys, track usage limits, and handle different model versions.
- Rate Limiting: Built-in rate limiting for Gemini API calls to avoid exceeding quotas and ensure continuous operation.
- Multiple Model Management: The
GeminiManagerallows using multiple Gemini models with different API keys, automatically switching between them based on availability and usage limits. - Simplified Interface: PyGPTs provides a clean and easy-to-use API for generating text, managing chat sessions, and accessing model information.
- Extensible Design: Built with modularity in mind, PyGPTs can be extended to support other AI APIs and model providers.
Installation
-
With pip:
pip install PyGPTs
-
With git:
pip install git+https://github.com/oddshellnick/PyGPTs.git
Modules:
PyGPTs.Gemini: Provides classes for interacting with Google Gemini:PyGPTs.HuggingFace: Provides classes for seamless integration with Hugging Face:
Usage Examples
Gemini:
from PyGPTs.Gemini.client import GeminiClientSettings, GeminiClient
settings = GeminiClientSettings(api_key="YOUR_API_KEY")
gemini = GeminiClient(settings)
gemini.start_chat()
response = gemini.send_message("Hello, Gemini!")
print("".join([part.text for candidate in response.candidates for part in candidate.content.parts]))
Hugging Face:
from PyGPTs.HuggingFace.Transformers import HF_TransformerSettings, HF_Transformer
from transformers import AutoModelForCausalLM
settings = HF_TransformerSettings(
pretrained_model_name_or_path="gpt2",
model_class=AutoModelForCausalLM,
task="text-generation"
)
transformer = HF_Transformer(settings)
generated_text = transformer.generate_content("Once upon a time")
print(generated_text)
This library offers a powerful and convenient way to integrate various AI models into your projects. Its flexible design and comprehensive feature set make it a valuable tool for developers working with large language models and other AI-driven applications.
Future Notes
PyGPTs is an actively developing project. We are continually working on expanding its capabilities, including adding support for new AI models and APIs, improving performance, and enhancing the user experience. Contributions, feature requests, and bug reports are welcome! We encourage you to get involved and help shape the future of PyGPTs.
Metadata
Release files for PyGPTs 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygpts-2.1.0.tar.gz | 29.9 kB | Without provenance | Details for pygpts-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyGPTs-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for PyGPTs-2.1.0-py3-none-any.whl |
Total release size: 69.1 kB
Release files / pygpts-2.1.0.tar.gz
| Download URL | pygpts-2.1.0.tar.gz |
|---|---|
| Size | 29.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67b6249628d1bc1f597b03dc7348243c8e0330a228216ad3d916f378fc4e975f
|
|
BLAKE2b-256 checksum How to use checksums |
f272111066a0375ad57d6e5277f90ef0559cd4582456c0d5b6e57ef6679c43d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / PyGPTs-2.1.0-py3-none-any.whl
| Download URL | PyGPTs-2.1.0-py3-none-any.whl |
|---|---|
| Size | 39.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ee0e2b69e3cf1d5f82de6845e4ce15f92d8bc22c8f340e7ceb10dcba7776fe6
|
|
BLAKE2b-256 checksum How to use checksums |
3b4db42dcd876b7d6cbad3995ed9ec613a0477508ce14085a5e4ca70ff4fd9b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for PyGPTs 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.