hjxdl 0.2.32__py3-none-any.whl → 0.2.33__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.2.32'
16
- __version_tuple__ = version_tuple = (0, 2, 32)
15
+ __version__ = version = '0.2.33'
16
+ __version_tuple__ = version_tuple = (0, 2, 33)
@@ -51,6 +51,22 @@ FN_DESC = {
51
51
  }
52
52
  }
53
53
 
54
+ """,
55
+ "execute_code(code)": """
56
+ ## 函数名:execute_code,
57
+ 描述:当用户明确要求执行一段代码时,调用此工具,执行这段代码,返回执行结果。
58
+ 触发条件:用户要求执行一段代码
59
+ 参数:
60
+ # code (str): 用户要求执行的代码
61
+ 返回值 (str): 执行结果
62
+ 需要返回的json
63
+ {
64
+ "function_name": "execute_code",
65
+ "params":
66
+ {
67
+ "code": <code>
68
+ }
69
+ }
54
70
  """,
55
71
  "default": None
56
72
  }
@@ -0,0 +1,40 @@
1
+ import subprocess
2
+ import sys
3
+ import os
4
+
5
+ def execute_code(code):
6
+ """
7
+ Executes the given Python code string in a subprocess.
8
+
9
+ This function uses the subprocess to execute Python code strings, limiting the execution time to prevent infinite loops,
10
+ and captures the execution output and errors for returning results.
11
+
12
+ Parameters:
13
+ code (str): The Python code string to be executed.
14
+
15
+ Returns:
16
+ str: The output result of executing the code or an error message.
17
+ """
18
+ try:
19
+ # Execute the code in a subprocess for safety
20
+ print(code)
21
+ python_path = sys.executable # 获取当前 Python 解释器路径
22
+ result = subprocess.run(
23
+ [
24
+ python_path, # 使用当前 conda 环境中的 Python
25
+ '-c',
26
+ code
27
+ ],
28
+ capture_output=True,
29
+ text=True,
30
+ timeout=5,
31
+ env={"PYTHONPATH": os.getcwd()}
32
+ )
33
+ # Return the execution result based on the subprocess return code
34
+ return result.stdout if result.returncode == 0 else f"Error: {result.stderr}"
35
+ except subprocess.TimeoutExpired:
36
+ # Return a timeout error message if the code execution exceeds the limit
37
+ return "Error: Code execution timed out"
38
+ except Exception as e:
39
+ # Return the exception information for other exceptions
40
+ return f"Error: {str(e)}"
hdl/utils/llm/visrag.py CHANGED
@@ -22,8 +22,20 @@ def get_image_md5(img: Image.Image):
22
22
  return hex_digest
23
23
 
24
24
  def calculate_md5_from_binary(binary_data):
25
+ """
26
+ 计算给定二进制数据的MD5哈希值。
27
+
28
+ 参数:
29
+ binary_data (bytes): 需要计算MD5的二进制数据。
30
+
31
+ 返回:
32
+ str: 二进制数据的MD5哈希值的十六进制表示。
33
+ """
34
+ # 初始化MD5哈希对象
25
35
  hash_md5 = hashlib.md5()
36
+ # 更新哈希对象以计算二进制数据的MD5
26
37
  hash_md5.update(binary_data)
38
+ # 返回计算出的MD5哈希值的十六进制表示
27
39
  return hash_md5.hexdigest()
28
40
 
29
41
  def add_pdf_gradio(pdf_file_binary, progress=gr.Progress(), cache_dir=None, model=None, tokenizer=None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hjxdl
3
- Version: 0.2.32
3
+ Version: 0.2.33
4
4
  Summary: A collection of functions for Jupyter notebooks
5
5
  Home-page: https://github.com/huluxiaohuowa/hdl
6
6
  Author: Jianxing Hu
@@ -15,12 +15,12 @@ Requires-Dist: openai
15
15
  Requires-Dist: tqdm
16
16
  Requires-Dist: geopy
17
17
  Requires-Dist: pytz
18
- Requires-Dist: duckduckgo-search[lxml]
18
+ Requires-Dist: duckduckgo_search[lxml]
19
19
  Requires-Dist: opencv-python
20
20
  Requires-Dist: redis[hiredis]
21
21
  Requires-Dist: psycopg[binary]
22
22
  Requires-Dist: Pillow
23
- Requires-Dist: open-clip-torch
23
+ Requires-Dist: open_clip_torch
24
24
  Requires-Dist: natsort
25
25
 
26
26
  # DL framework by Jianxing
@@ -1,5 +1,5 @@
1
1
  hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
2
- hdl/_version.py,sha256=jSnpQjxfX4ZsfrMFFxLeBiF7_cxq8o44X1E_cpi4UPE,413
2
+ hdl/_version.py,sha256=T7EtJYRX8K7MA0r6pLuoIDP8tNQ2dSjsgBzJKunIqDA,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
@@ -122,10 +122,11 @@ hdl/utils/database_tools/connect.py,sha256=xCacGucKxlQUXs6AsNddpeECvdqT1180V1ZWq
122
122
  hdl/utils/database_tools/datetime.py,sha256=xqE2xNiOpADzX-R8_bM0bioJRF3Ay9Jp1CAG6dy6uVI,1202
123
123
  hdl/utils/database_tools/web.py,sha256=vZJYWA02QbyUUMGLDX710cexn7RlfWeHa8YwK3UsDZ0,1934
124
124
  hdl/utils/desc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
- hdl/utils/desc/func_desc.py,sha256=uFU61nZHE0TQce1YtpJWldXnH_CdskYmW2fDDQpToOA,1917
125
+ hdl/utils/desc/func_desc.py,sha256=ykqYBpGHQnXm6pJUFmrRMZBGIpbwrERfGrt3anyc5aU,2346
126
126
  hdl/utils/desc/template.py,sha256=a0UAkkKctt_EHY9UECsIIAwVkGPcM1Hr01HSkRMeIuw,1272
127
127
  hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
128
  hdl/utils/general/glob.py,sha256=8-RCnt6L297wMIfn34ZAMCsGCZUjHG3MGglGZI1cX0g,491
129
+ hdl/utils/general/runners.py,sha256=-xGCkRKKqSEFUtDy0o8JkXpfFVrXPCU0C-ISfv-pNis,1413
129
130
  hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
131
  hdl/utils/llm/chat.py,sha256=OzyY9xACOOocx9zZigtq9YAPvHtDUo8v2fvf1Tyjg_U,14891
131
132
  hdl/utils/llm/chatgr.py,sha256=lKaDeimYz-Bw32QXYtde51xjf7gbfS2CEYt5R0ODunM,4075
@@ -133,12 +134,12 @@ hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
133
134
  hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
134
135
  hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
135
136
  hdl/utils/llm/vis.py,sha256=BsGAfy5X8sMFnX5A3vHpTPDRe_-IDdhs6YVQ-efvyQ0,21424
136
- hdl/utils/llm/visrag.py,sha256=_PuKtmQIXD5bnmXwDWhTLdzOhgC42JiqdMNb1uKA7n8,9190
137
+ hdl/utils/llm/visrag.py,sha256=ZH7Z63taj3hgGAVvDyrMIA_V0tqconCobcfYAAElYmU,9552
137
138
  hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
139
  hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
139
140
  hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
140
141
  hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
141
- hjxdl-0.2.32.dist-info/METADATA,sha256=DLlf5Bv3kIdC3Zs-a9iKvjQsCzN5e7QL_BXvVa9IywA,836
142
- hjxdl-0.2.32.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
143
- hjxdl-0.2.32.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
144
- hjxdl-0.2.32.dist-info/RECORD,,
142
+ hjxdl-0.2.33.dist-info/METADATA,sha256=3F1pmrbVHLnvogM43ps_14ScO8mF_h3I96MpJ-VoR6E,836
143
+ hjxdl-0.2.33.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
144
+ hjxdl-0.2.33.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
145
+ hjxdl-0.2.33.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5