infomankit 0.3.23__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.
- infoman/__init__.py +1 -0
- infoman/cli/README.md +378 -0
- infoman/cli/__init__.py +7 -0
- infoman/cli/commands/__init__.py +3 -0
- infoman/cli/commands/init.py +312 -0
- infoman/cli/scaffold.py +634 -0
- infoman/cli/templates/Makefile.template +132 -0
- infoman/cli/templates/app/__init__.py.template +3 -0
- infoman/cli/templates/app/app.py.template +4 -0
- infoman/cli/templates/app/models_base.py.template +18 -0
- infoman/cli/templates/app/models_entity_init.py.template +11 -0
- infoman/cli/templates/app/models_schemas_init.py.template +11 -0
- infoman/cli/templates/app/repository_init.py.template +11 -0
- infoman/cli/templates/app/routers_init.py.template +15 -0
- infoman/cli/templates/app/services_init.py.template +11 -0
- infoman/cli/templates/app/static_index.html.template +39 -0
- infoman/cli/templates/app/static_main.js.template +31 -0
- infoman/cli/templates/app/static_style.css.template +111 -0
- infoman/cli/templates/app/utils_init.py.template +11 -0
- infoman/cli/templates/config/.env.dev.template +43 -0
- infoman/cli/templates/config/.env.prod.template +43 -0
- infoman/cli/templates/config/README.md.template +28 -0
- infoman/cli/templates/docker/.dockerignore.template +60 -0
- infoman/cli/templates/docker/Dockerfile.template +47 -0
- infoman/cli/templates/docker/README.md.template +240 -0
- infoman/cli/templates/docker/docker-compose.yml.template +81 -0
- infoman/cli/templates/docker/mysql_custom.cnf.template +42 -0
- infoman/cli/templates/docker/mysql_init.sql.template +15 -0
- infoman/cli/templates/project/.env.example.template +1 -0
- infoman/cli/templates/project/.gitignore.template +60 -0
- infoman/cli/templates/project/Makefile.template +38 -0
- infoman/cli/templates/project/README.md.template +137 -0
- infoman/cli/templates/project/deploy.sh.template +97 -0
- infoman/cli/templates/project/main.py.template +10 -0
- infoman/cli/templates/project/manage.sh.template +97 -0
- infoman/cli/templates/project/pyproject.toml.template +47 -0
- infoman/cli/templates/project/service.sh.template +203 -0
- infoman/config/__init__.py +25 -0
- infoman/config/base.py +67 -0
- infoman/config/db_cache.py +237 -0
- infoman/config/db_relation.py +181 -0
- infoman/config/db_vector.py +39 -0
- infoman/config/jwt.py +16 -0
- infoman/config/llm.py +16 -0
- infoman/config/log.py +627 -0
- infoman/config/mq.py +26 -0
- infoman/config/settings.py +65 -0
- infoman/llm/__init__.py +0 -0
- infoman/llm/llm.py +297 -0
- infoman/logger/__init__.py +57 -0
- infoman/logger/context.py +191 -0
- infoman/logger/core.py +358 -0
- infoman/logger/filters.py +157 -0
- infoman/logger/formatters.py +138 -0
- infoman/logger/handlers.py +276 -0
- infoman/logger/metrics.py +160 -0
- infoman/performance/README.md +583 -0
- infoman/performance/__init__.py +19 -0
- infoman/performance/cli.py +215 -0
- infoman/performance/config.py +166 -0
- infoman/performance/reporter.py +519 -0
- infoman/performance/runner.py +303 -0
- infoman/performance/standards.py +222 -0
- infoman/service/__init__.py +8 -0
- infoman/service/app.py +67 -0
- infoman/service/core/__init__.py +0 -0
- infoman/service/core/auth.py +105 -0
- infoman/service/core/lifespan.py +132 -0
- infoman/service/core/monitor.py +57 -0
- infoman/service/core/response.py +37 -0
- infoman/service/exception/__init__.py +7 -0
- infoman/service/exception/error.py +274 -0
- infoman/service/exception/exception.py +25 -0
- infoman/service/exception/handler.py +238 -0
- infoman/service/infrastructure/__init__.py +8 -0
- infoman/service/infrastructure/base.py +212 -0
- infoman/service/infrastructure/db_cache/__init__.py +8 -0
- infoman/service/infrastructure/db_cache/manager.py +194 -0
- infoman/service/infrastructure/db_relation/__init__.py +41 -0
- infoman/service/infrastructure/db_relation/manager.py +300 -0
- infoman/service/infrastructure/db_relation/manager_pro.py +408 -0
- infoman/service/infrastructure/db_relation/mysql.py +52 -0
- infoman/service/infrastructure/db_relation/pgsql.py +54 -0
- infoman/service/infrastructure/db_relation/sqllite.py +25 -0
- infoman/service/infrastructure/db_vector/__init__.py +40 -0
- infoman/service/infrastructure/db_vector/manager.py +201 -0
- infoman/service/infrastructure/db_vector/qdrant.py +322 -0
- infoman/service/infrastructure/mq/__init__.py +15 -0
- infoman/service/infrastructure/mq/manager.py +178 -0
- infoman/service/infrastructure/mq/nats/__init__.py +0 -0
- infoman/service/infrastructure/mq/nats/nats_client.py +57 -0
- infoman/service/infrastructure/mq/nats/nats_event_router.py +25 -0
- infoman/service/launch.py +284 -0
- infoman/service/middleware/__init__.py +7 -0
- infoman/service/middleware/base.py +41 -0
- infoman/service/middleware/logging.py +51 -0
- infoman/service/middleware/rate_limit.py +301 -0
- infoman/service/middleware/request_id.py +21 -0
- infoman/service/middleware/white_list.py +24 -0
- infoman/service/models/__init__.py +8 -0
- infoman/service/models/base.py +441 -0
- infoman/service/models/type/embed.py +70 -0
- infoman/service/routers/__init__.py +18 -0
- infoman/service/routers/health_router.py +311 -0
- infoman/service/routers/monitor_router.py +44 -0
- infoman/service/utils/__init__.py +8 -0
- infoman/service/utils/cache/__init__.py +0 -0
- infoman/service/utils/cache/cache.py +192 -0
- infoman/service/utils/module_loader.py +10 -0
- infoman/service/utils/parse.py +10 -0
- infoman/service/utils/resolver/__init__.py +8 -0
- infoman/service/utils/resolver/base.py +47 -0
- infoman/service/utils/resolver/resp.py +102 -0
- infoman/service/vector/__init__.py +20 -0
- infoman/service/vector/base.py +56 -0
- infoman/service/vector/qdrant.py +125 -0
- infoman/service/vector/service.py +67 -0
- infoman/utils/__init__.py +2 -0
- infoman/utils/decorators/__init__.py +8 -0
- infoman/utils/decorators/cache.py +137 -0
- infoman/utils/decorators/retry.py +99 -0
- infoman/utils/decorators/safe_execute.py +99 -0
- infoman/utils/decorators/timing.py +99 -0
- infoman/utils/encryption/__init__.py +8 -0
- infoman/utils/encryption/aes.py +66 -0
- infoman/utils/encryption/ecc.py +108 -0
- infoman/utils/encryption/rsa.py +112 -0
- infoman/utils/file/__init__.py +0 -0
- infoman/utils/file/handler.py +22 -0
- infoman/utils/hash/__init__.py +0 -0
- infoman/utils/hash/hash.py +61 -0
- infoman/utils/http/__init__.py +8 -0
- infoman/utils/http/client.py +62 -0
- infoman/utils/http/info.py +94 -0
- infoman/utils/http/result.py +19 -0
- infoman/utils/notification/__init__.py +8 -0
- infoman/utils/notification/feishu.py +35 -0
- infoman/utils/text/__init__.py +8 -0
- infoman/utils/text/extractor.py +111 -0
- infomankit-0.3.23.dist-info/METADATA +632 -0
- infomankit-0.3.23.dist-info/RECORD +143 -0
- infomankit-0.3.23.dist-info/WHEEL +4 -0
- infomankit-0.3.23.dist-info/entry_points.txt +5 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*-coding:utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
# Time :2025/12/22 21:37
|
|
6
|
+
# Author :Maxwell
|
|
7
|
+
# Description:
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Optional, List, Dict, Literal
|
|
11
|
+
from functools import cached_property
|
|
12
|
+
from pydantic import Field
|
|
13
|
+
from pydantic_settings import BaseSettings
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DatabaseInstanceConfig(BaseSettings):
|
|
17
|
+
enabled: bool = False
|
|
18
|
+
ssl_enabled: bool = False
|
|
19
|
+
type: Literal["mysql", "postgresql", "sqlite"] = "mysql"
|
|
20
|
+
host: Optional[str] = None
|
|
21
|
+
port: Optional[int] = None
|
|
22
|
+
database: str = "infoman"
|
|
23
|
+
user: Optional[str] = None
|
|
24
|
+
password: Optional[str] = None
|
|
25
|
+
|
|
26
|
+
# 连接池
|
|
27
|
+
pool_min_size: int = 1
|
|
28
|
+
pool_max_size: int = 20
|
|
29
|
+
pool_recycle: int = 3600
|
|
30
|
+
|
|
31
|
+
# 超时
|
|
32
|
+
connect_timeout: int = 10
|
|
33
|
+
|
|
34
|
+
# 模型
|
|
35
|
+
models: List[str] = []
|
|
36
|
+
|
|
37
|
+
# 数据库特有
|
|
38
|
+
charset: str = "utf8mb4"
|
|
39
|
+
schema_name: str = "public" # PostgreSQL schema (renamed from schema_content)
|
|
40
|
+
echo: bool = False
|
|
41
|
+
|
|
42
|
+
# SSL 配置
|
|
43
|
+
ssl_ca: Optional[str] = None # SSL CA 证书路径
|
|
44
|
+
ssl_cert: Optional[str] = None # SSL 客户端证书路径
|
|
45
|
+
ssl_key: Optional[str] = None # SSL 客户端密钥路径
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class DatabaseConfig(BaseSettings):
|
|
49
|
+
USE_PRO_ORM: bool = Field(default=False)
|
|
50
|
+
# ========== MySQL ==========
|
|
51
|
+
MYSQL_ENABLED: bool = Field(default=False)
|
|
52
|
+
MYSQL_HOST: Optional[str] = Field(default=None)
|
|
53
|
+
MYSQL_PORT: int = Field(default=3306)
|
|
54
|
+
MYSQL_DB: str = Field(default="infoman")
|
|
55
|
+
MYSQL_USER: Optional[str] = Field(default=None)
|
|
56
|
+
MYSQL_PASSWORD: Optional[str] = Field(default=None)
|
|
57
|
+
MYSQL_CHARSET: str = Field(default="utf8mb4")
|
|
58
|
+
MYSQL_POOL_MIN_SIZE: int = Field(default=1)
|
|
59
|
+
MYSQL_POOL_MAX_SIZE: int = Field(default=20)
|
|
60
|
+
MYSQL_POOL_RECYCLE: int = Field(default=3600)
|
|
61
|
+
MYSQL_MODELS_PATH: str = Field(default="infoman.models")
|
|
62
|
+
MYSQL_MODELS: str = Field(default="")
|
|
63
|
+
MYSQL_ECHO: bool = Field(default=False)
|
|
64
|
+
MYSQL_SSL_ENABLED: bool = Field(default=False)
|
|
65
|
+
MYSQL_SSL_CA: Optional[str] = Field(default=None)
|
|
66
|
+
MYSQL_SSL_CERT: Optional[str] = Field(default=None)
|
|
67
|
+
MYSQL_SSL_KEY: Optional[str] = Field(default=None)
|
|
68
|
+
|
|
69
|
+
# ========== PostgreSQL ==========
|
|
70
|
+
POSTGRES_ENABLED: bool = Field(default=False)
|
|
71
|
+
POSTGRES_HOST: Optional[str] = Field(default=None)
|
|
72
|
+
POSTGRES_PORT: int = Field(default=5432)
|
|
73
|
+
POSTGRES_DB: str = Field(default="analytics")
|
|
74
|
+
POSTGRES_USER: Optional[str] = Field(default=None)
|
|
75
|
+
POSTGRES_PASSWORD: Optional[str] = Field(default=None)
|
|
76
|
+
POSTGRES_SCHEMA: str = Field(default="public")
|
|
77
|
+
POSTGRES_POOL_MIN_SIZE: int = Field(default=5)
|
|
78
|
+
POSTGRES_POOL_MAX_SIZE: int = Field(default=20)
|
|
79
|
+
POSTGRES_MODELS: str = Field(default="")
|
|
80
|
+
POSTGRES_MODELS_PATH: str = Field(default="infoman.models")
|
|
81
|
+
POSTGRES_ECHO: bool = Field(default=False)
|
|
82
|
+
POSTGRES_SSL_ENABLED: bool = Field(default=False)
|
|
83
|
+
POSTGRES_SSL_CA: Optional[str] = Field(default=None)
|
|
84
|
+
POSTGRES_SSL_CERT: Optional[str] = Field(default=None)
|
|
85
|
+
POSTGRES_SSL_KEY: Optional[str] = Field(default=None)
|
|
86
|
+
|
|
87
|
+
# ========== SQLite ==========
|
|
88
|
+
SQLITE_ENABLED: bool = Field(default=False)
|
|
89
|
+
SQLITE_DB: str = Field(default="cache")
|
|
90
|
+
SQLITE_MODELS_PATH: str = Field(default="infoman.models")
|
|
91
|
+
SQLITE_MODELS: str = Field(default="")
|
|
92
|
+
|
|
93
|
+
# ========== 通用 ==========
|
|
94
|
+
DB_TIMEZONE: str = Field(default="Asia/Shanghai")
|
|
95
|
+
DB_USE_TZ: bool = Field(default=False)
|
|
96
|
+
DB_MODELS_PATH: str = Field(default="infoman.models")
|
|
97
|
+
|
|
98
|
+
# ========== 计算属性 ==========
|
|
99
|
+
|
|
100
|
+
@cached_property
|
|
101
|
+
def mysql_config(self) -> Optional[DatabaseInstanceConfig]:
|
|
102
|
+
if not self.MYSQL_ENABLED:
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
models = [m.strip() for m in self.MYSQL_MODELS.split(",") if m.strip()]
|
|
106
|
+
|
|
107
|
+
return DatabaseInstanceConfig(
|
|
108
|
+
enabled=True,
|
|
109
|
+
type="mysql",
|
|
110
|
+
host=self.MYSQL_HOST,
|
|
111
|
+
port=self.MYSQL_PORT,
|
|
112
|
+
database=self.MYSQL_DB,
|
|
113
|
+
user=self.MYSQL_USER,
|
|
114
|
+
password=self.MYSQL_PASSWORD,
|
|
115
|
+
pool_min_size=self.MYSQL_POOL_MIN_SIZE,
|
|
116
|
+
pool_max_size=self.MYSQL_POOL_MAX_SIZE,
|
|
117
|
+
pool_recycle=self.MYSQL_POOL_RECYCLE,
|
|
118
|
+
models=[f"{self.MYSQL_MODELS_PATH}.{m}" for m in models],
|
|
119
|
+
charset=self.MYSQL_CHARSET,
|
|
120
|
+
echo=self.MYSQL_ECHO,
|
|
121
|
+
ssl_enabled=self.MYSQL_SSL_ENABLED,
|
|
122
|
+
ssl_ca=self.MYSQL_SSL_CA,
|
|
123
|
+
ssl_cert=self.MYSQL_SSL_CERT,
|
|
124
|
+
ssl_key=self.MYSQL_SSL_KEY,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
@cached_property
|
|
128
|
+
def postgres_config(self) -> Optional[DatabaseInstanceConfig]:
|
|
129
|
+
if not self.POSTGRES_ENABLED:
|
|
130
|
+
return None
|
|
131
|
+
|
|
132
|
+
models = [m.strip() for m in self.POSTGRES_MODELS.split(",") if m.strip()]
|
|
133
|
+
|
|
134
|
+
return DatabaseInstanceConfig(
|
|
135
|
+
enabled=True,
|
|
136
|
+
type="postgresql",
|
|
137
|
+
host=self.POSTGRES_HOST,
|
|
138
|
+
port=self.POSTGRES_PORT,
|
|
139
|
+
database=self.POSTGRES_DB,
|
|
140
|
+
user=self.POSTGRES_USER,
|
|
141
|
+
password=self.POSTGRES_PASSWORD,
|
|
142
|
+
pool_min_size=self.POSTGRES_POOL_MIN_SIZE,
|
|
143
|
+
pool_max_size=self.POSTGRES_POOL_MAX_SIZE,
|
|
144
|
+
models=[f"{self.POSTGRES_MODELS_PATH}.{m}" for m in models],
|
|
145
|
+
schema_name=self.POSTGRES_SCHEMA,
|
|
146
|
+
echo=self.POSTGRES_ECHO,
|
|
147
|
+
ssl_enabled=self.POSTGRES_SSL_ENABLED,
|
|
148
|
+
ssl_ca=self.POSTGRES_SSL_CA,
|
|
149
|
+
ssl_cert=self.POSTGRES_SSL_CERT,
|
|
150
|
+
ssl_key=self.POSTGRES_SSL_KEY,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
@cached_property
|
|
154
|
+
def sqlite_config(self) -> Optional[DatabaseInstanceConfig]:
|
|
155
|
+
if not self.SQLITE_ENABLED:
|
|
156
|
+
return None
|
|
157
|
+
|
|
158
|
+
models = [m.strip() for m in self.SQLITE_MODELS.split(",") if m.strip()]
|
|
159
|
+
|
|
160
|
+
return DatabaseInstanceConfig(
|
|
161
|
+
enabled=True,
|
|
162
|
+
type="sqlite",
|
|
163
|
+
database=self.SQLITE_DB,
|
|
164
|
+
models=[f"{self.SQLITE_MODELS_PATH}.{m}" for m in models],
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
@cached_property
|
|
168
|
+
def enabled_databases(self) -> Dict[str, DatabaseInstanceConfig]:
|
|
169
|
+
databases = {}
|
|
170
|
+
|
|
171
|
+
if self.mysql_config:
|
|
172
|
+
databases["mysql"] = self.mysql_config
|
|
173
|
+
|
|
174
|
+
if self.postgres_config:
|
|
175
|
+
databases["postgres"] = self.postgres_config
|
|
176
|
+
|
|
177
|
+
if self.sqlite_config:
|
|
178
|
+
databases["sqlite"] = self.sqlite_config
|
|
179
|
+
|
|
180
|
+
return databases
|
|
181
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*-coding:utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
# Time :2025/12/22 21:38
|
|
6
|
+
# Author :Maxwell
|
|
7
|
+
# Description:
|
|
8
|
+
"""
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from pydantic import Field
|
|
11
|
+
from pydantic_settings import BaseSettings
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class VectorDBConfig(BaseSettings):
|
|
15
|
+
# ========== Qdrant ==========
|
|
16
|
+
QDRANT_ENABLED: bool = Field(default=False, description="是否启用 Qdrant")
|
|
17
|
+
QDRANT_HOST: Optional[str] = Field(default=None, description="Qdrant 主机")
|
|
18
|
+
QDRANT_HTTP_PORT: int = Field(default=6333, description="HTTP 端口")
|
|
19
|
+
QDRANT_GRPC_PORT: int = Field(default=6334, description="gRPC 端口")
|
|
20
|
+
QDRANT_API_KEY: Optional[str] = Field(default=None, description="API Key")
|
|
21
|
+
QDRANT_TIMEOUT: int = Field(default=10, description="超时时间(秒)")
|
|
22
|
+
|
|
23
|
+
# ========== Milvus ==========
|
|
24
|
+
MILVUS_ENABLED: bool = Field(default=False, description="是否启用 Milvus")
|
|
25
|
+
MILVUS_HOST: Optional[str] = Field(default=None, description="Milvus 主机")
|
|
26
|
+
MILVUS_PORT: int = Field(default=19530, description="Milvus 端口")
|
|
27
|
+
MILVUS_USER: Optional[str] = Field(default=None, description="用户名")
|
|
28
|
+
MILVUS_PASSWORD: Optional[str] = Field(default=None, description="密码")
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def qdrant_configured(self) -> bool:
|
|
32
|
+
"""Qdrant 是否已配置"""
|
|
33
|
+
return self.QDRANT_ENABLED and bool(self.QDRANT_HOST)
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def milvus_configured(self) -> bool:
|
|
37
|
+
"""Milvus 是否已配置"""
|
|
38
|
+
return self.MILVUS_ENABLED and bool(self.MILVUS_HOST)
|
|
39
|
+
|
infoman/config/jwt.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*-coding:utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
# Time :2025/12/23 08:37
|
|
6
|
+
# Author :Maxwell
|
|
7
|
+
# Description:
|
|
8
|
+
"""
|
|
9
|
+
from pydantic import Field
|
|
10
|
+
from pydantic_settings import BaseSettings
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class JWTConfig(BaseSettings):
|
|
14
|
+
JWT_ALGORITHM: str = Field(default="HS256")
|
|
15
|
+
JWT_SECRET_KEY: str = Field(default="your-secret-key-for-jwt")
|
|
16
|
+
JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = Field(default=60, ge=0, le=24*30*60)
|
infoman/config/llm.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*-coding:utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
# Time :2025/12/23 08:32
|
|
6
|
+
# Author :Maxwell
|
|
7
|
+
# Description:
|
|
8
|
+
"""
|
|
9
|
+
from pydantic import Field
|
|
10
|
+
from pydantic_settings import BaseSettings
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LLMConfig(BaseSettings):
|
|
14
|
+
LLM_PROXY: str = Field(default="litellm_proxy", description="LLM 代理")
|
|
15
|
+
LLM_TIMEOUT: int = Field(default=60, ge=5, description="LLM 请求超时")
|
|
16
|
+
LLM_MAX_RETRIES: int = Field(default=3, ge=0, le=10, description="最大重试次数")
|