Skip to main content

统一的LLM调用库,支持多种LLM提供商、文件上传、环境感知

Project description

LLM Hub - Unified LLM Calling Library

English 中文 PyPI version Python versions License

A unified calling library supporting multiple LLM providers (International + Chinese AI), providing a consistent API interface.

📖 API Reference documentation can be found in the docs/ directory

✨ Features

  • 🔌 Unified API - One interface for all LLM providers
  • 🌍 Multi-Provider Support - OpenAI, DeepSeek, Kimi, Gemini, Claude, etc.
  • 🇨🇳 Chinese AI Support - Qwen, GLM, ERNIE, MiniCPM
  • 💻 Local Deployment - Ollama, llama.cpp
  • 🤔 Reasoning Mode - Display thinking process (DeepSeek support)
  • 📊 Accurate Token Counting - Official tokenizers for each provider
  • 📡 Streaming Output - Real-time response generation
  • 📁 File Upload - Support for PDF, Word, Excel, PPT, Image OCR, and more
  • 💾 Configuration Management - JSON/YAML config, profiles, environment variables
  • 🔌 Plugin System - Support for third-party Provider extensions

📋 Supported Providers

Provider Type Token Counting Reasoning Mode
OpenAI Cloud ✅ tiktoken
DeepSeek Cloud ✅ deepseek-tokenizer
Kimi Cloud ✅ API
Google Gemini Cloud ⚠️ Estimation
Anthropic Claude Cloud ⚠️ Estimation
Qwen Cloud ✅ transformers
GLM Cloud ✅ transformers
ERNIE Cloud ✅ transformers
MiniCPM Cloud/Local ✅ transformers
Ollama Local ✅ API tokenize
llama.cpp Local ✅ Subprocess

📁 Supported File Formats

Category Formats Dependencies
Text .txt, .md, .json, .csv Built-in
Code .py, .js, .java, .go, .cpp, etc. Built-in
Documents .pdf, .docx, .xlsx, .pptx Optional
Images .png, .jpg, .jpeg (OCR) Optional
Web .html, .xml Optional
Config .yaml, .toml, .ini Optional
eBook .epub Optional

🚀 Installation

# Basic installation
pip install gracefox-llm-hub

# Install environment sensing support (system resource monitoring)
pip install gracefox-llm-hub[env]

# Install accurate token counting
pip install gracefox-llm-hub[tokenizers]

# Install file upload support (all formats)
pip install gracefox-llm-hub[files-all]

# Install all features
pip install gracefox-llm-hub[all]

⚙️ Configuration

Supports JSON/YAML config files, environment variables, code parameters, and more.

{
    "provider": "deepseek",
    "model": "deepseek-chat",
    "api_key": "your-api-key",
    "temperature": 0.7,
    "max_tokens": 2000,
    "reasoning": true,
    "stream": true
}

Configuration priority (low to high): Default → Environment variables → Profiles → Config files → JSON string → Code parameters

📦 Project Structure

llm-hub/
├── llm_hub/
│   ├── core/           # Core functionality (client, enums, exceptions)
│   ├── config/         # Configuration management (config, manager, security)
│   ├── models/         # Data models (message, conversation, response)
│   ├── providers/      # Provider implementations (base, factory, providers)
│   ├── environment/    # Environment sensing (optional, system monitoring)
│   └── utils/          # Utilities
│       ├── file_loader/    # File upload (multi-format support)
│       ├── stream_handler/ # Stream handling
│       ├── rate_limiter/   # Rate limiting
│       └── logger.py       # Logging system
├── docs/               # API reference documentation
├── examples/           # Example code
└── pyproject.toml      # Project configuration

🔧 Development

# Development installation
pip install -e .[dev,all]

# Code formatting
black llm_hub/

# Code linting
ruff check llm_hub/

# Type checking
mypy llm_hub/

🔌 Plugin System

LLM Hub supports third-party Provider extensions through the entry points mechanism.

# setup.py
setup(
    entry_points={
        "llm_hub.providers": [
            "my_provider = my_package:MyProvider",
        ]
    }
)

🤝 Contributing

Contributions are welcome! Please feel free to submit Pull Requests.

📄 License

GNU General Public License v3.0

📧 Contact


Quick Reference

Installation Options

Option Description Dependencies
[env] Environment sensing psutil
[tokenizers] Accurate token counting tiktoken, transformers
[secure] Secure encryption cryptography
[yaml] YAML configuration pyyaml
[files-all] All file format support pypdf, python-docx, openpyxl, etc.
[all] All features All of the above

Supported Providers

Provider Config Value Example Model
OpenAI openai gpt-3.5-turbo
DeepSeek deepseek deepseek-chat
Kimi kimi moonshot-v1-8k
Qwen qwen qwen-turbo
GLM glm glm-4-flash
ERNIE ernie ernie-3.5-8k
Ollama ollama llama2
llama.cpp llama_cpp llama-2-7b

API Key Acquisition

Provider URL
OpenAI https://platform.openai.com/api-keys
DeepSeek https://platform.deepseek.com/api_keys
Kimi https://platform.moonshot.cn/console/apiKey
Qwen https://dashscope.console.aliyun.com/apiKey
GLM https://open.bigmodel.cn/usercenter/apikeys
ERNIE https://console.bce.baidu.com/ai_platform/

📖 Complete API reference documentation and usage examples can be found in the docs/ directory

⭐ If you find this useful, please give it a Star on Gitee!

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

gracefox_llm_hub-0.2.2.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

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

gracefox_llm_hub-0.2.2-py3-none-any.whl (104.8 kB view details)

Uploaded Python 3

File details

Details for the file gracefox_llm_hub-0.2.2.tar.gz.

File metadata

  • Download URL: gracefox_llm_hub-0.2.2.tar.gz
  • Upload date:
  • Size: 96.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for gracefox_llm_hub-0.2.2.tar.gz
Algorithm Hash digest
SHA256 559d2c3c0fc13437638a18d1d941a86b447d92ac2ea63ef66f398c9b4e6fd1e3
MD5 ffcc26211cc3cf84534a3e556b48cf6c
BLAKE2b-256 eb8b37957027fb5f8fd6b473a3cb8dbb65b4383ae62b9136ee46b1076eb16cb6

See more details on using hashes here.

File details

Details for the file gracefox_llm_hub-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for gracefox_llm_hub-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22e7782740800c9274bd8ff39aae59f82e06dfb8925afeea871f161fdc2576f4
MD5 74b9f9bebecb641ae33ed23198eb8d49
BLAKE2b-256 a4fed9505406af1c75de9e81f0f5f0747ad8ae495e42ceafa94d19888ffe23ef

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