Carry accepted chunk maps through the runner
This commit is contained in:
@@ -69,6 +69,16 @@ func CloneSerializedArtifact(artifact SerializedArtifact) SerializedArtifact {
|
||||
return artifact
|
||||
}
|
||||
|
||||
// CloneSerializedArtifactPointer returns an independently owned artifact when
|
||||
// one is present.
|
||||
func CloneSerializedArtifactPointer(artifact *SerializedArtifact) *SerializedArtifact {
|
||||
if artifact == nil {
|
||||
return nil
|
||||
}
|
||||
cloned := CloneSerializedArtifact(*artifact)
|
||||
return &cloned
|
||||
}
|
||||
|
||||
func CloneSerializedOutput(output SerializedOutput) SerializedOutput {
|
||||
output.Artifact = CloneSerializedArtifact(output.Artifact)
|
||||
return output
|
||||
|
||||
@@ -291,6 +291,7 @@ type OutputRequest struct {
|
||||
Warnings []Warning `json:"warnings,omitempty"`
|
||||
LLMProfile string `json:"llm_profile,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
ChunkMap *SerializedArtifact `json:"chunk_map,omitempty"`
|
||||
}
|
||||
|
||||
type OutputFile struct {
|
||||
|
||||
@@ -26,6 +26,25 @@ func TestCloneReferenceSlotsEmptyInputReturnsNil(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloneSerializedArtifactPointerOwnsArtifactData(t *testing.T) {
|
||||
original := &SerializedArtifact{
|
||||
Kind: "test/artifact",
|
||||
Schema: ArtifactSchema{ID: "test.schema", JSONSchema: []byte(`{"type":"object"}`)},
|
||||
Content: []byte(`{"items":[]}`),
|
||||
Metadata: map[string]any{"count": 1},
|
||||
}
|
||||
cloned := CloneSerializedArtifactPointer(original)
|
||||
original.Schema.JSONSchema[0] = '['
|
||||
original.Content[0] = '['
|
||||
original.Metadata["count"] = 2
|
||||
if cloned == nil || string(cloned.Schema.JSONSchema) != `{"type":"object"}` || string(cloned.Content) != `{"items":[]}` || cloned.Metadata["count"] != 1 {
|
||||
t.Fatalf("CloneSerializedArtifactPointer() = %#v, want independent artifact data", cloned)
|
||||
}
|
||||
if CloneSerializedArtifactPointer(nil) != nil {
|
||||
t.Fatal("CloneSerializedArtifactPointer(nil) must return nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloneReferenceSlotsPreservesFields(t *testing.T) {
|
||||
slots := []ReferenceSlot{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user