e768098d0e
Flake8 Lint / flake8 (push) Waiting to run
Spell check CI / Spell_Check (push) Waiting to run
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
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from promptflow.core import tool
|
|
|
|
|
|
# Validate the metric's inputs.
|
|
def is_valid(metric):
|
|
return True
|
|
|
|
|
|
@tool
|
|
def validate_input(chat_history: list, selected_metrics: dict) -> dict:
|
|
dict_metric_required_fields = {"answer_relevance": set(["question", "answer"]),
|
|
"conversation_quality": set(["question", "answer"]),
|
|
"creativity": set(["question", "answer"]),
|
|
"grounding": set(["answer", "context"])}
|
|
actual_input_cols = set()
|
|
for item in chat_history:
|
|
actual_input_cols.update(set(item["inputs"].keys()))
|
|
actual_input_cols.update(set(item["outputs"].keys()))
|
|
break
|
|
|
|
data_validation = selected_metrics
|
|
for metric in selected_metrics:
|
|
if selected_metrics[metric]:
|
|
metric_required_fields = dict_metric_required_fields[metric]
|
|
if metric_required_fields <= actual_input_cols:
|
|
data_validation[metric] = True
|
|
else:
|
|
print("this path")
|
|
data_validation[metric] = False
|
|
return data_validation
|