fix: target json type & round (#662)

* refactor: Rename direct_exp_gen to json_target_type in DSExpGen class

* fix type

* fix: Adjust loop iterations and update json_target_type for nested dicts
This commit is contained in:
you-n-g
2025-03-05 22:46:43 +08:00
committed by GitHub
parent c600468649
commit 44d1ad80c5
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -378,7 +378,7 @@ class APIBackend(ABC):
all_response = ""
new_messages = deepcopy(messages)
for _ in range(3):
for _ in range(6): # for some long code, 3 times may not enough for reasoning models
if "json_mode" in kwargs:
del kwargs["json_mode"]
response, finish_reason = self._create_chat_completion_add_json_in_prompt(
@@ -420,7 +420,10 @@ class DSExpGen(ExpGen):
user_prompt=user_prompt,
system_prompt=system_prompt,
json_mode=True,
json_target_type=dict[str, dict[str, str] | str], # workflow_update may be a string
# NOTE: corner cases.
# workflow_update may be a string
# model could have 2 level nested dict.
json_target_type=dict[str, dict[str, str | dict] | str],
)
)
assert "hypothesis_proposal" in resp_dict, "Hypothesis proposal not provided."