Prepare shared context for all D&D extractors
This commit is contained in:
@@ -56,6 +56,7 @@ var _ contracts.Extractor[dnd.LocationOccurrenceList] = (*Extractor)(nil)
|
||||
type Options struct{}
|
||||
|
||||
type Extractor struct {
|
||||
context shared.PreparedContext
|
||||
locationResolver *locationregistry.Resolver
|
||||
}
|
||||
|
||||
@@ -67,11 +68,15 @@ func New(_ Options, references ...contracts.ReferenceSet) (*Extractor, error) {
|
||||
if len(references) == 1 {
|
||||
referenceSet = references[0]
|
||||
}
|
||||
context, err := shared.PrepareContext(referenceSet)
|
||||
if err != nil {
|
||||
return nil, extractorErrorf("prepare references: %w", err)
|
||||
}
|
||||
locationResolver, err := locationregistry.NewResolver(referenceSet)
|
||||
if err != nil {
|
||||
return nil, extractorErrorf("prepare location registry prompt input: %w", err)
|
||||
}
|
||||
return &Extractor{locationResolver: locationResolver}, nil
|
||||
return &Extractor{context: context, locationResolver: locationResolver}, nil
|
||||
}
|
||||
|
||||
func (e *Extractor) Key() string { return Key }
|
||||
@@ -106,7 +111,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
||||
order := shared.NewSourceRefOrderForSource(req.Source, index)
|
||||
|
||||
sourceID := req.Source.ID
|
||||
materials := shared.PromptInputs(sourceInput, req.References)
|
||||
materials := e.context.Inputs(sourceInput)
|
||||
materials[LocationRegistryReferenceSlot] = grounding.PromptInput()
|
||||
inputs := make(map[string]promptkit.ArtifactRef, len(materials))
|
||||
for name, material := range materials {
|
||||
|
||||
Reference in New Issue
Block a user