bazi-agent 1.0.0__tar.gz

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.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 易晓白
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,11 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ include setup.py
5
+ recursive-include bazi_agent *.py
6
+ recursive-include bazi_agent *.md
7
+ global-exclude __pycache__
8
+ global-exclude *.py[co]
9
+ global-exclude *.so
10
+ global-exclude .DS_Store
11
+
@@ -0,0 +1,480 @@
1
+ Metadata-Version: 2.1
2
+ Name: bazi-agent
3
+ Version: 1.0.0
4
+ Summary: 基于传统命理学的AI智能人物画像分析系统
5
+ Home-page: https://github.com/yourusername/bazi-agent
6
+ Author: 易晓白
7
+ Author-email: 799278912@qq.com
8
+ License: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: lunar-python>=1.0.0
22
+ Requires-Dist: anthropic>=0.18.0
23
+ Requires-Dist: openai>=1.0.0
24
+ Requires-Dist: pydantic>=2.0.0
25
+ Requires-Dist: loguru>=0.7.0
26
+
27
+ # BaziAgent - 八字命理分析引擎
28
+
29
+ 基于传统命理学的AI智能人物画像分析系统
30
+
31
+ **作者**:易晓白(花名)
32
+ **版本**:1.0.0
33
+
34
+ ## 📖 项目简介
35
+
36
+ BaziAgent 是一个基于传统八字命理学的智能分析系统,能够根据用户的出生信息自动排盘、进行多维度分析,并生成详细的人物画像报告。
37
+ 但该项目的基础功能只能计算部分数据,如果需要更多数据,可查看下方规则库中所支持的内容。
38
+
39
+ ### 主要功能
40
+
41
+ - 🔮 **自动排盘**:精确计算四柱八字,支持真太阳时校正
42
+ - 📊 **深度分析**:五行、十神、格局等多维度分析
43
+ - 🤖 **AI解读**:集成大语言模型,生成自然语言解读报告
44
+ - 💾 **数据导出**:结构化JSON输出,便于后续处理
45
+
46
+ ### 解决的问题
47
+
48
+ 1. **自动化八字排盘**:无需手动查表,自动计算准确的四柱八字
49
+ 2. **多维度分析**:提供11个维度的深度分析(五行、十神、格局、性格、事业、财运、婚姻、健康、人际、大运、神煞)
50
+ 3. **智能解读**:结合传统命理学规则和现代AI技术,生成易懂的分析报告
51
+ 4. **标准化输出**:统一的JSON格式输出,便于集成到其他系统
52
+
53
+ ## 📥 输入输出
54
+
55
+ ### 输入
56
+
57
+ - **用户基本信息**:
58
+ - 姓名
59
+ - 性别(男/女)
60
+ - 出生时间(年、月、日、时、分)
61
+ - 出生地点(可选,用于真太阳时校正)
62
+
63
+ - **配置信息**:
64
+ - LLM API配置(可选,用于AI解读)
65
+ - 分析维度配置
66
+ - 输出配置
67
+
68
+ ### 输出
69
+
70
+ - **JSON格式的分析结果**,包含以下内容:
71
+ - `user_basic_info`: 用户基本信息
72
+ - `bazi_basic`: 八字基础信息(四柱、日主等)
73
+ - `wuxing_analysis`: 五行分析(旺衰、喜忌、用神等)
74
+ - `shishen_analysis`: 十神分析
75
+ - `geju_analysis`: 格局分析
76
+ - `personality_analysis`: 性格分析
77
+ - `career_analysis`: 事业分析
78
+ - `wealth_analysis`: 财运分析
79
+ - `marriage_analysis`: 婚姻分析
80
+ - `health_analysis`: 健康分析
81
+ - `interpersonal_analysis`: 人际分析
82
+ - `dayun_analysis`: 大运分析
83
+ - `shensha_analysis`: 神煞分析
84
+ - `liunian_analysis`: 流年分析
85
+ - `llm_interpretation`: LLM解读(如果启用)
86
+
87
+ ## 🚀 快速开始
88
+
89
+ ### 安装
90
+
91
+ ```bash
92
+ pip install bazi-agent
93
+ ```
94
+
95
+ ### 基本使用
96
+
97
+ #### 方法1:使用配置文件
98
+
99
+ 1. **创建配置文件**
100
+
101
+ 复制示例配置文件:
102
+ ```bash
103
+ cp config.json.example config.json
104
+ cp user_config.json.example user_config.json
105
+ ```
106
+
107
+ 2. **编辑配置文件**
108
+
109
+ 编辑 `user_config.json`,填入用户信息:
110
+ ```json
111
+ {
112
+ "name": "张三",
113
+ "gender": "男",
114
+ "birth": {
115
+ "year": 1990,
116
+ "month": 5,
117
+ "day": 15,
118
+ "hour": 14,
119
+ "minute": 30
120
+ },
121
+ "location": {
122
+ "province": "北京市",
123
+ "city": "北京市",
124
+ "use_true_solar_time": true
125
+ }
126
+ }
127
+ ```
128
+
129
+ 编辑 `config.json`,配置LLM API(可选):
130
+ ```json
131
+ {
132
+ "llm": {
133
+ "provider": "anthropic",
134
+ "api_key": "your-api-key-here",
135
+ "model": "claude-sonnet-4-20250514"
136
+ }
137
+ }
138
+ ```
139
+
140
+ 3. **运行分析**
141
+
142
+ ```bash
143
+ python run.py
144
+ ```
145
+
146
+ #### 方法2:使用Python代码
147
+
148
+ ```python
149
+ from bazi_agent import BaziAgent
150
+
151
+ # 创建实例
152
+ agent = BaziAgent(
153
+ config_path="./config.json",
154
+ user_config_path="./user_config.json"
155
+ )
156
+
157
+ # 执行分析
158
+ result = agent.analyze()
159
+
160
+ # 查看结果
161
+ print(result['bazi_basic']['sizhu'])
162
+ print(result['wuxing_analysis']['wuxing_most'])
163
+ ```
164
+
165
+ #### 方法3:快速分析(无需配置文件)
166
+
167
+ ```python
168
+ from bazi_agent import quick_analyze
169
+
170
+ result = quick_analyze(
171
+ name="张三",
172
+ gender="男",
173
+ year=1990,
174
+ month=5,
175
+ day=15,
176
+ hour=14,
177
+ minute=30,
178
+ api_key="your-api-key" # 可选
179
+ )
180
+ ```
181
+
182
+ ## 📚 API 文档
183
+
184
+ ### BaziAgent 类
185
+
186
+ #### `__init__(config_path, user_config_path, config_dict)`
187
+
188
+ 初始化BaziAgent实例。
189
+
190
+ **参数:**
191
+ - `config_path` (str, 可选): 配置文件路径,默认为 `"./config.json"`
192
+ - `user_config_path` (str, 可选): 用户配置文件路径,默认为 `"./user_config.json"`
193
+ - `config_dict` (dict, 可选): 配置字典,如果提供则不读取文件
194
+
195
+ **示例:**
196
+ ```python
197
+ agent = BaziAgent(config_path="./config.json", user_config_path="./user_config.json")
198
+ ```
199
+
200
+ #### `analyze() -> Dict[str, Any]`
201
+
202
+ 执行完整的八字分析。
203
+
204
+ **返回:**
205
+ - `Dict[str, Any]`: 包含所有分析结果的字典
206
+
207
+ **示例:**
208
+ ```python
209
+ result = agent.analyze()
210
+ ```
211
+
212
+ #### `get_bazi_basic() -> Dict[str, Any]`
213
+
214
+ 获取八字基础信息(四柱、日主等)。
215
+
216
+ **返回:**
217
+ - `Dict[str, Any]`: 八字基础信息字典
218
+
219
+ **示例:**
220
+ ```python
221
+ bazi = agent.get_bazi_basic()
222
+ print(bazi['sizhu']) # 四柱
223
+ print(bazi['ri_zhu']) # 日柱
224
+ ```
225
+
226
+ #### `get_wuxing_analysis() -> Dict[str, Any]`
227
+
228
+ 获取五行分析结果。
229
+
230
+ **返回:**
231
+ - `Dict[str, Any]`: 五行分析结果,包含:
232
+ - `wuxing_most`: 最旺五行
233
+ - `wuxing_missing`: 缺失五行
234
+ - `rizhu_status`: 日主旺衰状态
235
+ - `yongshen`: 用神列表
236
+
237
+ **示例:**
238
+ ```python
239
+ wuxing = agent.get_wuxing_analysis()
240
+ print(wuxing['wuxing_most'])
241
+ print(wuxing['yongshen'])
242
+ ```
243
+
244
+ #### `get_shishen_analysis() -> Dict[str, Any]`
245
+
246
+ 获取十神分析结果。
247
+
248
+ **返回:**
249
+ - `Dict[str, Any]`: 十神分析结果
250
+
251
+ **示例:**
252
+ ```python
253
+ shishen = agent.get_shishen_analysis()
254
+ ```
255
+
256
+ #### `get_geju_analysis() -> Dict[str, Any]`
257
+
258
+ 获取格局分析结果。
259
+
260
+ **返回:**
261
+ - `Dict[str, Any]`: 格局分析结果,包含:
262
+ - `geju_type`: 格局类型
263
+ - `geju_level`: 格局层次
264
+
265
+ **示例:**
266
+ ```python
267
+ geju = agent.get_geju_analysis()
268
+ print(geju['geju_type'])
269
+ ```
270
+
271
+ ### 工具函数
272
+
273
+ #### `quick_analyze(name, gender, year, month, day, hour, minute, api_key, provider, model) -> Dict[str, Any]`
274
+
275
+ 快速分析,无需配置文件。
276
+
277
+ **参数:**
278
+ - `name` (str): 姓名
279
+ - `gender` (str): 性别,"男" 或 "女"
280
+ - `year` (int): 出生年份
281
+ - `month` (int): 出生月份
282
+ - `day` (int): 出生日期
283
+ - `hour` (int): 出生小时
284
+ - `minute` (int, 可选): 出生分钟,默认为0
285
+ - `api_key` (str, 可选): LLM API密钥
286
+ - `provider` (str, 可选): LLM提供商,默认为 "anthropic"
287
+ - `model` (str, 可选): 模型名称,默认为 "claude-sonnet-4-20250514"
288
+
289
+ **返回:**
290
+ - `Dict[str, Any]`: 分析结果字典
291
+
292
+ **示例:**
293
+ ```python
294
+ from bazi_agent import quick_analyze
295
+
296
+ result = quick_analyze(
297
+ name="张三",
298
+ gender="男",
299
+ year=1990,
300
+ month=5,
301
+ day=15,
302
+ hour=14,
303
+ minute=30
304
+ )
305
+ ```
306
+
307
+ #### `validate_config(config_path) -> Tuple[bool, Optional[str]]`
308
+
309
+ 验证配置文件是否合法。
310
+
311
+ **参数:**
312
+ - `config_path` (str): 配置文件路径
313
+
314
+ **返回:**
315
+ - `Tuple[bool, Optional[str]]`: (是否合法, 错误信息)
316
+
317
+ **示例:**
318
+ ```python
319
+ from bazi_agent import validate_config
320
+
321
+ is_valid, error = validate_config("./config.json")
322
+ if not is_valid:
323
+ print(f"配置错误: {error}")
324
+ ```
325
+
326
+ ## ⚙️ 配置说明
327
+
328
+ ### 配置文件结构
329
+
330
+ #### config.json
331
+
332
+ 主配置文件,包含LLM配置、分析配置和输出配置。
333
+
334
+ ```json
335
+ {
336
+ "llm": {
337
+ "provider": "anthropic",
338
+ "api_key": "your-api-key-here",
339
+ "model": "claude-sonnet-4-20250514",
340
+ "temperature": 0.7,
341
+ "max_tokens": 2000,
342
+ "timeout": 30
343
+ },
344
+ "analysis": {
345
+ "dimensions": ["wuxing", "shishen", "geju", ...],
346
+ "include_llm_interpretation": true,
347
+ "llm_interpretation_level": "detailed"
348
+ },
349
+ "output": {
350
+ "json": {
351
+ "enabled": true,
352
+ "filepath": "./output/result.json",
353
+ "pretty": true
354
+ },
355
+ "logging": {
356
+ "level": "INFO",
357
+ "filepath": "./logs/bazi_agent.log"
358
+ }
359
+ }
360
+ }
361
+ ```
362
+
363
+ #### user_config.json
364
+
365
+ 用户信息配置文件。
366
+
367
+ ```json
368
+ {
369
+ "name": "张三",
370
+ "gender": "男",
371
+ "birth": {
372
+ "year": 1990,
373
+ "month": 5,
374
+ "day": 15,
375
+ "hour": 14,
376
+ "minute": 30
377
+ },
378
+ "location": {
379
+ "province": "北京市",
380
+ "city": "北京市",
381
+ "use_true_solar_time": true
382
+ }
383
+ }
384
+ ```
385
+
386
+ ### LLM 提供商支持
387
+
388
+ - `custom`: 自定义OpenAI兼容API
389
+
390
+ ## 📝 输出结果说明
391
+
392
+ 分析结果以JSON格式保存到 `output/{用户姓名}_{出生日期}/result.json`。
393
+
394
+ 主要字段说明:
395
+
396
+ - **user_basic_info**: 用户基本信息
397
+ - **bazi_basic**: 八字基础信息
398
+ - `sizhu`: 四柱(年柱、月柱、日柱、时柱)
399
+ - `rizhu_tiangan`: 日主天干
400
+ - `rizhu_wuxing`: 日主五行
401
+ - **wuxing_analysis**: 五行分析
402
+ - `wuxing_most`: 最旺五行
403
+ - `wuxing_missing`: 缺失五行
404
+ - `rizhu_status`: 日主旺衰(身旺/身弱/从强/从弱等)
405
+ - `yongshen`: 用神列表
406
+ - **geju_analysis**: 格局分析
407
+ - `geju_type`: 格局类型
408
+ - `geju_level`: 格局层次
409
+ - **llm_interpretation**: LLM解读(如果启用)
410
+ - `comprehensive_analysis`: 综合分析报告
411
+
412
+ ## ⚠️ 注意事项
413
+
414
+ ### 规则库(bazi_rules 目录)
415
+
416
+ 本项目支持可选的规则库功能,用于更精确的分析。规则库文件位于 `bazi_rules` 目录下,包含:
417
+ - 生肖关系数据
418
+ - 神煞计算规则
419
+ - 十神性格特征
420
+ - 格局职业倾向
421
+ - 大运计算规则
422
+ - 流年分析规则
423
+ - 性格维度评分规则
424
+
425
+ **注意**:本项目仅公开核心计算逻辑和方式,不提供 `bazi_rules` 目录,系统会使用默认规则继续工作,但某些高级分析功能可能会受限。如果需要完整功能,请联系作者获取 `bazi_rules` 规则库。
426
+
427
+ 详细的功能对比说明请参考 [规则库使用对比说明](BAZI_RULES_COMPARISON.md)。
428
+
429
+ ## 🔧 开发
430
+
431
+ ### 安装开发依赖
432
+
433
+ ```bash
434
+ pip install -r requirements.txt
435
+ ```
436
+
437
+ ### 运行测试
438
+
439
+ ```bash
440
+ python run.py
441
+ ```
442
+
443
+ ## 📄 许可证
444
+
445
+ MIT License
446
+
447
+ ## 🤝 贡献
448
+
449
+ 欢迎提交 Issue 和 Pull Request!
450
+
451
+ ## 👤 作者信息
452
+
453
+ **作者**:易晓白(花名)
454
+ **项目**:BaziAgent - 八字命理分析引擎
455
+
456
+ ## 💼 商业对接
457
+
458
+ ### 商业合作
459
+
460
+ 本项目支持商业合作,包括但不限于:
461
+
462
+ - **规则库授权**:获取完整的 `bazi_rules` 规则库,享受完整功能
463
+ - **定制开发**:根据业务需求定制开发功能模块
464
+ - **技术咨询**:提供八字命理算法相关的技术咨询服务
465
+ - **API服务**:提供云端API服务,支持高并发调用
466
+ - **私有化部署**:提供私有化部署方案和技术支持
467
+
468
+ ### 合作方式
469
+
470
+ 如有商业合作需求,请通过以下方式联系:
471
+
472
+ 1. **微信(WeChat)**:yixiaobai-AI(请备注"商业合作")
473
+ 2. **邮箱**:799278912@qq.com(主题请注明"BaziAgent商业合作")
474
+
475
+ 我们会在收到您的咨询后尽快回复,并安排专人对接您的需求。
476
+
477
+
478
+
479
+
480
+