bella-openapi 1.0.2.3__py3-none-any.whl → 1.0.2.4__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.
- bella_openapi/__init__.py +23 -2
- bella_openapi/entity/__init__.py +27 -0
- bella_openapi/{domtree → entity}/standard_domtree.py +12 -2
- {bella_openapi-1.0.2.3.dist-info → bella_openapi-1.0.2.4.dist-info}/METADATA +1 -1
- {bella_openapi-1.0.2.3.dist-info → bella_openapi-1.0.2.4.dist-info}/RECORD +8 -9
- bella_openapi/domtree/__init__.py +0 -3
- bella_openapi/domtree/utils.py +0 -12
- {bella_openapi-1.0.2.3.dist-info → bella_openapi-1.0.2.4.dist-info}/WHEEL +0 -0
- {bella_openapi-1.0.2.3.dist-info → bella_openapi-1.0.2.4.dist-info}/licenses/LICENSE +0 -0
- {bella_openapi-1.0.2.3.dist-info → bella_openapi-1.0.2.4.dist-info}/top_level.txt +0 -0
bella_openapi/__init__.py
CHANGED
@@ -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
|
# 注意:这个映射表是临时的,后续计划统一布局类型定义
|
@@ -32,6 +31,16 @@ layout_type_mapping = {
|
|
32
31
|
"TableNote": "Text", # 目前实际解析出来没有
|
33
32
|
}
|
34
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
|
35
44
|
|
36
45
|
class SourceFile(BaseModel):
|
37
46
|
id: str # 文件ID,唯一标识符,类型为string
|
@@ -490,3 +499,4 @@ class StandardDomTree(BaseModel):
|
|
490
499
|
standard_node.tokens = tokens
|
491
500
|
|
492
501
|
return standard_node
|
502
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
bella_openapi/__init__.py,sha256=
|
1
|
+
bella_openapi/__init__.py,sha256=Iq8YjMYBNWJvQvlu9gFy8uxG8Xf06jPaCyZvXtAW2jA,1462
|
2
2
|
bella_openapi/auth_billing.py,sha256=Hn0KS8GuG48etnvnd1Faej4IfFXD3tjzalUzDnpZh7Q,3520
|
3
3
|
bella_openapi/authorize.py,sha256=cO6J-wx9dmmkDAeqpXT7QlyCr13hO-HSC5SWQSw2gZw,2150
|
4
4
|
bella_openapi/config.py,sha256=Dn8vnToDaOesPGboauxCCwNrW5awQLeSkmDjNjXS4bQ,319
|
@@ -13,13 +13,12 @@ bella_openapi/bella_trace/record_log.py,sha256=qSZXp_VTzIzMVlQNnZKLIbmyGvggFSQL5
|
|
13
13
|
bella_openapi/bella_trace/trace_requests.py,sha256=ADA8J_gbC3TwUo5LWQ3c_yTmCSZRaWzq1FC0iUOnst0,1370
|
14
14
|
bella_openapi/console/__init__.py,sha256=uSfr5v6JLRSqTlftjK_ZU1pnbkEyxAPbuQbMyYX_phk,64
|
15
15
|
bella_openapi/console/models.py,sha256=Hh1UuYHIxFtF9r5QK-pSJPFrSqbZUHv6spLvPbCeX08,1274
|
16
|
-
bella_openapi/
|
17
|
-
bella_openapi/
|
18
|
-
bella_openapi/domtree/utils.py,sha256=-ItZYh9Gj8QyOkZzjCC5xWPYU-FkzJllGC0oUO21Kp4,394
|
16
|
+
bella_openapi/entity/__init__.py,sha256=zzsYYg859pzPSgx1Py2kxB2ozQ0tt4OtTatBtpm2bAw,512
|
17
|
+
bella_openapi/entity/standard_domtree.py,sha256=GJZ4_2zcagtmUf4XMf6_IGWCr1unW6NoCwbjEm6QfCU,20293
|
19
18
|
bella_openapi/middleware/__init__.py,sha256=XWvZG1xO30ZXIn10YVYthmT1BV-9fonMEP_jVRZbAlQ,157
|
20
19
|
bella_openapi/middleware/context_middleware.py,sha256=YawQyKAxMzvlDs_MxcuQKh90pP6VoMKzCBDS94qmlzQ,3870
|
21
|
-
bella_openapi-1.0.2.
|
22
|
-
bella_openapi-1.0.2.
|
23
|
-
bella_openapi-1.0.2.
|
24
|
-
bella_openapi-1.0.2.
|
25
|
-
bella_openapi-1.0.2.
|
20
|
+
bella_openapi-1.0.2.4.dist-info/licenses/LICENSE,sha256=O-0zMbcEi6wXz1DiSdVgzMlQjJcNqNe5KDv08uYzqR0,1055
|
21
|
+
bella_openapi-1.0.2.4.dist-info/METADATA,sha256=FGMjsUJzbybMQLvPf_VHvyhhKMwTkSfmirp1DLTCvpM,9377
|
22
|
+
bella_openapi-1.0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
bella_openapi-1.0.2.4.dist-info/top_level.txt,sha256=EZuq3F6tKeF-vmZQi6_S2XzmES7SPW7HAbGN1Uv9vN8,14
|
24
|
+
bella_openapi-1.0.2.4.dist-info/RECORD,,
|
bella_openapi/domtree/utils.py
DELETED
@@ -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
|