InfinityAgent — Async LLM Client
强类型、可扩展的 LLM 异步客户端库 — 支持 OpenAI 兼容 API、流式对话、工具调用。
✨ Features
| 类别 | 能力 |
|---|---|
| 类型安全 | Pydantic 负载校验 · pyright strict |
| 多 Provider | 工厂注册模式,轻松扩展新 LLM 服务商 |
| OpenAI 兼容 | 完整实现 OpenAI Chat Completions 流式 API |
| 工具调用 | ToolRegistry 自动从 Python 函数推断 Tool Schema |
| 流式对话 | stream_chat() 异步生成器,支持 Text / ToolCall / Usage chunk |
| 多模态消息 | 文本 + 图片 URL 混合内容 |
| 连接管理 | 指数退避重试 + 抖动 + 连接池复用 |
📦 Installation
pip install infinity_agent
🚀 Quick Start
from infinity_agent import (
Message, Messages,
OpenAIConfig, create_client,
ToolRegistry,
)
# 创建客户端
config = OpenAIConfig(
model="gpt-4o-mini",
api_key="sk-...",
)
client = create_client(config)
# 流式对话
messages = Messages([
Message.system("你是一个有用的助手"),
Message.user("你好"),
])
async with client:
async for chunk in client.stream_chat(messages):
print(chunk)
🧱 Architecture
infinity_agent/
├── clients/ # 客户端抽象 + provider 实现
│ ├── base.py # LLMClient 抽象基类
│ ├── config.py # ConnectionConfig / LLMConfig
│ ├── exceptions.py # 异常层级
│ ├── provider.py # 工厂注册表
│ └── open_ai/ # OpenAI 兼容实现
├── models/ # 消息 / Chunk / 工具定义
│ ├── messages.py # Message, Messages, ToolCall
│ ├── chunks.py # StreamChunk 子类
│ └── tools.py # ToolDefinition, ParameterProperty
└── tools/ # 工具注册与类型推断
├── registry.py # ToolRegistry
└── introspection.py # 函数 → ToolDefinition 自动推断
📄 License
Part of InfinitySystem
Metadata
Release files for infinity_agent 0.2.1
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 |
|---|---|---|---|---|
| infinity_agent-0.2.1.tar.gz | 33.6 kB | Without provenance | Details for infinity_agent-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| infinity_agent-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for infinity_agent-0.2.1-py3-none-any.whl |
Total release size: 77.7 kB
Release files / infinity_agent-0.2.1.tar.gz
| Download URL | infinity_agent-0.2.1.tar.gz |
|---|---|
| Size | 33.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a734dafbb2e148632571d8c0c9b58b85c8c37ed1e5f5e9177a35597f8a11125f
|
|
BLAKE2b-256 checksum How to use checksums |
4f1a4341679896e02593a3c75616e5a8f44e9597e73222296aab31f42dda2657
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / infinity_agent-0.2.1-py3-none-any.whl
| Download URL | infinity_agent-0.2.1-py3-none-any.whl |
|---|---|
| Size | 44.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b4ad86b504977cc18baddb3b8d212fc80691d4746ec07794de7563932ee2f71
|
|
BLAKE2b-256 checksum How to use checksums |
1d6a7e561b39c07d8e2fcc8bf64d74e014211fa6acbb6bb52b4406756978da8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for infinity_agent 0.2.1
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.