hjxdl 0.3.24__py3-none-any.whl → 0.3.26__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.
hdl/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.3.24'
16
- __version_tuple__ = version_tuple = (0, 3, 24)
15
+ __version__ = version = '0.3.26'
16
+ __version_tuple__ = version_tuple = (0, 3, 26)
File without changes
@@ -0,0 +1,56 @@
1
+ import time
2
+ from functools import wraps
3
+
4
+ def measure_stream_performance(func):
5
+ @wraps(func)
6
+ def wrapper(*args, **kwargs):
7
+ # 开始计时
8
+ start_time = time.time()
9
+
10
+ # 执行流式处理函数并获取生成器
11
+ stream = func(*args, **kwargs)
12
+
13
+ # 初始化计时和统计变量
14
+ first_char_time = None
15
+ total_chars = 0
16
+
17
+ for i in stream:
18
+ if i['type'] == 'text' and i['content']:
19
+ if first_char_time is None:
20
+ # 第一次输出字符的时间
21
+ first_char_time = time.time()
22
+
23
+ # 输出字符并统计数量
24
+ print(i['content'], end="", flush=True)
25
+ total_chars += len(i['content'])
26
+
27
+ # 总时间计算
28
+ end_time = time.time()
29
+ total_time = end_time - start_time
30
+ time_to_first_char = first_char_time - start_time if first_char_time else total_time
31
+
32
+ # 每秒输出的字符数
33
+ chars_per_second = total_chars / total_time if total_time > 0 else 0
34
+
35
+ # 打印统计信息
36
+ print("\n--- Statistics ---")
37
+ print(f"Time to first character: {time_to_first_char:.2f} seconds")
38
+ print(f"Total time: {total_time:.2f} seconds")
39
+ print(f"Characters per second: {chars_per_second:.2f}")
40
+
41
+ return wrapper
42
+
43
+
44
+ @measure_stream_performance
45
+ def run_llm_stream(
46
+ llm,
47
+ client_id,
48
+ prompt,
49
+ **kwargs
50
+ ):
51
+ resp = llm.stream(
52
+ client_id=client_id,
53
+ prompt=prompt,
54
+ **kwargs
55
+ )
56
+ return resp
hdl/utils/desc/tools.py CHANGED
@@ -3,7 +3,7 @@ TOOL_DICT = {
3
3
  "type": "function",
4
4
  "function": {
5
5
  "name": "get_weather",
6
- "description": "Get current temperature for a given location.",
6
+ "description": "仅在用户明确询问天气、气候、气温等信息时,获取指定城市的天气情况。",
7
7
  "parameters": {
8
8
  "type": "object",
9
9
  "properties": {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: hjxdl
3
- Version: 0.3.24
3
+ Version: 0.3.26
4
4
  Summary: A collection of functions for Jupyter notebooks
5
5
  Home-page: https://github.com/huluxiaohuowa/hdl
6
6
  Author: Jianxing Hu
@@ -1,5 +1,5 @@
1
1
  hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
2
- hdl/_version.py,sha256=xxze0Z9aZc1cnT2UsH5Up2FW8XUOyAB2EqHM_PedmQc,413
2
+ hdl/_version.py,sha256=30eq06siTU79TQsQ2EEqu52177bco5xynk3YSelgFpk,413
3
3
  hdl/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  hdl/args/loss_args.py,sha256=s7YzSdd7IjD24rZvvOrxLLFqMZQb9YylxKeyelSdrTk,70
5
5
  hdl/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -121,10 +121,12 @@ hdl/utils/database_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
121
121
  hdl/utils/database_tools/connect.py,sha256=xCacGucKxlQUXs6AsNddpeECvdqT1180V1ZWqHrUdNA,875
122
122
  hdl/utils/database_tools/datetime.py,sha256=xqE2xNiOpADzX-R8_bM0bioJRF3Ay9Jp1CAG6dy6uVI,1202
123
123
  hdl/utils/database_tools/web.py,sha256=awJ8lafL-2KRjf3V1uuij8JIvX9U5fI8fLZKOkOvqtk,5771
124
+ hdl/utils/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
+ hdl/utils/decorators/llm.py,sha256=RRdixVVWHopx476fVgmr9-w7yBqZMBdJMrkjZZKFjdk,1559
124
126
  hdl/utils/desc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
127
  hdl/utils/desc/func_desc.py,sha256=sHmVZZmV7Zgii--gnHqMs6fTb7HVkqTOf8Pl_0F6qlI,3808
126
128
  hdl/utils/desc/template.py,sha256=Kf_tbL-XkDCKNQ3UncbCuYEeUgXEa7kRVCf9TD2b8og,2526
127
- hdl/utils/desc/tools.py,sha256=KNxmmTFFL3BZPh-2NGvNPz2VygHPJ3BWFa4VY2jy58g,619
129
+ hdl/utils/desc/tools.py,sha256=tovV4sqjMBCHI6PG5YGJYBKpoXRhgYilzt77ZYTL7Jk,673
128
130
  hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
131
  hdl/utils/general/glob.py,sha256=Zuf7WHU0UdUPOs9UrhxmrCiMC8GrHxQU6n3mTThv6yc,1120
130
132
  hdl/utils/general/runners.py,sha256=x7QBolp3MrqNV6L4rB6Ueybr26bqkRFZTuXhY0SwyLk,3061
@@ -141,8 +143,8 @@ hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
141
143
  hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
142
144
  hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
143
145
  hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
144
- hjxdl-0.3.24.dist-info/LICENSE,sha256=lkMiSbeZHBQLB9LJEkS9-L3Z-LBC4yGnKrzHSG8RkPM,2599
145
- hjxdl-0.3.24.dist-info/METADATA,sha256=HEeA6mVJG8tifL-Hfoabfd8WP-6YB5Cmd6-rdHHCmAc,1336
146
- hjxdl-0.3.24.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
147
- hjxdl-0.3.24.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
148
- hjxdl-0.3.24.dist-info/RECORD,,
146
+ hjxdl-0.3.26.dist-info/LICENSE,sha256=lkMiSbeZHBQLB9LJEkS9-L3Z-LBC4yGnKrzHSG8RkPM,2599
147
+ hjxdl-0.3.26.dist-info/METADATA,sha256=Y7g6KkHdFw_eroB_ynzGyMI9MN3Z4YypdWjf6YVnd_Y,1336
148
+ hjxdl-0.3.26.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
+ hjxdl-0.3.26.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
150
+ hjxdl-0.3.26.dist-info/RECORD,,
File without changes