Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

my-llm-py

Latest version: v2.2.2

Overview

Last scanned
29 Nov 2026
Published
29 Nov 2026
PyPI package Publisher: JJJJustiYYYY
3 Stars
1 Forks
31 Versions
2.5K Downloads
Python Repo language

Scan summary

my-llm-py was last scanned on 29 Nov 2026 at version 2.2.2. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 31 versions; the latest 5 were published within 5 days (25–29 Nov 2026).
  • Findings: No rules fired in version 2.2.2.
  • Downloads: 2,475 downloads.

Versions

31 versions published
Versions and the rules that fired in each
VersionPublishedStatus
2.2.2 LATEST 29 Nov 2026 No rules fired
2.2.1 28 Nov 2026 No rules fired
2.2.0 28 Nov 2026 No rules fired
2.1.0 27 Nov 2026 Not shown
2.0.5 25 Nov 2026 Not shown

No rules fired in 2.2.2

Findings

Findings for v2.2.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 2.2.2; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

my-llm-py

PyPI Python License Discord

通用的 LLM Provider 协议适配器

my-llm-py 是一个 Python 异步 LLM 协议适配库,支持 OpenAI Chat、OpenAI Responses、Anthropic 三种协议自由组合。

用一种协议请求另一种协议的 API,按输入协议返回结果。标准协议直接转换,非标准协议通过配置兼容。

OpenAI Chat 格式输入 → 任意协议 API → OpenAI Chat 格式输出

消息、工具和流事件一并转换。更换上游 API,业务层继续使用原有协议收发数据。 本项目面向调用方使用固定消息协议的场景;MyLLM 按 stdio_protocol 返回对应协议的消息, 便于直接续接同一协议的历史。不支持混合协议历史输入,详见输入输出协议约定。 业务调用使用 MyLLM.generate / generate_json;离线翻译使用 MyCodec.encode / decode / convert,各自可独立使用。 请求准备和原生协议组件属于内部实现,不作为独立业务入口。

主要功能

功能 说明
跨协议调用 输入输出协议与上游 API 独立选择,消息、工具和流事件一并转换。
标准输入输出 接受标准字典或官方 SDK 对象,完成消息随输入选择字典/SDK 对象表示;流事件保持原格式。
统一工具调用 转换工具定义、调用和结果;流式参数自动组装,成功结束后交付完整调用,由应用执行。
流式与完整回复 支持文本、可见思考增量,流结束后通过 stream.result 获取完整消息。
多模态转换 支持文本、用户图片、工具结果图片、思维链及 usage;转换受目标协议能力限制。
语义损失处理 已支持内容无法表达时默认抛 SemanticLossError,可选 ignore 或双向 hook 补偿。
Profile 配置兼容 用 InputParameter / OutputParameter 配置字段路径与默认值,Config 控制行为;适配服务与模型差异。
中间模型直连 显式 stdio_protocol="middleware",直接用中间模型收发消息、工具与流事件。
增量消息缓存 缓存已翻译的增量历史,连续重发相同批次不重复追加;开启后同实例串行使用,见缓存约定。
异步与资源管理 关闭消息缓存时支持同实例并发;支持取消、提前退出和资源清理,见架构职责。
独立格式转换 无需调用模型,即可转换已支持的消息、工具和完整流事件列表。
协议扩展 实现四个抽象基类,通过 MyCodec.register(CodecFactory) 注册;无需修改公共入口,见接入指南。
字段保留边界 只翻译已识别字段;工具参数、结果和 JSON Schema 等开放字典保留内部键值;audio、file、用户 metadata 等未支持字段静默丢弃。

安装

需要 Python 3.12+。

pip install 'my-llm-py[all]'
# 或 uv add 'my-llm-py[all]'

推荐使用 [all] 安装全部 SDK。也可以按需选择,支持用逗号组合多个 extra:

pip install 'my-llm-py[openai]'
pip install 'my-llm-py[anthropic]'
pip install 'my-llm-py[openai,anthropic]'

pip install my-llm-py 仅安装核心依赖。每种输入、输出及上游协议都需要对应 SDK; 例如 Chat 输入调用 Anthropic API 需要 [openai,anthropic]。 中间模型 stdio 只需要安装上游对应 SDK。 未安装的协议不会注册,显式选择时会提示安装命令。

项目开发环境执行 uv sync 默认安装开发工具和全部 SDK。 仅安装指定 SDK 可使用 uv sync --no-default-groups --extra openai。

快速开始

以下示例使用 OpenAI Chat 格式调用 Anthropic Messages API,返回 Chat assistant 消息。 设置 ANTHROPIC_API_KEY 和 LLM_MODEL 环境变量后运行,模型 ID 填写服务支持的值。

import asyncio
import os

from my_llm import Attribute, Config, ModelProfile, MyLLM, InputParameter, ProviderProfile


async def main():
    llm = MyLLM(
        provider=ProviderProfile(
            protocol=Config(default_value="anthropic"),
            api_key=InputParameter(path="$.api_key", default_value=os.environ["ANTHROPIC_API_KEY"]),
        ),
        model=ModelProfile(
            model=Attribute(default_value=os.environ["LLM_MODEL"]),
            max_tokens=InputParameter(path="$.max_tokens", default_value=4096),
        ),
        stdio_protocol="openai_chat",
    )
    message = await llm.generate(messages=[{"role": "user", "content": "你好"}])
    print(message["content"])


asyncio.run(main())

通过 provider.protocol 配置默认上游 API,model.protocol 可覆盖它;stdio_protocol 决定业务层使用的格式。 建议像示例一样显式指定 stdio_protocol。省略时仅在消息与工具整批唯一匹配一种协议时自动绑定; 零匹配或多种协议都匹配时抛出 MessageValidationError。普通 role/content 文本存在协议歧义,需要显式指定。

流式调用

将上例的 MyLLM 实例设为 stdio_protocol="openai_chat" 后调用下面的函数,流事件也按 Chat 协议返回:

async def print_answer(llm):
    stream = await llm.generate(
        messages=[{"role": "user", "content": "你好"}],
        stream=True,
    )
    async with stream:
        async for event in stream:
            for choice in event.get("choices", []):
                print(choice["delta"].get("content", ""), end="", flush=True)
    return stream.result

使用 async with 管理响应流,MyLLM 实例无需关闭。传入工具前,在 ModelProfile 中设置 supports_function_calling=Config(default_value=True)。

设置 enable_message_cache=True 可缓存已翻译的增量消息;连续重发相同批次不会重复追加历史。 启用后,同一 MyLLM 实例不支持并发:先完成或关闭前一条流,再调用下一次生成。 不同实例可以并发使用。用法和重试约定见增量消息缓存。

独立格式转换

MyCodec 可离线转换协议格式,无需 API 密钥:

from my_llm import MyCodec

converted = MyCodec().convert(
    [{"role": "user", "content": "你好"}],
    input_format="openai_chat",
    target_format="anthropic",
)
print(converted["messages"])
# [{"role": "user", "content": [{"type": "text", "text": "你好"}]}]

完整响应流也可离线翻译:encode(chunks=完整原生流, input_format=...) 返回公开 MessageEvent 列表, 保存在 ProtocolMiddleWare.stream;decode(chunks=完整中间事件, target_format=...) 可单独调用, 也支持事件经 to_wire() 和 JSON 保存后重新翻译。实时生成使用 MyLLM.generate(stream=True)。

支持的协议

以下标识均可用于 ProviderProfile.protocol、ModelProfile.protocol 和 stdio_protocol:

协议标识 对应 API
openai_chat OpenAI Chat Completions 及兼容服务
openai_responses OpenAI Responses 及兼容服务
anthropic Anthropic Messages

同一实例的消息与工具使用同一种输入输出协议。

验证范围

常规测试使用官方 SDK 与本地模拟 HTTP/SSE,不请求真实模型。 真实服务 E2E 单独覆盖三种上游与四种输入/输出格式的文本、工具回合、能力处理和推理回传。 汇总调用也通过上游 SSE 执行,结果不能证明供应商的 HTTP 非流式接口行为。

运行方法见测试文档,按日期记录的通过项、失败项和验证限制见 测试结果目录。历史结果不作为当前模型或服务行为的保证。

安装最新的开发版本 (main 分支)

git clone https://github.com/JJJJSTIYYYY/my-llm.git
cd ./my-llm
uv sync --group dev --locked
uv run pytest -q
uv run ruff check src tests examples
uv run ruff format --check src tests examples
uv run python examples/local_demo.py
uv build

文档

文档分为四部分,完整导航见项目文档。

  • 使用文档:公开接口、配置、中间模型、语义损失和服务接入。
  • 开发文档:设计取舍、职责边界、协议扩展和构建。
  • 测试文档:测试复现、结果汇总、性能与发行包验证。
  • 审查文档:代码审查、根因、修复记录和不修复决定。

项目采用 Apache License 2.0。

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases my-llm-py

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (3)
Research

Ruby2Shell: Ruby Memory Corruption Flaws Expose Applications to Remote Code Execution, But is it an Actual Risk?

PolinRider Returns
Research

PolinRider Returns: Hijacked npm Packages Use Ethereum Blockchain to Conceal Malware Infrastructure

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Frame 2085668439 (1)
Group 1261154229