bella-openapi 1.0.2.4__tar.gz → 1.0.2.5__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.2.4/src/bella_openapi.egg-info → bella_openapi-1.0.2.5}/PKG-INFO +1 -1
  2. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/setup.py +1 -1
  3. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/entity/standard_domtree.py +23 -12
  4. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5/src/bella_openapi.egg-info}/PKG-INFO +1 -1
  5. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/LICENSE +0 -0
  6. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/README.md +0 -0
  7. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/setup.cfg +0 -0
  8. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/__init__.py +0 -0
  9. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/auth_billing.py +0 -0
  10. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/authorize.py +0 -0
  11. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/__init__.py +0 -0
  12. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/_context.py +0 -0
  13. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/fastapi_interceptor.py +0 -0
  14. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/record_log.py +0 -0
  15. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/trace_requests.py +0 -0
  16. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/config.py +0 -0
  17. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/console/__init__.py +0 -0
  18. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/console/models.py +0 -0
  19. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/entity/__init__.py +0 -0
  20. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/exception.py +0 -0
  21. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/log.py +0 -0
  22. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/middleware/__init__.py +0 -0
  23. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/middleware/context_middleware.py +0 -0
  24. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/openapi_contexvar.py +0 -0
  25. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi/schema.py +0 -0
  26. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/SOURCES.txt +0 -0
  27. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/dependency_links.txt +0 -0
  28. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/not-zip-safe +0 -0
  29. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/requires.txt +0 -0
  30. {bella_openapi-1.0.2.4 → bella_openapi-1.0.2.5}/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.2.4
3
+ Version: 1.0.2.5
4
4
  Summary: client for openapi service.
5
5
  Home-page:
6
6
  Author: ['tangxiaolong', 'fanqiangwei', 'zhangxiaojia', 'liumin', 'wangyukun']
@@ -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.2.4"
6
+ __version__ = "1.0.2.5"
7
7
  __author__ = ["tangxiaolong", "fanqiangwei", "zhangxiaojia", 'liumin', 'wangyukun']
8
8
  __email__ = ''
9
9
  readme_path = 'README.md'
@@ -31,16 +31,7 @@ layout_type_mapping = {
31
31
  "TableNote": "Text", # 目前实际解析出来没有
32
32
  }
33
33
 
34
- # 自研模型均用gpt-4计算(可能有误差,可忽略)
35
- def count_tokens(text: str, model: str = "gpt-4") -> int:
36
- if not text:
37
- return 0
38
- encoding = tiktoken.encoding_for_model(model)
39
- tokens = encoding.encode(text)
40
- # 计算标记列表的长度,即标记的数量
41
- token_count = len(tokens)
42
- # 返回标记的数量
43
- return token_count
34
+
44
35
 
45
36
  class SourceFile(BaseModel):
46
37
  id: str # 文件ID,唯一标识符,类型为string
@@ -440,7 +431,7 @@ class StandardDomTree(BaseModel):
440
431
  cell_data['end_col']],
441
432
  text=cell_text,
442
433
  # 目前只会有一个元素,且是Text类型,Path重新从头编号,相对cell是root
443
- nodes=[StandardNode(summary="", tokens=count_tokens(cell_text), path=[1], children=[],
434
+ nodes=[StandardNode(summary="", tokens=cls.count_tokens(cell_text), path=[1], children=[],
444
435
  element=StandardElement(
445
436
  type='Text',
446
437
  positions=[],
@@ -491,7 +482,7 @@ class StandardDomTree(BaseModel):
491
482
  standard_node.children.append(standard_child)
492
483
 
493
484
  # 计算 token 数量:自身 text 的 token 数量 + 子节点 token 数量
494
- tokens = count_tokens(text)
485
+ tokens = cls.count_tokens(text)
495
486
  for child in standard_node.children:
496
487
  tokens += child.tokens
497
488
 
@@ -500,3 +491,23 @@ class StandardDomTree(BaseModel):
500
491
 
501
492
  return standard_node
502
493
 
494
+ @classmethod
495
+ def count_tokens(cls, text: str, model: str = "gpt-4") -> int:
496
+ """
497
+ 计算文本的token数量
498
+
499
+ Args:
500
+ text: 要计算的文本
501
+ model: 使用的模型名称,默认为gpt-4
502
+
503
+ Returns:
504
+ int: token数量
505
+ """
506
+ if not text:
507
+ return 0
508
+ encoding = tiktoken.encoding_for_model(model)
509
+ tokens = encoding.encode(text)
510
+ # 计算标记列表的长度,即标记的数量
511
+ token_count = len(tokens)
512
+ # 返回标记的数量
513
+ return token_count
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-openapi
3
- Version: 1.0.2.4
3
+ Version: 1.0.2.5
4
4
  Summary: client for openapi service.
5
5
  Home-page:
6
6
  Author: ['tangxiaolong', 'fanqiangwei', 'zhangxiaojia', 'liumin', 'wangyukun']
File without changes