runner: add sync between computeBatch and completion

This commit is contained in:
ParthSareen
2025-09-10 18:50:01 -07:00
parent 1e5fecbbc3
commit c0aeb3531b
2 changed files with 33 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ import (
"math"
"math/rand/v2"
"slices"
"sync"
"github.com/ollama/ollama/llama"
"github.com/ollama/ollama/model"
@@ -25,7 +26,9 @@ type Sampler struct {
grammar *GrammarSampler
}
func (s *Sampler) SetGrammar(grammar *GrammarSampler) {
func (s *Sampler) SetGrammar(grammar *GrammarSampler, mutex *sync.Mutex) {
mutex.Lock()
defer mutex.Unlock()
s.grammar = grammar
}