Migrate spell extraction to native execution and semantic continuation
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
// PrepareChunkExtraction validates common D&D extraction prerequisites and
|
||||
// prepares owned chunk-scoped source material for prompt inputs.
|
||||
func PrepareChunkExtraction(ctx context.Context, req contracts.TypedExtractionRequest) (contracts.LLMInputMaterial, error) {
|
||||
func PrepareChunkExtraction[T any](ctx context.Context, req contracts.TypedExtractionRequest[T]) (contracts.LLMInputMaterial, error) {
|
||||
if ctx == nil {
|
||||
return contracts.LLMInputMaterial{}, fmt.Errorf("context must not be nil")
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestPrepareChunkExtraction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
ctx context.Context
|
||||
configure func(*contracts.TypedExtractionRequest)
|
||||
configure func(*contracts.TypedExtractionRequest[any])
|
||||
sourceInput contracts.LLMInputMaterial
|
||||
want contracts.LLMInputMaterial
|
||||
wantErr string
|
||||
@@ -33,21 +33,21 @@ func TestPrepareChunkExtraction(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "nil source",
|
||||
configure: func(req *contracts.TypedExtractionRequest) {
|
||||
configure: func(req *contracts.TypedExtractionRequest[any]) {
|
||||
req.Source = nil
|
||||
},
|
||||
wantErr: "source must not be nil",
|
||||
},
|
||||
{
|
||||
name: "nil chunk",
|
||||
configure: func(req *contracts.TypedExtractionRequest) {
|
||||
configure: func(req *contracts.TypedExtractionRequest[any]) {
|
||||
req.Chunk = nil
|
||||
},
|
||||
wantErr: "chunk must not be nil",
|
||||
},
|
||||
{
|
||||
name: "empty chunk units",
|
||||
configure: func(req *contracts.TypedExtractionRequest) {
|
||||
configure: func(req *contracts.TypedExtractionRequest[any]) {
|
||||
req.Chunk = &source.Chunk{ID: req.Chunk.ID}
|
||||
},
|
||||
wantErr: "units must not be empty",
|
||||
@@ -139,7 +139,7 @@ func TestPrepareChunkExtraction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func extractionRequest() contracts.TypedExtractionRequest {
|
||||
func extractionRequest() contracts.TypedExtractionRequest[any] {
|
||||
doc := &source.SourceDocument{ID: "session-alpha"}
|
||||
chunk := &source.Chunk{
|
||||
ID: "session-alpha:chunk:0",
|
||||
@@ -148,5 +148,5 @@ func extractionRequest() contracts.TypedExtractionRequest {
|
||||
MediaType: "application/json",
|
||||
Units: []source.SourceUnit{{ID: 1}},
|
||||
}
|
||||
return contracts.TypedExtractionRequest{Source: doc, Chunk: chunk}
|
||||
return contracts.TypedExtractionRequest[any]{Source: doc, Chunk: chunk}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user