Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

动植物识别、图片内容理解修改返回结果 #199

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions appbuilder/core/components/animal_recognize/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from appbuilder.core._exception import AppBuilderServerException
from typing import Generator, Union

TOP_NUM = 1
BAIKE_NUM = 0


class AnimalRecognition(Component):
r"""
Expand Down Expand Up @@ -169,8 +172,8 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls) -> str:
if img_url in file_urls:
img_url = file_urls['img_url']
req.url = img_url
req.top_num = 6
req.baike_num = 0
req.top_num = TOP_NUM
req.baike_num = BAIKE_NUM
result = self._recognize(req)
result_dict = proto.Message.to_dict(result)
rec_res = "模型识别结果为:\n"
Expand Down
11 changes: 10 additions & 1 deletion appbuilder/core/components/image_understand/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@ def tool_eval(self, name: str, streaming: bool,
file_urls = kwargs.get("file_urls", {})
rec_res = self._recognize_w_post_process(img_path, img_url, file_urls)
if streaming:
yield rec_res
yield {
"type": "text",
"text": rec_res,
"visible_scope": 'llm',
}
yield {
"type": "text",
"text": "",
"visible_scope": 'user',
}
else:
return rec_res

Expand Down
7 changes: 5 additions & 2 deletions appbuilder/core/components/plant_recognize/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
from appbuilder.core.components.plant_recognize.model import *
from typing import Generator, Union

TOP_NUM = 1
BAIKE_NUM = 0


class PlantRecognition(Component):
r"""
Expand Down Expand Up @@ -174,8 +177,8 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls):
if img_url in file_urls:
img_url = file_urls['img_url']
req.url = img_url
req.top_num = 6
req.baike_num = 0
req.top_num = TOP_NUM
req.baike_num = BAIKE_NUM
result = self.__recognize(req)
result_dict = proto.Message.to_dict(result)
rec_res = "模型识别结果为:\n"
Expand Down
Loading