Skip to content

Commit 13ce9b3

Browse files
authored
refactor(ark): remove explicit tool choice assignment from chat model (#695)
Removed explicit `toolChoice` field assignment in tool binding methods for both standard ChatModel and ResponsesAPIChatModel. Changes: - Remove `toolChoice = &tc` assignment in WithTools(), BindTools(), and BindForcedTools() methods in chatmodel.go - Remove `toolChoice` assignment in ResponsesAPIChatModel.WithTools() method in responses_api.go - Simplify tool binding logic by relying on default behavior instead of explicit ToolChoiceAllowed/ToolChoiceForced settings This change simplifies the codebase by removing redundant tool choice configuration, allowing the underlying implementation to handle tool choice behavior implicitly.
1 parent 1332771 commit 13ce9b3

File tree

2 files changed

+0
-15
lines changed

2 files changed

+0
-15
lines changed

components/model/ark/chatmodel.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,12 @@ func (cm *ChatModel) WithTools(tools []*schema.ToolInfo) (fmodel.ToolCallingChat
462462
return nil, fmt.Errorf("failed to convert to ark responsesAPI tools: %w", err)
463463
}
464464

465-
tc := schema.ToolChoiceAllowed
466-
467465
ncm := *cm.chatModel
468466
ncm.rawTools = tools
469467
ncm.tools = arkTools
470-
ncm.toolChoice = &tc
471-
472468
nrcm := *cm.respChatModel
473469
nrcm.rawTools = tools
474470
nrcm.tools = respTools
475-
nrcm.toolChoice = &tc
476-
477471
return &ChatModel{
478472
chatModel: &ncm,
479473
respChatModel: &nrcm,
@@ -484,23 +478,16 @@ func (cm *ChatModel) BindTools(tools []*schema.ToolInfo) (err error) {
484478
if err = cm.tryBindTools(tools); err != nil {
485479
return err
486480
}
487-
488-
tc := schema.ToolChoiceAllowed
489-
cm.chatModel.toolChoice = &tc
490-
cm.respChatModel.toolChoice = &tc
491-
492481
return nil
493482
}
494483

495484
func (cm *ChatModel) BindForcedTools(tools []*schema.ToolInfo) (err error) {
496485
if err = cm.tryBindTools(tools); err != nil {
497486
return err
498487
}
499-
500488
tc := schema.ToolChoiceForced
501489
cm.chatModel.toolChoice = &tc
502490
cm.respChatModel.toolChoice = &tc
503-
504491
return nil
505492
}
506493

components/model/ark/responses_api.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,11 +1608,9 @@ func (cm *ResponsesAPIChatModel) WithTools(tools []*schema.ToolInfo) (model.Tool
16081608
if err != nil {
16091609
return nil, fmt.Errorf("failed to convert to ark responsesAPI tools: %w", err)
16101610
}
1611-
tc := schema.ToolChoiceAllowed
16121611
nrcm := *cm
16131612
nrcm.rawTools = tools
16141613
nrcm.tools = respTools
1615-
nrcm.toolChoice = &tc
16161614

16171615
return &nrcm, nil
16181616
}

0 commit comments

Comments
 (0)