Skip to main content

InfinityAgent — Async LLM Client

Test Pyright License Supported Python

强类型、可扩展的 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

MIT

Part of InfinitySystem

icon

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infinity_agent-0.2.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

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

infinity_agent-0.2.0-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file infinity_agent-0.2.0.tar.gz.

File metadata

  • Download URL: infinity_agent-0.2.0.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

File hashes

Hashes for infinity_agent-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cd8ba043e896c45e6dc2e935a6f3f982ea70851835f808e578a142ef2c166ad2
MD5 ea810e6bc88f769c150f53f50cc121ae
BLAKE2b-256 5f18a90b1573a561f69f7d1f344d271da7b9be280ad05462c19aad828b1320cc

See more details on using hashes here.

File details

Details for the file infinity_agent-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: infinity_agent-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

File hashes

Hashes for infinity_agent-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1683a045cd6b6b852971363dd460fbcc1fe8d6e39acf42787b0f3ba6defe736
MD5 efbc9cbc0daf583b1a47a64a3970820c
BLAKE2b-256 716627d23660e0a73452bbe202d297c5d41779de8365ecf6bb9f0cf01a23d30c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page