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
08fbb60b
Commit
08fbb60b
authored
Oct 14, 2025
by
Devon Rifkin
Browse files
qwen3-coder: support anyOf when parsing tool calls
parent
850da848
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
model/parsers/qwen3coder.go
model/parsers/qwen3coder.go
+8
-1
model/parsers/qwen3coder_test.go
model/parsers/qwen3coder_test.go
+15
-0
No files found.
model/parsers/qwen3coder.go
View file @
08fbb60b
...
...
@@ -276,9 +276,16 @@ func parseToolCall(raw qwenEventRawToolCall, tools []api.Tool) (api.ToolCall, er
var
paramType
api
.
PropertyType
if
matchedTool
!=
nil
&&
matchedTool
.
Function
.
Parameters
.
Properties
!=
nil
{
if
prop
,
ok
:=
matchedTool
.
Function
.
Parameters
.
Properties
[
parameter
.
Name
];
ok
{
// Handle anyOf by collecting all types from the union
if
len
(
prop
.
AnyOf
)
>
0
{
for
_
,
anyOfProp
:=
range
prop
.
AnyOf
{
paramType
=
append
(
paramType
,
anyOfProp
.
Type
...
)
}
}
else
{
paramType
=
prop
.
Type
}
}
}
toolCall
.
Function
.
Arguments
[
parameter
.
Name
]
=
parseValue
(
parameter
.
Value
,
paramType
)
}
...
...
model/parsers/qwen3coder_test.go
View file @
08fbb60b
...
...
@@ -977,6 +977,21 @@ func TestQwenToolCallValueParsing(t *testing.T) {
raw
:
"123"
,
want
:
123
,
// Integer has higher precedence than string
},
{
desc
:
"anyOf array or string - with array of objects"
,
paramType
:
api
.
PropertyType
{
"array"
,
"string"
},
raw
:
`[{"content": "task 1", "status": "pending", "priority": "high", "id": "1"}, {"content": "task 2", "status": "completed", "priority": "low", "id": "2"}]`
,
want
:
[]
any
{
map
[
string
]
any
{
"content"
:
"task 1"
,
"status"
:
"pending"
,
"priority"
:
"high"
,
"id"
:
"1"
},
map
[
string
]
any
{
"content"
:
"task 2"
,
"status"
:
"completed"
,
"priority"
:
"low"
,
"id"
:
"2"
},
},
},
{
desc
:
"anyOf array or string - with plain string"
,
paramType
:
api
.
PropertyType
{
"array"
,
"string"
},
raw
:
"Error: could not load data"
,
want
:
"Error: could not load data"
,
},
}
for
_
,
tc
:=
range
cases
{
...
...
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