runner/parser: allow on-the-fly grammar constraining

This commit is contained in:
ParthSareen
2025-09-10 11:50:12 -07:00
parent 8d6fffaead
commit 1e5fecbbc3
4 changed files with 40 additions and 9 deletions

View File

@@ -25,6 +25,10 @@ type Sampler struct {
grammar *GrammarSampler
}
func (s *Sampler) SetGrammar(grammar *GrammarSampler) {
s.grammar = grammar
}
func (s *Sampler) Sample(logits []float32) (int32, error) {
if len(logits) == 0 {
return -1, errors.New("sample: no logits provided to sample")