87 lines
2.2 KiB
Go
87 lines
2.2 KiB
Go
package spells
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/sharedassets/dnd"
|
|
)
|
|
|
|
func promptExtractionRequest() contracts.ExtractionRequest {
|
|
doc := promptSourceDocument()
|
|
chunk := &contracts.SourceChunk{
|
|
ID: "session-alpha:chunk:0",
|
|
SourceID: doc.ID,
|
|
Index: 0,
|
|
StartUnitID: doc.Units[0].ID,
|
|
EndUnitID: doc.Units[len(doc.Units)-1].ID,
|
|
Content: []byte(`{"units":[1,2]}`),
|
|
MediaType: "application/json",
|
|
Units: append([]source.SourceUnit(nil), doc.Units...),
|
|
Metadata: map[string]any{"ignored": "chunk metadata"},
|
|
}
|
|
return contracts.ExtractionRequest{
|
|
Source: doc,
|
|
Chunk: chunk,
|
|
}
|
|
}
|
|
|
|
func promptSourceDocument() *source.SourceDocument {
|
|
return &source.SourceDocument{
|
|
ID: "session-alpha",
|
|
Kind: "transcript",
|
|
Format: "application/vnd.seriatim.minimal+json",
|
|
Digest: "sha256:test",
|
|
Units: []source.SourceUnit{
|
|
{
|
|
ID: 1,
|
|
Kind: "transcript_segment",
|
|
Text: "Aria raises her hand and casts Cure Wounds.",
|
|
Metadata: map[string]any{
|
|
"speaker": "Alice",
|
|
"start": json.Number("1.25"),
|
|
"end": json.Number("3.5"),
|
|
"ignored": "not rendered",
|
|
},
|
|
},
|
|
{
|
|
ID: 2,
|
|
Kind: "transcript_segment",
|
|
Text: "The fighter's wounds begin to close.",
|
|
Metadata: map[string]any{"ignored": "not rendered"},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func mustJSON(t *testing.T, value any) string {
|
|
t.Helper()
|
|
encoded, err := json.Marshal(value)
|
|
if err != nil {
|
|
t.Fatalf("Marshal() error = %v, want nil", err)
|
|
}
|
|
return string(encoded)
|
|
}
|
|
|
|
func responseSourceRefs(sourceID string, startUnitID int, endUnitID int) []dnd.SourceRefResponse {
|
|
return []dnd.SourceRefResponse{
|
|
{
|
|
SourceID: sourceID,
|
|
StartUnitID: dnd.UnitRefFromInt(startUnitID),
|
|
EndUnitID: dnd.UnitRefFromInt(endUnitID),
|
|
},
|
|
}
|
|
}
|
|
|
|
func responseSourceRefsInt(sourceID string, startUnitID int, endUnitID int) []dnd.SourceRefResponse {
|
|
return []dnd.SourceRefResponse{
|
|
{
|
|
SourceID: sourceID,
|
|
StartUnitID: dnd.UnitRefFromInt(startUnitID),
|
|
EndUnitID: dnd.UnitRefFromInt(endUnitID),
|
|
},
|
|
}
|
|
}
|