32 lines
1022 B
Python
32 lines
1022 B
Python
import dspy
|
|
|
|
|
|
def validate_signature_with_feedback(
|
|
args, pred, feedback=None, satisfied_with_score=True
|
|
):
|
|
"""Validation function for dspy.Refine that asks user for feedback"""
|
|
|
|
# Display the generated signature
|
|
print("\n" + "=" * 60)
|
|
print("🔍 Review Generated Signature")
|
|
print("=" * 60)
|
|
|
|
# Show the signature name and description
|
|
print(f"Signature Name: {pred.signature_name}")
|
|
print(f"Description: {pred.task_description}")
|
|
|
|
# Show the fields in a simple format
|
|
print(f"\nFields ({len(pred.signature_fields)}):")
|
|
for i, field in enumerate(pred.signature_fields, 1):
|
|
role_emoji = "📥" if field.role.value == "input" else "📤"
|
|
print(
|
|
f" {i}. {role_emoji} {field.name} ({field.type.value}) - {field.description}"
|
|
)
|
|
|
|
if satisfied_with_score:
|
|
print("✓ Signature approved!")
|
|
return 1.0
|
|
else:
|
|
print(f"📝 Feedback recorded: {feedback}")
|
|
return dspy.Prediction(score=0.0, feedback=feedback)
|