Files
wehub-resource-sync e768098d0e
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:52 +08:00

21 lines
902 B
Python

from promptflow.core import tool
from typing import List
from promptflow.core import log_metric
# The inputs section will change based on the arguments of the tool function, after you save the code
# Adding type to arguments and return value will help the system show the types properly
# Please update the function name/signature per need
@tool
def log_metrics(match_counts: List[dict]):
exact_match_rate = sum([m["exact_match"] for m in match_counts]) / len(match_counts)
partial_match_rate = sum([m["partial_match"] for m in match_counts]) / len(match_counts)
log_metric(key="exact_match_rate", value=exact_match_rate)
log_metric(key="partial_match_rate", value=partial_match_rate)
print("exact_match_rate: ", exact_match_rate)
print("partial_match_rate: ", partial_match_rate)
return {"exact_match_rate": exact_match_rate, "partial_match_rate": partial_match_rate}