yimo-kit 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. yimo/__init__.py +26 -0
  2. yimo/kit/__init__.py +98 -0
  3. yimo/kit/ai/__init__.py +110 -0
  4. yimo/kit/ai/_internal/__init__.py +27 -0
  5. yimo/kit/ai/_internal/failover.py +535 -0
  6. yimo/kit/ai/_internal/pool.py +526 -0
  7. yimo/kit/ai/_internal/rerank_transport.py +137 -0
  8. yimo/kit/ai/_internal/retry_after.py +51 -0
  9. yimo/kit/ai/_internal/sdk_client.py +463 -0
  10. yimo/kit/ai/_internal/service_base.py +115 -0
  11. yimo/kit/ai/_internal/types.py +28 -0
  12. yimo/kit/ai/agent/__init__.py +127 -0
  13. yimo/kit/ai/agent/approval.py +66 -0
  14. yimo/kit/ai/agent/errors.py +128 -0
  15. yimo/kit/ai/agent/loop.py +643 -0
  16. yimo/kit/ai/agent/mcp.py +278 -0
  17. yimo/kit/ai/agent/registry.py +203 -0
  18. yimo/kit/ai/agent/session.py +150 -0
  19. yimo/kit/ai/agent/skill.py +370 -0
  20. yimo/kit/ai/agent/types.py +161 -0
  21. yimo/kit/ai/chat_service.py +724 -0
  22. yimo/kit/ai/decision/__init__.py +57 -0
  23. yimo/kit/ai/decision/decima.py +853 -0
  24. yimo/kit/ai/decision/laya.py +552 -0
  25. yimo/kit/ai/embedding_service.py +198 -0
  26. yimo/kit/ai/exceptions.py +109 -0
  27. yimo/kit/ai/image_service.py +84 -0
  28. yimo/kit/ai/messages.py +105 -0
  29. yimo/kit/ai/model_builder.py +121 -0
  30. yimo/kit/ai/model_client.py +62 -0
  31. yimo/kit/ai/profiles.py +577 -0
  32. yimo/kit/ai/rerank_service.py +136 -0
  33. yimo/kit/ai/runner.py +1127 -0
  34. yimo/kit/common_kit.py +221 -0
  35. yimo/kit/config/__init__.py +44 -0
  36. yimo/kit/config/kit_config.py +210 -0
  37. yimo/kit/config/log_config.py +171 -0
  38. yimo/kit/crawl/__init__.py +71 -0
  39. yimo/kit/crawl/article_io.py +325 -0
  40. yimo/kit/crawl/article_models.py +172 -0
  41. yimo/kit/crawl/deepseek_kit.py +673 -0
  42. yimo/kit/crawl/web_article_kit.py +638 -0
  43. yimo/kit/crawl/wx_article_kit.py +692 -0
  44. yimo/kit/db/__init__.py +101 -0
  45. yimo/kit/db/audit.py +625 -0
  46. yimo/kit/db/base_db_kit.py +1265 -0
  47. yimo/kit/db/crud.py +423 -0
  48. yimo/kit/db/engine.py +235 -0
  49. yimo/kit/db/exceptions.py +45 -0
  50. yimo/kit/db/models/__init__.py +33 -0
  51. yimo/kit/db/models/base.py +56 -0
  52. yimo/kit/db/mysql_kit.py +348 -0
  53. yimo/kit/db/pg_kit.py +442 -0
  54. yimo/kit/db/query.py +338 -0
  55. yimo/kit/db/session.py +85 -0
  56. yimo/kit/db/sqlite_kit.py +462 -0
  57. yimo/kit/db/transaction.py +109 -0
  58. yimo/kit/docs/__init__.py +34 -0
  59. yimo/kit/docs/anydoc_kit.py +490 -0
  60. yimo/kit/docs/docx_kit.py +895 -0
  61. yimo/kit/docs/md2doc_kit.py +1801 -0
  62. yimo/kit/docs/mineru_kit.py +1497 -0
  63. yimo/kit/docs/rc_docparser_kit.py +654 -0
  64. yimo/kit/file_kit.py +518 -0
  65. yimo/kit/license_kit.py +533 -0
  66. yimo/kit/redis_kit.py +392 -0
  67. yimo_kit-0.1.0.dist-info/METADATA +1673 -0
  68. yimo_kit-0.1.0.dist-info/RECORD +70 -0
  69. yimo_kit-0.1.0.dist-info/WHEEL +4 -0
  70. yimo_kit-0.1.0.dist-info/licenses/LICENSE +201 -0
yimo/__init__.py ADDED
@@ -0,0 +1,26 @@
1
+ """
2
+ Copyright (c) 2021-2026 溢墨修心(Yimo). All Rights Reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ Project: yimo
17
+ Author: 溢墨修心(Yimo)
18
+ """
19
+
20
+ """Yimo —— Python 项目脚手架 + 统一工具集
21
+
22
+ 命名空间根:``yimo.core``(脚手架本体)与 ``yimo.kit``(发布件 yimo-kit)。
23
+
24
+ 本文件**零导入**:``yimo.kit`` 初始化会加载数据库层(连带 sqlalchemy),
25
+ 若在此转出符号,基础安装下 ``import yimo`` 将直接失败。
26
+ """
yimo/kit/__init__.py ADDED
@@ -0,0 +1,98 @@
1
+ """
2
+ Copyright (c) 2021-2026 溢墨修心(Yimo). All Rights Reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ Project: yimo
17
+ Author: 溢墨修心(Yimo)
18
+ """
19
+
20
+ # date: 2026-08-23
21
+ """Kit 模块——统一数据库访问层 + 工具集
22
+
23
+ 数据库访问通过 yimo.kit.db 子包提供(基于 SQLModel)。
24
+ """
25
+
26
+ __version__ = "0.1.0"
27
+
28
+ from yimo.kit.db import (
29
+ MYSQL,
30
+ POSTGRESQL,
31
+ SQLITE,
32
+ AuditConfig,
33
+ CRUDBase,
34
+ DEFAULT_DISTANCE_TYPE,
35
+ DBError,
36
+ MySqlKit,
37
+ NotFoundError,
38
+ PgKit,
39
+ SQLiteKit,
40
+ VectorNotSupportedError,
41
+ build_mysql_url,
42
+ build_pg_url,
43
+ build_sqlite_url,
44
+ close_all_engines,
45
+ close_engine,
46
+ create_tables,
47
+ generate_snowflake_ids,
48
+ get_engine,
49
+ get_session,
50
+ list_tables,
51
+ prepare_statement,
52
+ session_scope,
53
+ table_exists,
54
+ to_vector_literal,
55
+ transactional,
56
+ )
57
+
58
+ # 顶层公共面与 yimo.kit.db 保持一致(同一套符号,避免两处入口漂移)
59
+ __all__ = [
60
+ # 引擎管理
61
+ "get_engine",
62
+ "create_tables",
63
+ "list_tables",
64
+ "table_exists",
65
+ "close_all_engines",
66
+ "close_engine",
67
+ # 连接串构造(单一来源)
68
+ "build_pg_url",
69
+ "build_mysql_url",
70
+ "build_sqlite_url",
71
+ # 常量
72
+ "POSTGRESQL",
73
+ "MYSQL",
74
+ "SQLITE",
75
+ # 数据库 Kit
76
+ "PgKit",
77
+ "MySqlKit",
78
+ "SQLiteKit",
79
+ # 会话
80
+ "session_scope",
81
+ "get_session",
82
+ # 异常
83
+ "DBError",
84
+ "NotFoundError",
85
+ "VectorNotSupportedError",
86
+ # CRUD
87
+ "CRUDBase",
88
+ # 审计字段与删除标记的自动填充(默认关闭,enable 后生效)
89
+ "AuditConfig",
90
+ # 事务
91
+ "transactional",
92
+ # 原生 SQL 语句构造(公共)
93
+ "prepare_statement",
94
+ # 向量工具(公共)
95
+ "to_vector_literal",
96
+ "generate_snowflake_ids",
97
+ "DEFAULT_DISTANCE_TYPE",
98
+ ]
@@ -0,0 +1,110 @@
1
+ """
2
+ Copyright (c) 2021-2026 溢墨修心(Yimo). All Rights Reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ Project: yimo
17
+ Author: 溢墨修心(Yimo)
18
+ """
19
+
20
+ # date: 2026-11-10
21
+ """yimo/kit/ai - AI 模型服务模块(纯异步,Python 3.13+)
22
+
23
+ 公共面延迟导入(PEP 562):``import yimo.kit.ai`` 本身不加载任何可选依赖,
24
+ 符号在首次访问时才导入,因此缺依赖时的报错会指向正确的 extra。
25
+
26
+ 模型服务:
27
+ - ChatService:对话(``create`` / ``create_once`` / ``create_stream``)
28
+ - EmbeddingService:文本嵌入向量(``create`` / ``create_batch``)
29
+ - RerankService:重排序(``create``)
30
+ - ImageService:文生图(``create``)
31
+
32
+ 同步门面与决策引擎:
33
+ - AI / run_sync / reload_config / shutdown / ReloadResult
34
+ - DecimaKit / LayaKit(extra ``decima`` / ``laya``,不进 ``__all__``)
35
+
36
+ Agent(extra ``agent``,不进 ``__all__``):
37
+ - Agent / ToolRegistry / Session / McpServerConfig
38
+ """
39
+
40
+ from importlib import import_module
41
+ from typing import Any
42
+
43
+ __all__ = [
44
+ "AI",
45
+ "ChatService",
46
+ "EmbeddingService",
47
+ "ImageResult",
48
+ "ImageService",
49
+ "ModelBuilder",
50
+ "ReloadResult",
51
+ "RerankHit",
52
+ "RerankService",
53
+ "StreamStats",
54
+ "reload_config",
55
+ "run_sync",
56
+ "shutdown",
57
+ ]
58
+
59
+ # 符号 → 所属模块;decision 的 4 个符号只支持显式导入,不进 __all__,
60
+ # 否则 ``from yimo.kit.ai import *`` 会在基础安装下触发 torch / onnxruntime。
61
+ _EXPORTS: dict[str, str] = {
62
+ "AI": "yimo.kit.ai.runner",
63
+ "ReloadResult": "yimo.kit.ai.runner",
64
+ "reload_config": "yimo.kit.ai.runner",
65
+ "run_sync": "yimo.kit.ai.runner",
66
+ "shutdown": "yimo.kit.ai.runner",
67
+ "ChatService": "yimo.kit.ai.chat_service",
68
+ "StreamStats": "yimo.kit.ai.chat_service",
69
+ "EmbeddingService": "yimo.kit.ai.embedding_service",
70
+ "RerankService": "yimo.kit.ai.rerank_service",
71
+ "RerankHit": "yimo.kit.ai.rerank_service",
72
+ "ImageService": "yimo.kit.ai.image_service",
73
+ "ImageResult": "yimo.kit.ai.image_service",
74
+ "ModelBuilder": "yimo.kit.ai.model_builder",
75
+ "DecimaKit": "yimo.kit.ai.decision",
76
+ "DecimaError": "yimo.kit.ai.decision",
77
+ "LayaKit": "yimo.kit.ai.decision",
78
+ "LayaError": "yimo.kit.ai.decision",
79
+ # Agent 能力(extra ``agent``)只支持显式导入,不进 __all__:
80
+ # ``from yimo.kit.ai import *`` 不应在基础安装下触发 fastmcp。
81
+ "Agent": "yimo.kit.ai.agent",
82
+ "ToolRegistry": "yimo.kit.ai.agent",
83
+ "Session": "yimo.kit.ai.agent",
84
+ "McpServerConfig": "yimo.kit.ai.agent",
85
+ }
86
+
87
+
88
+ def __getattr__(name: str) -> Any:
89
+ module = _EXPORTS.get(name)
90
+ if module is None:
91
+ raise AttributeError(f"module 'yimo.kit.ai' has no attribute {name!r}")
92
+ value = getattr(import_module(module), name)
93
+ globals()[name] = value
94
+ return value
95
+
96
+
97
+ def __dir__() -> list[str]:
98
+ return sorted(
99
+ set(__all__)
100
+ | {
101
+ "DecimaError",
102
+ "DecimaKit",
103
+ "LayaError",
104
+ "LayaKit",
105
+ "Agent",
106
+ "ToolRegistry",
107
+ "Session",
108
+ "McpServerConfig",
109
+ }
110
+ )
@@ -0,0 +1,27 @@
1
+ """
2
+ Copyright (c) 2021-2026 溢墨修心(Yimo). All Rights Reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ Project: yimo
17
+ Author: 溢墨修心(Yimo)
18
+ """
19
+
20
+ # date: 2026-11-10
21
+ """yimo/kit/ai 内部实现层。
22
+
23
+ **禁止外部导入**:本包只服务于 ``yimo.kit.ai`` 的公共面,路径与符号可在
24
+ patch 版本内自由调整,不构成兼容承诺。
25
+ """
26
+
27
+ __all__: list[str] = []