hjxdl 0.2.97__py3-none-any.whl → 0.2.99__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 +2 -2
- hdl/utils/desc/func_desc.py +15 -0
- hdl/utils/llm/chat.py +63 -15
- hdl/utils/llm/vis.py +1 -1
- {hjxdl-0.2.97.dist-info → hjxdl-0.2.99.dist-info}/METADATA +1 -1
- {hjxdl-0.2.97.dist-info → hjxdl-0.2.99.dist-info}/RECORD +8 -8
- {hjxdl-0.2.97.dist-info → hjxdl-0.2.99.dist-info}/WHEEL +0 -0
- {hjxdl-0.2.97.dist-info → hjxdl-0.2.99.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
hdl/utils/desc/func_desc.py
CHANGED
@@ -109,6 +109,21 @@ TOOL_DESC = {
|
|
109
109
|
"""
|
110
110
|
},
|
111
111
|
|
112
|
+
"object_detect": {
|
113
|
+
"desc": """
|
114
|
+
## 函数名:object_detect
|
115
|
+
描述:当用户要求识别图片中的目标位置时,调用此工具,给出具体位置信息。
|
116
|
+
参数 :
|
117
|
+
- image (str): 图片的路径或 url
|
118
|
+
返回值 (str): 图片中目标的位置信息(也可能含有带有标记的渲染图片路径)
|
119
|
+
""",
|
120
|
+
"md": """
|
121
|
+
需要返回的 markdown:
|
122
|
+
- function_name: object_detect
|
123
|
+
- image: <image_path>
|
124
|
+
"""
|
125
|
+
},
|
126
|
+
|
112
127
|
"default": None
|
113
128
|
|
114
129
|
}
|
hdl/utils/llm/chat.py
CHANGED
@@ -450,12 +450,12 @@ class OpenAI_M():
|
|
450
450
|
str: The agent response based on the prompt.
|
451
451
|
'''
|
452
452
|
"""
|
453
|
-
|
454
|
-
decision_dict = parse_fn_markdown(
|
453
|
+
decision_dict_str = self.get_decision(prompt, **kwargs)
|
454
|
+
decision_dict = parse_fn_markdown(decision_dict_str)
|
455
455
|
if decision_dict.get("function_name", None) is None:
|
456
456
|
return self.chat(prompt=prompt, stream=stream, **kwargs)
|
457
457
|
else:
|
458
|
-
tool_result = str(self.get_tool_result(
|
458
|
+
tool_result = str(self.get_tool_result(decision_dict_str))
|
459
459
|
prompt_final = "根据上下文回答最后的用户问题:\n上下文信息:\n"
|
460
460
|
prompt_final += tool_result
|
461
461
|
# prompt_final += f"\n用户的问题:\n{prompt}"
|
@@ -502,7 +502,7 @@ class OpenAI_M():
|
|
502
502
|
|
503
503
|
def get_tool_result(
|
504
504
|
self,
|
505
|
-
|
505
|
+
decision_dict_str: str,
|
506
506
|
):
|
507
507
|
"""Get the result of a tool based on the decision made.
|
508
508
|
|
@@ -513,16 +513,7 @@ class OpenAI_M():
|
|
513
513
|
Returns:
|
514
514
|
str: The result of the tool.
|
515
515
|
"""
|
516
|
-
|
517
|
-
# prompt,
|
518
|
-
# **kwargs
|
519
|
-
# )
|
520
|
-
# try:
|
521
|
-
# decision_dict = parse_fn_markdown(decision_dict_str)
|
522
|
-
# # decision_dict = json.loads(decision_dict_str)
|
523
|
-
# except Exception as e:
|
524
|
-
# print(e)
|
525
|
-
# return ""
|
516
|
+
decision_dict = parse_fn_markdown(decision_dict_str)
|
526
517
|
func_name = decision_dict.get("function_name", None)
|
527
518
|
if func_name is None:
|
528
519
|
return ""
|
@@ -532,6 +523,8 @@ class OpenAI_M():
|
|
532
523
|
if tool.__name__ == func_name:
|
533
524
|
tool_final = tool
|
534
525
|
func_kwargs = decision_dict.get("params")
|
526
|
+
if tool_final.__name__ == "object_detect":
|
527
|
+
func_kwargs["llm"] = self
|
535
528
|
return tool_final(**func_kwargs)
|
536
529
|
except Exception as e:
|
537
530
|
print(e)
|
@@ -695,4 +688,59 @@ class MMChatter():
|
|
695
688
|
else:
|
696
689
|
response = output.strip()
|
697
690
|
|
698
|
-
return response
|
691
|
+
return response
|
692
|
+
|
693
|
+
|
694
|
+
def object_detect(
|
695
|
+
image,
|
696
|
+
prompt: str = OD_TEMPLATE,
|
697
|
+
llm = None,
|
698
|
+
cli_dir: str = None,
|
699
|
+
model_dir: str = None,
|
700
|
+
mmproj_dir: str = None,
|
701
|
+
save_dir: str = None,
|
702
|
+
):
|
703
|
+
resp = ""
|
704
|
+
cli_dir = cli_dir if cli_dir is not None else os.getenv(
|
705
|
+
"MM_CLI_DIR",
|
706
|
+
None
|
707
|
+
)
|
708
|
+
if model_dir is None:
|
709
|
+
model_dir = os.getenv(
|
710
|
+
"MM_MODEL_DIR",
|
711
|
+
"/home/jhu/dev/models/MiniCPM-V-2_6-gguf/ggml-model-Q4_K_M.gguf"
|
712
|
+
)
|
713
|
+
if mmproj_dir is None:
|
714
|
+
mmproj_dir = os.getenv(
|
715
|
+
"MM_PROJ_DIR",
|
716
|
+
"/home/jhu/dev/models/MiniCPM-V-2_6-gguf/mmproj-model-f16.gguf"
|
717
|
+
)
|
718
|
+
if llm is None and cli_dir is None:
|
719
|
+
raise ValueError("Either 'llm' or 'cli_dir' must be provided.")
|
720
|
+
# mm_server = os.getenv("LLM_SERVER", "192.168.1.232")
|
721
|
+
# mm_port = int(os.getevn("LLM_PORT", 22299))
|
722
|
+
|
723
|
+
if cli_dir:
|
724
|
+
mm = MMChatter(
|
725
|
+
cli_dir=cli_dir,
|
726
|
+
model_dir=model_dir,
|
727
|
+
mmproj_dir=mmproj_dir
|
728
|
+
)
|
729
|
+
json_data = mm.get_resp(
|
730
|
+
prompt=prompt,
|
731
|
+
image=image
|
732
|
+
)
|
733
|
+
else:
|
734
|
+
json_data = llm.od(image)
|
735
|
+
_, save_dir = draw_and_plot_boxes_from_json(
|
736
|
+
json_data=json_data,
|
737
|
+
image=image,
|
738
|
+
save_path=save_dir
|
739
|
+
)
|
740
|
+
resp += "Detected objects are:\n"
|
741
|
+
resp += json_data
|
742
|
+
resp =+ "\n"
|
743
|
+
if save_dir:
|
744
|
+
resp += "Picture with marks were saved at:\n"
|
745
|
+
resp += save_dir
|
746
|
+
return resp
|
hdl/utils/llm/vis.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=eh_O0mMXOD0hXwM9sRjgMdeWbi6snGlGab0dp1qqp9g,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,24 +122,24 @@ 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=awJ8lafL-2KRjf3V1uuij8JIvX9U5fI8fLZKOkOvqtk,5771
|
124
124
|
hdl/utils/desc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
125
|
-
hdl/utils/desc/func_desc.py,sha256=
|
125
|
+
hdl/utils/desc/func_desc.py,sha256=sHmVZZmV7Zgii--gnHqMs6fTb7HVkqTOf8Pl_0F6qlI,3808
|
126
126
|
hdl/utils/desc/template.py,sha256=Kf_tbL-XkDCKNQ3UncbCuYEeUgXEa7kRVCf9TD2b8og,2526
|
127
127
|
hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
128
128
|
hdl/utils/general/glob.py,sha256=Zuf7WHU0UdUPOs9UrhxmrCiMC8GrHxQU6n3mTThv6yc,1120
|
129
129
|
hdl/utils/general/runners.py,sha256=x7QBolp3MrqNV6L4rB6Ueybr26bqkRFZTuXhY0SwyLk,3061
|
130
130
|
hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
131
|
-
hdl/utils/llm/chat.py,sha256=
|
131
|
+
hdl/utils/llm/chat.py,sha256=0MXmw9FP10uR_NRJrSUhcrK88zE9oIdgGRbZp5l4N74,26263
|
132
132
|
hdl/utils/llm/chatgr.py,sha256=5F5PJHe8vz3iCfi4TT54DCLRi1UeJshECdVtgvvvao0,3696
|
133
133
|
hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
|
134
134
|
hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
|
135
135
|
hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
|
136
|
-
hdl/utils/llm/vis.py,sha256=
|
136
|
+
hdl/utils/llm/vis.py,sha256=SSP6tOwKLq0hWcpM3twI9TitqzBmKjlcGrnXEWYlCzM,26055
|
137
137
|
hdl/utils/llm/visrag.py,sha256=0i-VrxqgiV-J7R3VPshu9oc7-rKjFJOldYik3HDXj6M,10176
|
138
138
|
hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
139
139
|
hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
|
140
140
|
hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
141
141
|
hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
|
142
|
-
hjxdl-0.2.
|
143
|
-
hjxdl-0.2.
|
144
|
-
hjxdl-0.2.
|
145
|
-
hjxdl-0.2.
|
142
|
+
hjxdl-0.2.99.dist-info/METADATA,sha256=pEj-TvHeI8XvXpXfCVACTTk5bNd-hj4116dIYje6zCI,862
|
143
|
+
hjxdl-0.2.99.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
144
|
+
hjxdl-0.2.99.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
145
|
+
hjxdl-0.2.99.dist-info/RECORD,,
|
File without changes
|
File without changes
|