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
55bbf3b4
Unverified
Commit
55bbf3b4
authored
Jun 18, 2025
by
Jeffrey Morgan
Committed by
GitHub
Jun 18, 2025
Browse files
tools: return empty arguments object instead of null (#11113)
parent
6bda1d24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
tools/tools.go
tools/tools.go
+2
-2
tools/tools_test.go
tools/tools_test.go
+15
-10
No files found.
tools/tools.go
View file @
55bbf3b4
...
@@ -115,11 +115,10 @@ func (p *Parser) findTag() (int, bool) {
...
@@ -115,11 +115,10 @@ func (p *Parser) findTag() (int, bool) {
// parseToolCall finds the next complete tool call in the buffer
// parseToolCall finds the next complete tool call in the buffer
// incrementing n and advancing the buffer.
// incrementing n and advancing the buffer.
func
(
p
*
Parser
)
parseToolCall
()
*
api
.
ToolCall
{
func
(
p
*
Parser
)
parseToolCall
()
*
api
.
ToolCall
{
var
args
map
[
string
]
any
var
tool
*
api
.
Tool
var
tool
*
api
.
Tool
var
end
int
=
len
(
p
.
buffer
)
var
end
int
=
len
(
p
.
buffer
)
var
i
int
var
i
int
// find tool name
// find tool name
for
_
,
t
:=
range
p
.
tools
{
for
_
,
t
:=
range
p
.
tools
{
n
:=
t
.
Function
.
Name
n
:=
t
.
Function
.
Name
...
@@ -136,6 +135,7 @@ func (p *Parser) parseToolCall() *api.ToolCall {
...
@@ -136,6 +135,7 @@ func (p *Parser) parseToolCall() *api.ToolCall {
}
}
// only look for arguments if the tool has parameters
// only look for arguments if the tool has parameters
args
:=
map
[
string
]
any
{}
if
len
(
tool
.
Function
.
Parameters
.
Properties
)
>
0
{
if
len
(
tool
.
Function
.
Parameters
.
Properties
)
>
0
{
if
args
,
i
=
p
.
findArguments
(
*
tool
);
args
==
nil
{
if
args
,
i
=
p
.
findArguments
(
*
tool
);
args
==
nil
{
return
nil
return
nil
...
...
tools/tools_test.go
View file @
55bbf3b4
...
@@ -190,8 +190,9 @@ func TestParser(t *testing.T) {
...
@@ -190,8 +190,9 @@ func TestParser(t *testing.T) {
calls
:
[]
api
.
ToolCall
{
calls
:
[]
api
.
ToolCall
{
{
{
Function
:
api
.
ToolCallFunction
{
Function
:
api
.
ToolCallFunction
{
Index
:
0
,
Index
:
0
,
Name
:
"say_hello"
,
Name
:
"say_hello"
,
Arguments
:
api
.
ToolCallFunctionArguments
{},
},
},
},
},
},
},
...
@@ -265,8 +266,9 @@ func TestParser(t *testing.T) {
...
@@ -265,8 +266,9 @@ func TestParser(t *testing.T) {
calls
:
[]
api
.
ToolCall
{
calls
:
[]
api
.
ToolCall
{
{
{
Function
:
api
.
ToolCallFunction
{
Function
:
api
.
ToolCallFunction
{
Index
:
0
,
Index
:
0
,
Name
:
"say_hello"
,
Name
:
"say_hello"
,
Arguments
:
api
.
ToolCallFunctionArguments
{},
},
},
},
},
{
{
...
@@ -413,8 +415,9 @@ func TestParser(t *testing.T) {
...
@@ -413,8 +415,9 @@ func TestParser(t *testing.T) {
calls
:
[]
api
.
ToolCall
{
calls
:
[]
api
.
ToolCall
{
{
{
Function
:
api
.
ToolCallFunction
{
Function
:
api
.
ToolCallFunction
{
Index
:
0
,
Index
:
0
,
Name
:
"say_hello"
,
Name
:
"say_hello"
,
Arguments
:
api
.
ToolCallFunctionArguments
{},
},
},
},
},
},
},
...
@@ -441,8 +444,9 @@ func TestParser(t *testing.T) {
...
@@ -441,8 +444,9 @@ func TestParser(t *testing.T) {
calls
:
[]
api
.
ToolCall
{
calls
:
[]
api
.
ToolCall
{
{
{
Function
:
api
.
ToolCallFunction
{
Function
:
api
.
ToolCallFunction
{
Index
:
0
,
Index
:
0
,
Name
:
"say_hello"
,
Name
:
"say_hello"
,
Arguments
:
api
.
ToolCallFunctionArguments
{},
},
},
},
},
},
},
...
@@ -577,8 +581,9 @@ func TestParser(t *testing.T) {
...
@@ -577,8 +581,9 @@ func TestParser(t *testing.T) {
calls
:
[]
api
.
ToolCall
{
calls
:
[]
api
.
ToolCall
{
{
{
Function
:
api
.
ToolCallFunction
{
Function
:
api
.
ToolCallFunction
{
Index
:
0
,
Index
:
0
,
Name
:
"say_hello"
,
Name
:
"say_hello"
,
Arguments
:
api
.
ToolCallFunctionArguments
{},
},
},
},
},
},
},
...
...
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