runner: simplify parser entrypoints in runner (#12233)

This commit is contained in:
Parth Sareen
2025-09-10 11:24:42 -07:00
committed by GitHub
parent 20b53eaa72
commit 8d6fffaead
6 changed files with 173 additions and 77 deletions

View File

@@ -35,6 +35,7 @@ import (
"github.com/ollama/ollama/logutil"
"github.com/ollama/ollama/ml"
"github.com/ollama/ollama/model"
"github.com/ollama/ollama/parser"
)
type filteredEnv []string
@@ -1350,7 +1351,7 @@ type CompletionRequest struct {
Options *api.Options
Grammar string // set before sending the request to the subprocess
UseHarmony bool
ParserType parser.TokenParserType
PrefillString string
}
@@ -1364,8 +1365,6 @@ const (
DoneReasonLength
// DoneReasonConnectionClosed indicates the completion stopped due to the connection being closed
DoneReasonConnectionClosed
// DoneReasonTokenRepeatLimit indicates the completion stopped due to a token repeat limit
DoneReasonTokenRepeatLimit
)
func (d DoneReason) String() string {
@@ -1374,8 +1373,6 @@ func (d DoneReason) String() string {
return "length"
case DoneReasonStop:
return "stop"
case DoneReasonTokenRepeatLimit:
return "token_repeat_limit"
default:
return "" // closed
}