Skip to content

Commit df259f9

Browse files
chore: return toolMapping in chat progress message
1 parent 8a0f8c6 commit df259f9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/openai/client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
356356
}
357357
}
358358

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

369+
if tool.Function.ToolID != "" {
370+
toolMapping[tool.Function.Name] = tool.Function.ToolID
371+
}
372+
368373
request.Tools = append(request.Tools, openai.Tool{
369374
Type: openai.ToolTypeFunction,
370375
Function: &openai.FunctionDefinition{
@@ -378,7 +383,10 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
378383
id := counter.Next()
379384
status <- types.CompletionStatus{
380385
CompletionID: id,
381-
Request: request,
386+
Request: map[string]any{
387+
"chatCompletion": request,
388+
"toolMapping": toolMapping,
389+
},
382390
}
383391

384392
var cacheResponse bool

0 commit comments

Comments
 (0)