Complete source index reuse across extractors
This commit is contained in:
@@ -72,7 +72,11 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
||||
}
|
||||
|
||||
chunk := source.Chunk{ID: req.Chunk.ID, Ref: req.Chunk.Ref}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := req.SourceIndex
|
||||
if index == nil {
|
||||
local := source.NewDocumentIndex(req.Source)
|
||||
index = &local
|
||||
}
|
||||
reuse := func(value dnd.SceneDescriptionList) (dnd.SceneDescriptionList, error) {
|
||||
if len(value.Scenes) != 1 || value.Scenes[0].SourceRef != chunk.Ref {
|
||||
return dnd.SceneDescriptionList{}, fmt.Errorf("cached scene does not describe the current chunk range")
|
||||
@@ -80,7 +84,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
||||
// Chunk ordinals can change without changing the semantic prompt.
|
||||
value.Scenes = append([]dnd.SceneDescription(nil), value.Scenes...)
|
||||
value.Scenes[0].ID = chunk.ID
|
||||
return sceneFallback(&value, chunk, index)
|
||||
return sceneFallback(&value, chunk, *index)
|
||||
}
|
||||
materials := shared.PromptInputs(sourceInput, req.References)
|
||||
inputs := make(map[string]promptkit.ArtifactRef, len(materials))
|
||||
@@ -103,7 +107,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
||||
if evaluation != nil {
|
||||
final = evaluation.View().Candidate
|
||||
}
|
||||
return sceneFallback(final, chunk, index)
|
||||
return sceneFallback(final, chunk, *index)
|
||||
}}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user