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.1.0.tar.gz (29.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.1.0-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: infinity_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 29.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.1.0.tar.gz
Algorithm Hash digest
SHA256 7e7a463730fbaf3fa787ed998a74f3190affc46c3c64566f05e70d88ab1ff040
MD5 ed54f797b5f6d5c86027a0564718c524
BLAKE2b-256 5c723c42c806ef2c1c4af9485af422870d0d1a8fd4dccb7712fe9917081e4291

See more details on using hashes here.

File details

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

File metadata

  • Download URL: infinity_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d27acd195d91c886503ed3d20efcdb042b57037b8b86ac9a0cc395437219d419
MD5 88977015d0050743f4d8cca4daf27ae4
BLAKE2b-256 9e55bfd820fe75e873eceeeef0e1d8f6fa70d30067deedc692465bda61cb5412

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

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