Separate reconciliation preparation and proposal assessment from native execution
This commit is contained in:
@@ -1,20 +1,16 @@
|
||||
package semanticreconcile
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
const (
|
||||
candidateInputName = "candidates"
|
||||
transcriptInputName = "transcript"
|
||||
jsonMediaType = "application/json"
|
||||
)
|
||||
|
||||
var defaultLimits = Limits{
|
||||
@@ -89,7 +85,7 @@ type Preparation struct {
|
||||
disposition Disposition
|
||||
candidateNumberRange CandidateNumberRange
|
||||
mappings []CandidateMapping
|
||||
materials contracts.LLMInputSet
|
||||
materials map[string][]byte
|
||||
}
|
||||
|
||||
// Disposition returns the preparation outcome.
|
||||
@@ -110,8 +106,15 @@ func (preparation Preparation) CandidateNumberRange() CandidateNumberRange {
|
||||
|
||||
// Materials returns independently owned candidate and transcript materials.
|
||||
// It is empty unless Disposition returns Ready.
|
||||
func (preparation Preparation) Materials() contracts.LLMInputSet {
|
||||
return preparation.materials.Clone()
|
||||
func (preparation Preparation) Materials() map[string][]byte {
|
||||
if preparation.materials == nil {
|
||||
return nil
|
||||
}
|
||||
materials := make(map[string][]byte, len(preparation.materials))
|
||||
for name, content := range preparation.materials {
|
||||
materials[name] = append([]byte(nil), content...)
|
||||
}
|
||||
return materials
|
||||
}
|
||||
|
||||
type sourceRange struct {
|
||||
@@ -242,9 +245,9 @@ func Prepare(document *source.SourceDocument, candidates []Candidate, limits Lim
|
||||
}
|
||||
|
||||
result.disposition = Ready
|
||||
result.materials = contracts.LLMInputSet{
|
||||
candidateInputName: newInputMaterial(candidateInputName, candidateContent),
|
||||
transcriptInputName: newInputMaterial(transcriptInputName, transcriptContent),
|
||||
result.materials = map[string][]byte{
|
||||
candidateInputName: candidateContent,
|
||||
transcriptInputName: transcriptContent,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -412,14 +415,3 @@ func appendWithinLimit(content []byte, maximumBytes int, parts ...[]byte) ([]byt
|
||||
}
|
||||
return content, true
|
||||
}
|
||||
|
||||
func newInputMaterial(name string, content []byte) contracts.LLMInputMaterial {
|
||||
digest := sha256.Sum256(content)
|
||||
return contracts.NewLLMInputMaterial(
|
||||
name,
|
||||
jsonMediaType,
|
||||
content,
|
||||
"sha256:"+hex.EncodeToString(digest[:]),
|
||||
"",
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user