Skip to content

Commit

Permalink
added simple parsing to parameter and value parsing for unify.update.
Browse files Browse the repository at this point in the history
  • Loading branch information
djl11 committed Oct 31, 2024
1 parent 4954a3b commit 032375d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions unify/evals/assist/system_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def {name}({arg1}: {type1}, {arg2}: {type2} = {default2}, ...):
At the very end of your response, please respond as follows, filling in the placeholders
{parameter_name} and {parameter_value}:
"parameter":
parameter:
"{parameter_name}"
"value":
value:
{parameter_value}
"""
19 changes: 16 additions & 3 deletions unify/evals/assist/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _print_table_from_dicts(dcts, col_list=None) -> str:
return "\n".join(ret)


def _format_evals(evals: Dict[str, List[Dict[str, Any]]]) -> str:
def _format_evals(evals: Dict[str, List[unify.Log]]) -> str:
ret = list()
for config_str, logs in evals.items():
ret.append(
Expand All @@ -37,7 +37,7 @@ def _format_evals(evals: Dict[str, List[Dict[str, Any]]]) -> str:
"\n" "Logs:\n" "-----\n",
)
ret.append(
json.dumps(logs, indent=4),
json.dumps([lg.to_json() for lg in logs], indent=4),
)
return "\n".join(ret)

Expand Down Expand Up @@ -102,4 +102,17 @@ def update(
"please follow the instructions of the system message",
system_message=system_message,
)
return response
parameter = response.split("\nparameter:\n")[-1].split("\nvalue:\n")[0].strip("\n")
value = (
response.split(
"\nvalue:\n",
)[-1]
.lstrip("```python")
.lstrip("```")
.rstrip("```")
.lstrip(
"\n",
)
.rstrip("\n")
)
return parameter, value

0 comments on commit 032375d

Please sign in to comment.