Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/openai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
}
}

toolMapping := map[string]string{}
for _, tool := range messageRequest.Tools {
var params any = tool.Function.Parameters
if tool.Function.Parameters == nil || len(tool.Function.Parameters.Properties) == 0 {
Expand All @@ -365,6 +366,10 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
}
}

if tool.Function.ToolID != "" {
toolMapping[tool.Function.Name] = tool.Function.ToolID
}

request.Tools = append(request.Tools, openai.Tool{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Expand All @@ -378,7 +383,10 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
id := counter.Next()
status <- types.CompletionStatus{
CompletionID: id,
Request: request,
Request: map[string]any{
"chatCompletion": request,
"toolMapping": toolMapping,
},
}

var cacheResponse bool
Expand Down
Loading