Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
472feec2
Commit
472feec2
authored
Sep 15, 2025
by
Devon Rifkin
Browse files
address comments
parent
47991940
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
17 deletions
+17
-17
model/parsers/parsers.go
model/parsers/parsers.go
+2
-2
model/parsers/qwen3coder_test.go
model/parsers/qwen3coder_test.go
+11
-11
model/renderers/qwen3coder.go
model/renderers/qwen3coder.go
+3
-3
server/routes.go
server/routes.go
+1
-1
No files found.
model/parsers/parsers.go
View file @
472feec2
...
...
@@ -4,13 +4,13 @@ import (
"github.com/ollama/ollama/api"
)
type
Builtin
Parser
interface
{
type
Parser
interface
{
Add
(
s
string
,
tools
[]
api
.
Tool
)
(
content
string
,
thinking
string
,
calls
[]
api
.
ToolCall
,
err
error
)
HasToolSupport
()
bool
HasThinkingSupport
()
bool
}
func
ParserForName
(
name
string
)
Builtin
Parser
{
func
ParserForName
(
name
string
)
Parser
{
switch
name
{
case
"qwen3-coder"
:
parser
:=
&
Qwen3CoderParser
{}
...
...
model/parsers/qwen3coder_test.go
View file @
472feec2
...
...
@@ -307,7 +307,7 @@ true
"x"
:
3.14
,
"y"
:
42
,
"enabled"
:
true
,
"items"
:
[]
interface
{}
{
"a"
,
"b"
,
"c"
},
"items"
:
[]
any
{
"a"
,
"b"
,
"c"
},
},
},
},
...
...
@@ -510,44 +510,44 @@ func TestQwenToolCallValueParsing(t *testing.T) {
desc
:
"array of strings"
,
paramType
:
api
.
PropertyType
{
"array"
},
raw
:
`["foo", "bar", "baz"]`
,
want
:
[]
interface
{}
{
"foo"
,
"bar"
,
"baz"
},
want
:
[]
any
{
"foo"
,
"bar"
,
"baz"
},
},
{
desc
:
"array of numbers"
,
paramType
:
api
.
PropertyType
{
"array"
},
raw
:
`[1, 2.5, 3]`
,
want
:
[]
interface
{}
{
float64
(
1
),
2.5
,
float64
(
3
)},
want
:
[]
any
{
float64
(
1
),
2.5
,
float64
(
3
)},
},
{
desc
:
"array of mixed types"
,
paramType
:
api
.
PropertyType
{
"array"
},
raw
:
`["string", 123, true, null]`
,
want
:
[]
interface
{}
{
"string"
,
float64
(
123
),
true
,
nil
},
want
:
[]
any
{
"string"
,
float64
(
123
),
true
,
nil
},
},
{
desc
:
"empty array"
,
paramType
:
api
.
PropertyType
{
"array"
},
raw
:
`[]`
,
want
:
[]
interface
{}
{},
want
:
[]
any
{},
},
// Object parsing tests
{
desc
:
"simple object"
,
paramType
:
api
.
PropertyType
{
"object"
},
raw
:
`{"key": "value", "number": 42}`
,
want
:
map
[
string
]
interface
{}
{
"key"
:
"value"
,
"number"
:
float64
(
42
)},
want
:
map
[
string
]
any
{
"key"
:
"value"
,
"number"
:
float64
(
42
)},
},
{
desc
:
"nested object"
,
paramType
:
api
.
PropertyType
{
"object"
},
raw
:
`{"outer": {"inner": "value"}}`
,
want
:
map
[
string
]
interface
{}
{
"outer"
:
map
[
string
]
interface
{}
{
"inner"
:
"value"
}},
want
:
map
[
string
]
any
{
"outer"
:
map
[
string
]
any
{
"inner"
:
"value"
}},
},
{
desc
:
"empty object"
,
paramType
:
api
.
PropertyType
{
"object"
},
raw
:
`{}`
,
want
:
map
[
string
]
interface
{}
{},
want
:
map
[
string
]
any
{},
},
// Error cases and fallback behavior
{
...
...
@@ -689,19 +689,19 @@ func TestQwenToolCallValueParsing(t *testing.T) {
desc
:
"array or object union - valid array"
,
paramType
:
api
.
PropertyType
{
"array"
,
"object"
},
raw
:
`[1, 2, 3]`
,
want
:
[]
interface
{}
{
float64
(
1
),
float64
(
2
),
float64
(
3
)},
want
:
[]
any
{
float64
(
1
),
float64
(
2
),
float64
(
3
)},
},
{
desc
:
"array or object union - valid object"
,
paramType
:
api
.
PropertyType
{
"array"
,
"object"
},
raw
:
`{"key": "value"}`
,
want
:
map
[
string
]
interface
{}
{
"key"
:
"value"
},
want
:
map
[
string
]
any
{
"key"
:
"value"
},
},
{
desc
:
"object or array union - valid array (precedence test)"
,
paramType
:
api
.
PropertyType
{
"object"
,
"array"
},
raw
:
`[1, 2, 3]`
,
want
:
[]
interface
{}
{
float64
(
1
),
float64
(
2
),
float64
(
3
)},
want
:
[]
any
{
float64
(
1
),
float64
(
2
),
float64
(
3
)},
},
{
desc
:
"complex multi-type union - null"
,
...
...
model/renderers/qwen3coder.go
View file @
472feec2
...
...
@@ -17,13 +17,13 @@ var (
// renderAdditionalKeys renders all JSON fields except the ones in handledKeys
// This follows the same approach from the reference implementation, which gives
// a particular key ordering
func
renderAdditionalKeys
(
obj
interface
{}
,
handledKeys
map
[
string
]
bool
)
string
{
func
renderAdditionalKeys
(
obj
any
,
handledKeys
map
[
string
]
bool
)
string
{
data
,
err
:=
json
.
Marshal
(
obj
)
if
err
!=
nil
{
return
""
}
var
m
map
[
string
]
interface
{}
var
m
map
[
string
]
any
if
err
:=
json
.
Unmarshal
(
data
,
&
m
);
err
!=
nil
{
return
""
}
...
...
@@ -36,7 +36,7 @@ func renderAdditionalKeys(obj interface{}, handledKeys map[string]bool) string {
// Check if value is a map or array (needs JSON serialization)
switch
v
:=
value
.
(
type
)
{
case
map
[
string
]
interface
{},
[]
interface
{}
:
case
map
[
string
]
any
,
[]
any
:
jsonBytes
,
_
:=
json
.
Marshal
(
v
)
// TODO(drifkin): it would be nice to format the JSON here similarly to
// python's default json.dumps behavior (spaces after commas and colons).
...
...
server/routes.go
View file @
472feec2
...
...
@@ -1618,7 +1618,7 @@ func (s *Server) ChatHandler(c *gin.Context) {
}
msgs
=
filterThinkTags
(
msgs
,
m
)
var
builtinParser
parsers
.
Builtin
Parser
var
builtinParser
parsers
.
Parser
if
m
.
Config
.
Parser
!=
""
{
builtinParser
=
parsers
.
ParserForName
(
m
.
Config
.
Parser
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment