Simplify contextual entity grounding
This commit is contained in:
@@ -36,7 +36,6 @@ type ContextUnit struct {
|
||||
// Its prompt input contains no durable IDs or source IDs.
|
||||
type Grounding struct {
|
||||
promptInput contracts.LLMInputMaterial
|
||||
projectionDigest string
|
||||
locationsBySelector map[string]dnd.Location
|
||||
}
|
||||
|
||||
@@ -104,7 +103,6 @@ func NewGrounding(registry *Registry, doc *source.SourceDocument) (*Grounding, e
|
||||
digest := semanticDigest(content)
|
||||
return &Grounding{
|
||||
promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, locationcodec.MediaType, content, digest, ""),
|
||||
projectionDigest: digest,
|
||||
locationsBySelector: locationsBySelector,
|
||||
}, nil
|
||||
}
|
||||
@@ -118,14 +116,6 @@ func (g *Grounding) PromptInput() contracts.LLMInputMaterial {
|
||||
return g.promptInput.Clone()
|
||||
}
|
||||
|
||||
// ProjectionDigest returns the digest of the exact contextual prompt input.
|
||||
func (g *Grounding) ProjectionDigest() string {
|
||||
if g == nil {
|
||||
return ""
|
||||
}
|
||||
return g.projectionDigest
|
||||
}
|
||||
|
||||
// Resolve maps a contextual selector to one canonical location.
|
||||
func (g *Grounding) Resolve(selector Selector) (dnd.Location, bool) {
|
||||
if g == nil {
|
||||
|
||||
@@ -216,8 +216,8 @@ func TestGroundingProjectsAndResolvesUniqueAndSameNameLocations(t *testing.T) {
|
||||
if bytes.Contains(grounding.PromptInput().Content, []byte("location:sha256:")) || bytes.Contains(grounding.PromptInput().Content, []byte(`"source_id"`)) {
|
||||
t.Fatalf("grounding projection exposed durable identity: %s", grounding.PromptInput().Content)
|
||||
}
|
||||
if grounding.ProjectionDigest() == "" || grounding.ProjectionDigest() == registry.IdentityDigest() || grounding.PromptInput().Digest != grounding.ProjectionDigest() {
|
||||
t.Fatalf("grounding/identity digests = %q/%q", grounding.ProjectionDigest(), registry.IdentityDigest())
|
||||
if grounding.PromptInput().Digest == "" || grounding.PromptInput().Digest == registry.IdentityDigest() {
|
||||
t.Fatalf("grounding/identity digests = %q/%q", grounding.PromptInput().Digest, registry.IdentityDigest())
|
||||
}
|
||||
|
||||
resolved, ok := grounding.Resolve(Selector{Name: " the tavern ", RegistryRefs: []RegistryRef{{StartUnitID: 30, EndUnitID: 30}, {StartUnitID: 20, EndUnitID: 20}}})
|
||||
@@ -276,8 +276,8 @@ func TestGroundingHandlesEmptyRegistriesAndIdentityFingerprints(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if base.IdentityDigest() != expanded.IdentityDigest() || baseGrounding.ProjectionDigest() != expandedGrounding.ProjectionDigest() {
|
||||
t.Fatalf("identity/model fingerprints = %q/%q and %q/%q", base.IdentityDigest(), expanded.IdentityDigest(), baseGrounding.ProjectionDigest(), expandedGrounding.ProjectionDigest())
|
||||
if base.IdentityDigest() != expanded.IdentityDigest() || baseGrounding.PromptInput().Digest != expandedGrounding.PromptInput().Digest {
|
||||
t.Fatalf("identity/model fingerprints = %q/%q and %q/%q", base.IdentityDigest(), expanded.IdentityDigest(), baseGrounding.PromptInput().Digest, expandedGrounding.PromptInput().Digest)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user