Skip to content

Instantly share code, notes, and snippets.

View PaulLockett's full-sized avatar

Paul Lockett PaulLockett

  • San Jose, CA
  • 06:25 (UTC -07:00)
View GitHub Profile
@PaulLockett
PaulLockett / JsonExtractMetric.py
Created March 1, 2024 02:46
DSPy Json extraction metric
import json
import dspy
class AssessJsonExtractSig(dspy.Signature):
trial_json = dspy.InputField(desc="The trial extraxted JSON")
ideal_json = dspy.InputField(desc="The ideal extraxted JSON")
input_str = dspy.InputField(desc="The str to extract the JSON from")
closeness = dspy.OutputField(desc="a float between 0.0 and 1.0; how closely is the trial_json is the same as the ideal_json")
class AssessJsonExtract(dspy.Module):