mirror of
https://github.com/ollama/ollama.git
synced 2025-11-12 05:27:46 +01:00
add registries for parsers/renderers
This commit is contained in:
@@ -16,7 +16,28 @@ type Parser interface {
|
||||
HasThinkingSupport() bool
|
||||
}
|
||||
|
||||
type ParserConstructor func() Parser
|
||||
|
||||
type ParserRegistry struct {
|
||||
constructors map[string]ParserConstructor
|
||||
}
|
||||
|
||||
func (r *ParserRegistry) Register(name string, constructor ParserConstructor) {
|
||||
r.constructors[name] = constructor
|
||||
}
|
||||
|
||||
var registry = ParserRegistry{
|
||||
constructors: make(map[string]ParserConstructor),
|
||||
}
|
||||
|
||||
func Register(name string, constructor ParserConstructor) {
|
||||
registry.Register(name, constructor)
|
||||
}
|
||||
|
||||
func ParserForName(name string) Parser {
|
||||
if parser, ok := registry.constructors[name]; ok {
|
||||
return parser()
|
||||
}
|
||||
switch name {
|
||||
case "qwen3-coder":
|
||||
parser := &Qwen3CoderParser{}
|
||||
|
||||
Reference in New Issue
Block a user