Skip to content

Commit ca96abd

Browse files
authored
feat(ToolChoice): refactor chat system and tool selection (#159)
- Add a system chat message with the content "You are a helpful assistant." - Introduce a new `ToolChoice` structure with `Type` set to `ToolTypeFunction` and `Function` containing the function name. Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent e11029e commit ca96abd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

openai/openai.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,22 @@ func (c *Client) CreateFunctionCall(
108108
FrequencyPenalty: c.frequencyPenalty,
109109
PresencePenalty: c.presencePenalty,
110110
Messages: []openai.ChatCompletionMessage{
111+
{
112+
Role: openai.ChatMessageRoleSystem,
113+
Content: "You are a helpful assistant.",
114+
},
111115
{
112116
Role: openai.ChatMessageRoleUser,
113117
Content: content,
114118
},
115119
},
116120
Tools: []openai.Tool{t},
121+
ToolChoice: openai.ToolChoice{
122+
Type: openai.ToolTypeFunction,
123+
Function: openai.ToolFunction{
124+
Name: f.Name,
125+
},
126+
},
117127
}
118128

119129
return c.client.CreateChatCompletion(ctx, req)

0 commit comments

Comments
 (0)