coze-coding-utils 0.1.10__tar.gz → 0.1.11__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.
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/PKG-INFO +1 -1
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/pyproject.toml +1 -1
- coze_coding_utils-0.1.11/src/coze_coding_utils/__init__.py +3 -0
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/src/coze_coding_utils/runtime_ctx/context.py +21 -6
- coze_coding_utils-0.1.10/src/coze_coding_utils/__init__.py +0 -3
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/.gitignore +0 -0
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/LICENSE +0 -0
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/README.md +0 -0
- {coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/src/coze_coding_utils/runtime_ctx/__init__.py +0 -0
{coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/src/coze_coding_utils/runtime_ctx/context.py
RENAMED
|
@@ -8,11 +8,18 @@ HEADER_X_TT_LOGID = "x-tt-logid"
|
|
|
8
8
|
HEADER_X_TT_ENV = "x-tt-env"
|
|
9
9
|
HEADER_X_USE_PPE = "x-use-ppe"
|
|
10
10
|
HEADER_X_TT_ENV_FE = "x-tt-env-fe"
|
|
11
|
+
HEADER_X_RUN_MODE = "x-run-mode"
|
|
11
12
|
HEADER_RPC_PERSIST_RES_REC_BIZ_SCENE = "rpc-persist-res-rec-biz-scene"
|
|
12
|
-
HEADER_RPC_PERSIST_COZE_RECORD_ROOT_ID =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
HEADER_RPC_PERSIST_COZE_RECORD_ROOT_ID = (
|
|
14
|
+
"rpc-persist-coze-record-root-id" # root_id,串联一次完整请求,通常标识一次完整对话
|
|
15
|
+
)
|
|
16
|
+
HEADER_RPC_PERSIST_RES_REC_ROOT_ENTITY_TYPE = "rpc-persist-res-rec-root-entity-type" # 对应最顶层实体类型,用于标识资源消耗的来源归属实体
|
|
17
|
+
HEADER_RPC_PERSIST_RES_REC_ROOT_ENTITY_ID = (
|
|
18
|
+
"rpc-persist-res-rec-root-entity-id" # 对应最顶层实体ID
|
|
19
|
+
)
|
|
20
|
+
HEADER_RPC_PERSIST_RES_REC_EXT_INFO = (
|
|
21
|
+
"rpc-persist-res-rec-ext-info" # 扩展信息,json字符串格式
|
|
22
|
+
)
|
|
16
23
|
|
|
17
24
|
# Environment variable keys
|
|
18
25
|
ENV_SPACE_ID = "COZE_PROJECT_SPACE_ID"
|
|
@@ -22,16 +29,18 @@ ENV_PROJECT_ID = "COZE_PROJECT_ID"
|
|
|
22
29
|
@dataclass(slots=True)
|
|
23
30
|
class Context:
|
|
24
31
|
"""运行时上下文,封装请求关联的标识与环境信息。"""
|
|
32
|
+
|
|
25
33
|
run_id: str
|
|
26
34
|
space_id: str
|
|
27
35
|
project_id: str
|
|
28
36
|
logid: str = ""
|
|
29
37
|
method: str = ""
|
|
30
38
|
|
|
39
|
+
x_run_mode: Optional[str] = None
|
|
31
40
|
x_tt_env: Optional[str] = None
|
|
32
41
|
x_use_ppe: Optional[str] = None
|
|
33
42
|
x_tt_env_fe: Optional[str] = None
|
|
34
|
-
|
|
43
|
+
|
|
35
44
|
rpc_persist_res_rec_biz_scene: Optional[str] = None
|
|
36
45
|
rpc_persist_coze_record_root_id: Optional[str] = None
|
|
37
46
|
rpc_persist_res_rec_root_entity_type: Optional[str] = None
|
|
@@ -39,7 +48,10 @@ class Context:
|
|
|
39
48
|
rpc_persist_res_rec_ext_info: Optional[str] = None
|
|
40
49
|
|
|
41
50
|
|
|
42
|
-
def new_context(
|
|
51
|
+
def new_context(
|
|
52
|
+
method: str,
|
|
53
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
54
|
+
) -> Context:
|
|
43
55
|
"""创建上下文对象,读取必要环境变量并可从请求头补充可选字段。"""
|
|
44
56
|
ctx = Context(
|
|
45
57
|
run_id=str(uuid.uuid4()),
|
|
@@ -54,6 +66,7 @@ def new_context(method: str, headers: Optional[Mapping[str, str]] = None) -> Con
|
|
|
54
66
|
HEADER_X_TT_ENV: "x_tt_env",
|
|
55
67
|
HEADER_X_USE_PPE: "x_use_ppe",
|
|
56
68
|
HEADER_X_TT_ENV_FE: "x_tt_env_fe",
|
|
69
|
+
HEADER_X_RUN_MODE: "x_run_mode",
|
|
57
70
|
HEADER_RPC_PERSIST_RES_REC_BIZ_SCENE: "rpc_persist_res_rec_biz_scene",
|
|
58
71
|
HEADER_RPC_PERSIST_COZE_RECORD_ROOT_ID: "rpc_persist_coze_record_root_id",
|
|
59
72
|
HEADER_RPC_PERSIST_RES_REC_ROOT_ENTITY_TYPE: "rpc_persist_res_rec_root_entity_type",
|
|
@@ -77,6 +90,7 @@ def default_headers(ctx: Context | None) -> Dict[str, str]:
|
|
|
77
90
|
"x_tt_env": HEADER_X_TT_ENV,
|
|
78
91
|
"x_use_ppe": HEADER_X_USE_PPE,
|
|
79
92
|
"x_tt_env_fe": HEADER_X_TT_ENV_FE,
|
|
93
|
+
"x_run_mode": HEADER_X_RUN_MODE,
|
|
80
94
|
"rpc_persist_res_rec_biz_scene": HEADER_RPC_PERSIST_RES_REC_BIZ_SCENE,
|
|
81
95
|
"rpc_persist_coze_record_root_id": HEADER_RPC_PERSIST_COZE_RECORD_ROOT_ID,
|
|
82
96
|
"rpc_persist_res_rec_root_entity_type": HEADER_RPC_PERSIST_RES_REC_ROOT_ENTITY_TYPE,
|
|
@@ -89,6 +103,7 @@ def default_headers(ctx: Context | None) -> Dict[str, str]:
|
|
|
89
103
|
headers[hk] = v
|
|
90
104
|
return headers
|
|
91
105
|
|
|
106
|
+
|
|
92
107
|
__all__ = [
|
|
93
108
|
"Context",
|
|
94
109
|
"new_context",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{coze_coding_utils-0.1.10 → coze_coding_utils-0.1.11}/src/coze_coding_utils/runtime_ctx/__init__.py
RENAMED
|
File without changes
|