chore: import upstream snapshot with attribution
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
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
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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
|
||||
Reference in New Issue
Block a user