Prepare shared context for all D&D extractors
This commit is contained in:
@@ -33,6 +33,7 @@ var _ contracts.Extractor[dnd.EnemyEventList] = (*Extractor)(nil)
|
||||
type Options struct{}
|
||||
|
||||
type Extractor struct {
|
||||
context shared.PreparedContext
|
||||
grounding *groundingResolver
|
||||
}
|
||||
|
||||
@@ -44,11 +45,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)
|
||||
}
|
||||
grounding, err := newGroundingResolver(referenceSet)
|
||||
if err != nil {
|
||||
return nil, extractorErrorf("prepare grounding: %w", err)
|
||||
}
|
||||
return &Extractor{grounding: grounding}, nil
|
||||
return &Extractor{context: context, grounding: grounding}, nil
|
||||
}
|
||||
|
||||
func (e *Extractor) Key() string { return Key }
|
||||
@@ -87,7 +92,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
||||
|
||||
order := shared.NewSourceRefOrderForSource(req.Source, req.SourceIndex)
|
||||
sourceID := req.Source.ID
|
||||
materials := shared.PromptInputs(sourceInput, req.References)
|
||||
materials := e.context.Inputs(sourceInput)
|
||||
for name, material := range grounding.PromptInputs() {
|
||||
materials[name] = material
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user