(no commit message)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from .modules import SignatureGenerator
|
||||
from .metrics import validate_signature_with_feedback
|
||||
|
||||
__all__ = ["SignatureGenerator"]
|
||||
__all__ = ["SignatureGenerator", "validate_signature_with_feedback"]
|
||||
|
||||
31
agent/metrics.py
Normal file
31
agent/metrics.py
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user