bella-openapi 1.0.3__tar.gz → 1.0.3.2__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.
Files changed (30) hide show
  1. {bella_openapi-1.0.3/src/bella_openapi.egg-info → bella_openapi-1.0.3.2}/PKG-INFO +5 -1
  2. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/README.md +3 -1
  3. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/setup.py +3 -1
  4. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/entity/standard_domtree.py +49 -20
  5. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2/src/bella_openapi.egg-info}/PKG-INFO +5 -1
  6. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi.egg-info/requires.txt +2 -0
  7. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/LICENSE +0 -0
  8. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/setup.cfg +0 -0
  9. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/__init__.py +0 -0
  10. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/auth_billing.py +0 -0
  11. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/authorize.py +0 -0
  12. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/bella_trace/__init__.py +0 -0
  13. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/bella_trace/_context.py +0 -0
  14. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/bella_trace/fastapi_interceptor.py +0 -0
  15. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/bella_trace/record_log.py +0 -0
  16. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/bella_trace/trace_requests.py +0 -0
  17. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/config.py +0 -0
  18. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/console/__init__.py +0 -0
  19. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/console/models.py +0 -0
  20. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/entity/__init__.py +0 -0
  21. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/exception.py +0 -0
  22. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/log.py +0 -0
  23. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/middleware/__init__.py +0 -0
  24. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/middleware/context_middleware.py +0 -0
  25. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/openapi_contexvar.py +0 -0
  26. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi/schema.py +0 -0
  27. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi.egg-info/SOURCES.txt +0 -0
  28. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi.egg-info/dependency_links.txt +0 -0
  29. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi.egg-info/not-zip-safe +0 -0
  30. {bella_openapi-1.0.3 → bella_openapi-1.0.3.2}/src/bella_openapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-openapi
3
- Version: 1.0.3
3
+ Version: 1.0.3.2
4
4
  Summary: client for openapi service.
5
5
  Home-page:
6
6
  Author: ['tangxiaolong', 'fanqiangwei', 'zhangxiaojia', 'liumin', 'wangyukun']
@@ -12,6 +12,8 @@ License-File: LICENSE
12
12
  Requires-Dist: httpx<=0.26.0,>=0.10.0
13
13
  Requires-Dist: Werkzeug==3.0.1
14
14
  Requires-Dist: tiktoken>=0.5.0
15
+ Requires-Dist: pydantic==1.10.14
16
+ Requires-Dist: fastapi==0.110.0
15
17
  Dynamic: author
16
18
  Dynamic: classifier
17
19
  Dynamic: description
@@ -259,3 +261,5 @@ get接口地址:/v1/openapi/log/{requestId}
259
261
  * rename 包名
260
262
  * 1.0.2
261
263
  * 修复bug
264
+ * 1.0.3
265
+ * 新增standard domtree
@@ -235,4 +235,6 @@ get接口地址:/v1/openapi/log/{requestId}
235
235
  * 1.0.1
236
236
  * rename 包名
237
237
  * 1.0.2
238
- * 修复bug
238
+ * 修复bug
239
+ * 1.0.3
240
+ * 新增standard domtree
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
3
3
 
4
4
  SHORT = "client for openapi service."
5
5
 
6
- __version__ = "1.0.3"
6
+ __version__ = "1.0.3.2"
7
7
  __author__ = ["tangxiaolong", "fanqiangwei", "zhangxiaojia", 'liumin', 'wangyukun']
8
8
  __email__ = ''
9
9
  readme_path = 'README.md'
@@ -17,6 +17,8 @@ setup(
17
17
  'httpx>=0.10.0,<=0.26.0',
18
18
  'Werkzeug==3.0.1',
19
19
  'tiktoken>=0.5.0',
20
+ 'pydantic==1.10.14',
21
+ 'fastapi==0.110.0'
20
22
  ],
21
23
  url='',
22
24
  author=__author__,
@@ -9,7 +9,7 @@ StandardDomTree - 新的DOM树协议定义
9
9
  """
10
10
 
11
11
  from typing import List, Optional, Literal, Any, Union
12
- from pydantic import BaseModel, Field
12
+ from pydantic import BaseModel, Field, root_validator
13
13
  import tiktoken
14
14
 
15
15
  # 布局类型映射表:将旧解析器的布局类型映射到新的标准类型
@@ -92,6 +92,23 @@ class StandardNode(BaseModel):
92
92
  path: Optional[List[int]] = Field(default_factory=list) # 编号的层级信息,例如:1.2.1
93
93
  element: Optional[Union[StandardElement, StandardImageElement, StandardTableElement]] = None # 元素信息,当前节点的元素详情
94
94
  children: Optional[List["StandardNode"]] = Field(default_factory=list) # 子节点信息,当前节点的所有子节点
95
+
96
+ @root_validator(pre=True)
97
+ def parse_element(cls, values):
98
+ """根据element的type字段正确实例化element"""
99
+ if 'element' in values and values['element'] is not None:
100
+ element_data = values['element']
101
+ # 只有当element是字典时才需要转换,如果已经是正确的实例则保持不变
102
+ if isinstance(element_data, dict):
103
+ element_type = element_data.get('type', '')
104
+ if element_type == 'Figure':
105
+ values['element'] = StandardImageElement(**element_data)
106
+ elif element_type == 'Table':
107
+ values['element'] = StandardTableElement(**element_data)
108
+ else:
109
+ values['element'] = StandardElement(**element_data)
110
+ # 如果element已经是正确的实例类型,则保持不变
111
+ return values
95
112
 
96
113
 
97
114
  class StandardDomTree(BaseModel):
@@ -400,19 +417,22 @@ class StandardDomTree(BaseModel):
400
417
  url=element['image_link']
401
418
  )
402
419
 
403
- # 创建 StandardNode
404
- standard_node = StandardNode(
420
+ # 创建StandardImageElement实例
421
+ image_element = StandardImageElement(
422
+ type=element_type,
423
+ positions=positions,
424
+ name="",
425
+ description="",
426
+ text=text,
427
+ image=image,
428
+ )
429
+
430
+ # 使用construct方法跳过validator,保持正确的element类型
431
+ standard_node = StandardNode.construct(
405
432
  summary="",
406
433
  tokens=0, # 先设置为 0,后面再计算
407
434
  path=[], # 初始化为空列表,后续再计算
408
- element=StandardImageElement(
409
- type=element_type,
410
- positions=positions,
411
- name="",
412
- description="",
413
- text=text,
414
- image=image,
415
- ),
435
+ element=image_element,
416
436
  children=[]
417
437
  )
418
438
  elif element_type == "Table":
@@ -447,17 +467,21 @@ class StandardDomTree(BaseModel):
447
467
  # 将所有单元格的文本合并,用于计算 token 数量
448
468
  text = " ".join(cell_texts)
449
469
 
450
- standard_node = StandardNode(
470
+ # 创建StandardTableElement实例
471
+ table_element = StandardTableElement(
472
+ type=element_type,
473
+ positions=positions,
474
+ name="",
475
+ description="",
476
+ rows=rows
477
+ )
478
+
479
+ # 使用construct方法跳过validator,保持正确的element类型
480
+ standard_node = StandardNode.construct(
451
481
  summary="",
452
482
  tokens=0, # 先设置为 0,后面再计算
453
483
  path=[], # 初始化为空列表,后续再计算
454
- element=StandardTableElement(
455
- type=element_type,
456
- positions=positions,
457
- name="",
458
- description="",
459
- rows=rows
460
- ),
484
+ element=table_element,
461
485
  children=[]
462
486
  )
463
487
  else:
@@ -510,4 +534,9 @@ class StandardDomTree(BaseModel):
510
534
  # 计算标记列表的长度,即标记的数量
511
535
  token_count = len(tokens)
512
536
  # 返回标记的数量
513
- return token_count
537
+ return token_count
538
+
539
+
540
+ # 更新forward references
541
+ StandardNode.update_forward_refs()
542
+ Cell.update_forward_refs()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-openapi
3
- Version: 1.0.3
3
+ Version: 1.0.3.2
4
4
  Summary: client for openapi service.
5
5
  Home-page:
6
6
  Author: ['tangxiaolong', 'fanqiangwei', 'zhangxiaojia', 'liumin', 'wangyukun']
@@ -12,6 +12,8 @@ License-File: LICENSE
12
12
  Requires-Dist: httpx<=0.26.0,>=0.10.0
13
13
  Requires-Dist: Werkzeug==3.0.1
14
14
  Requires-Dist: tiktoken>=0.5.0
15
+ Requires-Dist: pydantic==1.10.14
16
+ Requires-Dist: fastapi==0.110.0
15
17
  Dynamic: author
16
18
  Dynamic: classifier
17
19
  Dynamic: description
@@ -259,3 +261,5 @@ get接口地址:/v1/openapi/log/{requestId}
259
261
  * rename 包名
260
262
  * 1.0.2
261
263
  * 修复bug
264
+ * 1.0.3
265
+ * 新增standard domtree
@@ -1,3 +1,5 @@
1
1
  httpx<=0.26.0,>=0.10.0
2
2
  Werkzeug==3.0.1
3
3
  tiktoken>=0.5.0
4
+ pydantic==1.10.14
5
+ fastapi==0.110.0
File without changes
File without changes