Skip to main content

sdpy-kit

SDPY 统一工具集(Kit 体系),供 Python 项目开箱即用:统一数据库访问层(PostgreSQL / MySQL / SQLite,三个 Kit API 完全一致)+ AI 多模型服务池(chat / embedding / rerank / image,多厂商候选链与故障转移)+ MCP 客户端 + Redis / 文件 / 文档 / 向量库 / MinerU 工具。

要求 Python 3.13+

安装

pip install sdpy-kit
# 或
uv add sdpy-kit

配置(.env)

kit 通过 pydantic-settings 读取项目根目录 .env(默认值见下,均可省略):

# 日志
LOG_LEVEL=INFO
LOG_TO_CONSOLE=true
LOG_TO_FILE=false

# 数据库(三选一,切换只改 DEFAULT_DB_TYPE)
DEFAULT_DB_TYPE=sqlite          # postgresql / mysql / sqlite
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=postgres
DB_USER=admin
DB_PASSWORD=
MYSQL_PORT=3306
MYSQL_DATABASE=mydb
MYSQL_USER=root
SQLITE_DB_PATH=./data/app.db

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

AI / MCP 功能的档案文件

AI 与 MCP 功能需要在项目根目录提供两个 JSON 档案文件:

  • config/ai_models.json —— chat / embedding / rerank / image 四类型多厂商模型档案
  • config/mcp_servers.json —— MCP 服务器档案

文件缺失时,首次使用相应功能会报错,报错信息中附带可直接复制的最小模板; 其中 api_key / token_env 字段填写环境变量名,真实密钥配置在 .env

快速开始

日志与配置

from kit.config import get_settings, get_default_logger

settings = get_settings()
logger = get_default_logger(__name__)
logger.info("hello %s", settings.APP_NAME)

数据库(SQLiteKit / PgKit / MySqlKit API 完全一致,切换只改 import)

from sqlmodel import SQLModel, Field
from kit.db.sqlite_kit import SQLiteKit

class Item(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    name: str

SQLiteKit.connect()
SQLiteKit.create_tables([Item])
item = SQLiteKit.create(Item, {"name": "demo"})

约定:SQLiteKit/PgKit/MySqlKit 方法自动提交;CRUDBase(配合 session_scope)不自动提交;事务用 kit.transactional

模块总览

模块 内容
kit.db 统一数据库访问层:PgKit / MySqlKit / SQLiteKit、CRUDBase、transactional
kit.ai AI 服务池:chat / embedding / rerank / image,多厂商候选链 + 故障转移
kit.mcp_kit 通用 MCP 客户端(streamable-http / sse,档案驱动多服务器)
kit.redis_kit Redis 工具
kit.file_kit 文件工具
kit.doc_kit 文档转换(基于 firecrawl-anydoc / pimd)
kit.zvec_kit zvec 本地向量库
kit.mineru_kit MinerU 文档精准解析 API
kit.common_kit 通用工具

License

MIT

Download files

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

Source Distribution

sdpy_kit-0.1.4.tar.gz (93.0 kB view details)

Uploaded Source

Built Distribution

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

sdpy_kit-0.1.4-py3-none-any.whl (132.0 kB view details)

Uploaded Python 3

File details

Details for the file sdpy_kit-0.1.4.tar.gz.

File metadata

  • Download URL: sdpy_kit-0.1.4.tar.gz
  • Upload date:
  • Size: 93.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sdpy_kit-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d53b54859c22debc6c3e382282da6a1a1510d47a41a5d3504c5f9aa9b78b26c8
MD5 1405c66778ed3cb9aa8f99897accc63c
BLAKE2b-256 c08ee2aae3fa305b21ed65846b008fc89617a83c66f6691703fd6432095d440a

See more details on using hashes here.

File details

Details for the file sdpy_kit-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sdpy_kit-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 132.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sdpy_kit-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9265283470532124df3a6e3be474f556c59fdc52badbc6ce2abdb52010560a0c
MD5 c1374a3f453b162fd857c1cfcec375e5
BLAKE2b-256 42a9261fdb64af2ebd7f798f71d9cb9749419a7e2517cb6b93cf22248499bd44

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

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