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

修复V2版本TableOCR组件BUG #712

Merged
merged 6 commits into from
Jan 9, 2025
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
8 changes: 6 additions & 2 deletions python/core/components/v2/table_ocr/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import base64
import json

from typing import Optional

from appbuilder.core import utils
from appbuilder.core.component import Component
from appbuilder.core.components.table_ocr.model import *
Expand Down Expand Up @@ -189,7 +191,7 @@ def get_table_markdown(self, tables_result):

@components_run_stream_trace
def tool_eval(self,
file_names: List[str],
file_names: Optional[List[str]] = [],
**kwargs):
"""
处理并评估传入的文件列表,并返回表格数据的Markdown格式表示。
Expand All @@ -206,8 +208,10 @@ def tool_eval(self,

"""
result = {}
traceid = kwargs.get("_sys_traceid")
traceid = kwargs.get("_sys_traceid", "")
file_urls = kwargs.get("_sys_file_urls", {})
if not file_names:
file_names = kwargs.get("_sys_file_names", [])
for file_name in file_names:
if utils.is_url(file_name):
file_url = file_name
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_dialog_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def test_run_with_model_names(self):
"""测试不同的 stream 和 temperature 参数值"""

chats = appbuilder.get_model_list(api_type_filter=["chat"])
self.assertTrue("EB-turbo-AppBuilder专用版" in chats)
self.assertTrue("ERNIE-3.5-8K" in chats)

appbuilder.DialogSummary(model="EB-turbo-AppBuilder专用版")
appbuilder.DialogSummary(model="ERNIE-3.5-8K")

with self.assertRaises(Exception):
appbuilder.DialogSummary(model="")
Expand Down
11 changes: 10 additions & 1 deletion python/tests/test_v2_table_ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ def test_run(self):
print(out)


def test_tool_eval(self):
def test_tool_eval_01(self):
result = self.com.tool_eval([self.image_url])
for res in result:
assert isinstance(res, ComponentOutput)
print(res.role, res.content)

def test_tool_eval_02(self):
_sys_file_urls = {
"test-name": self.image_url
}
result = self.com.tool_eval(_sys_file_names = ["test-name"], _sys_file_urls = _sys_file_urls)
for res in result:
assert isinstance(res, ComponentOutput)
print(res.role, res.content)

if __name__ == '__main__':
unittest.main()
Loading