bella-openapi 1.0.2.3__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.
- {bella_openapi-1.0.2.3/src/bella_openapi.egg-info → bella_openapi-1.0.2.5}/PKG-INFO +1 -1
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/setup.py +1 -3
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/__init__.py +23 -2
- bella_openapi-1.0.2.5/src/bella_openapi/entity/__init__.py +27 -0
- {bella_openapi-1.0.2.3/src/bella_openapi/domtree → bella_openapi-1.0.2.5/src/bella_openapi/entity}/standard_domtree.py +25 -4
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5/src/bella_openapi.egg-info}/PKG-INFO +1 -1
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/SOURCES.txt +2 -3
- bella_openapi-1.0.2.3/src/bella_openapi/domtree/__init__.py +0 -3
- bella_openapi-1.0.2.3/src/bella_openapi/domtree/utils.py +0 -12
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/LICENSE +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/README.md +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/setup.cfg +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/auth_billing.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/authorize.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/__init__.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/_context.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/fastapi_interceptor.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/record_log.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/trace_requests.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/config.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/console/__init__.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/console/models.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/exception.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/log.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/middleware/__init__.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/middleware/context_middleware.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/openapi_contexvar.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/schema.py +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/dependency_links.txt +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/not-zip-safe +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/requires.txt +0 -0
- {bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/top_level.txt +0 -0
@@ -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.
|
6
|
+
__version__ = "1.0.2.5"
|
7
7
|
__author__ = ["tangxiaolong", "fanqiangwei", "zhangxiaojia", 'liumin', 'wangyukun']
|
8
8
|
__email__ = ''
|
9
9
|
readme_path = 'README.md'
|
@@ -16,9 +16,7 @@ setup(
|
|
16
16
|
install_requires=[
|
17
17
|
'httpx>=0.10.0,<=0.26.0',
|
18
18
|
'Werkzeug==3.0.1',
|
19
|
-
# 'pydantic>=1.10.0',
|
20
19
|
'tiktoken>=0.5.0',
|
21
|
-
# 'fastapi>=0.110.0',
|
22
20
|
],
|
23
21
|
url='',
|
24
22
|
author=__author__,
|
@@ -3,7 +3,19 @@ from .log import operation_log, submit_log
|
|
3
3
|
from .openapi_contexvar import trace_id_context, caller_id_context, request_url_context
|
4
4
|
from .auth_billing import ErrorInfo, async_authenticate_decorator_args, authenticate_user, print_context, \
|
5
5
|
get_context, set_context, clean_context, report
|
6
|
-
from .
|
6
|
+
from .entity import (
|
7
|
+
StandardDomTree,
|
8
|
+
StandardNode,
|
9
|
+
SourceFile,
|
10
|
+
StandardPosition,
|
11
|
+
StandardImage,
|
12
|
+
Cell,
|
13
|
+
StandardRow,
|
14
|
+
StandardBaseElement,
|
15
|
+
StandardElement,
|
16
|
+
StandardTableElement,
|
17
|
+
StandardImageElement
|
18
|
+
)
|
7
19
|
|
8
20
|
__all__ = ["validate_token", "operation_log",
|
9
21
|
"support_model",
|
@@ -22,5 +34,14 @@ __all__ = ["validate_token", "operation_log",
|
|
22
34
|
"clean_context",
|
23
35
|
"report",
|
24
36
|
"StandardDomTree",
|
25
|
-
"StandardNode"
|
37
|
+
"StandardNode",
|
38
|
+
"SourceFile",
|
39
|
+
"StandardPosition",
|
40
|
+
"StandardImage",
|
41
|
+
"Cell",
|
42
|
+
"StandardRow",
|
43
|
+
"StandardBaseElement",
|
44
|
+
"StandardElement",
|
45
|
+
"StandardTableElement",
|
46
|
+
"StandardImageElement"
|
26
47
|
]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
from .standard_domtree import (
|
2
|
+
StandardDomTree,
|
3
|
+
StandardNode,
|
4
|
+
SourceFile,
|
5
|
+
StandardPosition,
|
6
|
+
StandardImage,
|
7
|
+
Cell,
|
8
|
+
StandardRow,
|
9
|
+
StandardBaseElement,
|
10
|
+
StandardElement,
|
11
|
+
StandardTableElement,
|
12
|
+
StandardImageElement
|
13
|
+
)
|
14
|
+
|
15
|
+
__all__ = [
|
16
|
+
"StandardDomTree",
|
17
|
+
"StandardNode",
|
18
|
+
"SourceFile",
|
19
|
+
"StandardPosition",
|
20
|
+
"StandardImage",
|
21
|
+
"Cell",
|
22
|
+
"StandardRow",
|
23
|
+
"StandardBaseElement",
|
24
|
+
"StandardElement",
|
25
|
+
"StandardTableElement",
|
26
|
+
"StandardImageElement"
|
27
|
+
]
|
@@ -10,8 +10,7 @@ StandardDomTree - 新的DOM树协议定义
|
|
10
10
|
|
11
11
|
from typing import List, Optional, Literal, Any, Union
|
12
12
|
from pydantic import BaseModel, Field
|
13
|
-
|
14
|
-
from bella_openapi.domtree.utils import count_tokens
|
13
|
+
import tiktoken
|
15
14
|
|
16
15
|
# 布局类型映射表:将旧解析器的布局类型映射到新的标准类型
|
17
16
|
# 注意:这个映射表是临时的,后续计划统一布局类型定义
|
@@ -33,6 +32,7 @@ layout_type_mapping = {
|
|
33
32
|
}
|
34
33
|
|
35
34
|
|
35
|
+
|
36
36
|
class SourceFile(BaseModel):
|
37
37
|
id: str # 文件ID,唯一标识符,类型为string
|
38
38
|
name: str # 文件名,文档的名称,类型为string
|
@@ -431,7 +431,7 @@ class StandardDomTree(BaseModel):
|
|
431
431
|
cell_data['end_col']],
|
432
432
|
text=cell_text,
|
433
433
|
# 目前只会有一个元素,且是Text类型,Path重新从头编号,相对cell是root
|
434
|
-
nodes=[StandardNode(summary="", tokens=count_tokens(cell_text), path=[1], children=[],
|
434
|
+
nodes=[StandardNode(summary="", tokens=cls.count_tokens(cell_text), path=[1], children=[],
|
435
435
|
element=StandardElement(
|
436
436
|
type='Text',
|
437
437
|
positions=[],
|
@@ -482,7 +482,7 @@ class StandardDomTree(BaseModel):
|
|
482
482
|
standard_node.children.append(standard_child)
|
483
483
|
|
484
484
|
# 计算 token 数量:自身 text 的 token 数量 + 子节点 token 数量
|
485
|
-
tokens = count_tokens(text)
|
485
|
+
tokens = cls.count_tokens(text)
|
486
486
|
for child in standard_node.children:
|
487
487
|
tokens += child.tokens
|
488
488
|
|
@@ -490,3 +490,24 @@ class StandardDomTree(BaseModel):
|
|
490
490
|
standard_node.tokens = tokens
|
491
491
|
|
492
492
|
return standard_node
|
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
|
@@ -22,8 +22,7 @@ src/bella_openapi/bella_trace/record_log.py
|
|
22
22
|
src/bella_openapi/bella_trace/trace_requests.py
|
23
23
|
src/bella_openapi/console/__init__.py
|
24
24
|
src/bella_openapi/console/models.py
|
25
|
-
src/bella_openapi/
|
26
|
-
src/bella_openapi/
|
27
|
-
src/bella_openapi/domtree/utils.py
|
25
|
+
src/bella_openapi/entity/__init__.py
|
26
|
+
src/bella_openapi/entity/standard_domtree.py
|
28
27
|
src/bella_openapi/middleware/__init__.py
|
29
28
|
src/bella_openapi/middleware/context_middleware.py
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import tiktoken
|
2
|
-
|
3
|
-
# 自研模型均用gpt-4计算(可能有误差,可忽略)
|
4
|
-
def count_tokens(text: str, model: str = "gpt-4") -> int:
|
5
|
-
if not text:
|
6
|
-
return 0
|
7
|
-
encoding = tiktoken.encoding_for_model(model)
|
8
|
-
tokens = encoding.encode(text)
|
9
|
-
# 计算标记列表的长度,即标记的数量
|
10
|
-
token_count = len(tokens)
|
11
|
-
# 返回标记的数量
|
12
|
-
return token_count
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/fastapi_interceptor.py
RENAMED
File without changes
|
File without changes
|
{bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/bella_trace/trace_requests.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi/middleware/context_middleware.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{bella_openapi-1.0.2.3 → bella_openapi-1.0.2.5}/src/bella_openapi.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|