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

json_to_pydantic replace(unique_items, Set) and BugFix #655

Merged
merged 9 commits into from
Dec 11, 2024
11 changes: 8 additions & 3 deletions python/tests/component_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def check(self, component_cls) -> CheckInfo:
invalid_details.append("{} 没有添加测试case到 component_tool_eval_cases 中".format(component_cls_name))
else:
component_case = self.component_tool_eval_cases[component_cls_name]()
envs = component_case.envs()
os.environ.update(envs)
init_args = component_case.init_args()

try:
Expand Down Expand Up @@ -105,7 +107,10 @@ def check(self, component_cls) -> CheckInfo:
print(e)
check_pass_flag = False
invalid_details.append(str(e))


for env in envs:
os.environ.pop(env)

if len(invalid_details) > 0:
check_pass_flag = False
invalid_details = ",".join(invalid_details)
Expand Down Expand Up @@ -292,9 +297,9 @@ def _gather_iter_outputs(self, outputs):
if out_type == "text":
text_output += content.text.info
elif out_type == "oral_text":
oral_text_output += content.oral_text.info
oral_text_output += content.text.info
elif out_type == "code":
code_output += content.code.code
code_output += content.text.code
return {
"text": text_output,
"oral_text": oral_text_output,
Expand Down
11 changes: 10 additions & 1 deletion python/utils/json_schema_to_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def json_schema_to_pydantic_model(json_schema: dict, name_override: str) -> Base

class_title = json_schema["title"]
pydantic_models_as_str = sed_pydantic_str(pydantic_models_as_str, class_title)

pydantic_models_as_str = pydantic_models_as_str.replace("unique_items", "Set")

with NamedTemporaryFile(suffix=".py", delete=False) as temp_file:
temp_file_path = Path(temp_file.name).resolve()
temp_file.write(pydantic_models_as_str.encode())
Expand Down Expand Up @@ -119,6 +120,14 @@ def json_schema_to_pydantic_model(json_schema: dict, name_override: str) -> Base
"type": "string",
"description": "待识别图片的文件名,用于生成图片url"
},
"files": {
"type": "array",
"items": {
"type": "string",
},
"uniqueItems": True
}

},
"anyOf": [
{
Expand Down
Loading