Skip to main content

PyGPTs simplifies interacting with AI models like Hugging Face Transformers and Google Gemini. It streamlines model management, handles rate limits, and provides an easy-to-use API for text generation and chat sessions.

Project description

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 transformers library. 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 GeminiManager allows 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 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.

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

pygpts-2.0.2.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

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

PyGPTs-2.0.2-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file pygpts-2.0.2.tar.gz.

File metadata

  • Download URL: pygpts-2.0.2.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for pygpts-2.0.2.tar.gz
Algorithm Hash digest
SHA256 139180827f4a05067943cf4c0bbad06a573a4c04bc9e2894c47421f1c2e58277
MD5 aa287bc8665c22140de1213c57e3d611
BLAKE2b-256 408c961c3d25b0540038aa122fd4b055341ce2beb0d0cdef21efbf54176193b6

See more details on using hashes here.

File details

Details for the file PyGPTs-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: PyGPTs-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for PyGPTs-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2169b54c32058bfc3e3f26e6ba672f3d30c93c7536893b2eb7e5ca8af2e11862
MD5 45c3ab67bf2bd03a59312af9607c11fe
BLAKE2b-256 711ab578846b595ddc4fc0deba863ea6d720faeb071fef52b941b37d9d67ebb7

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