OpenAIToolCallChunk creates a streaming chunk with a tool call. Takes the tool name and arguments JSON string, creates a tool call for choice index 0.
(toolName, arguments string)
| 901 | // OpenAIToolCallChunk creates a streaming chunk with a tool call. |
| 902 | // Takes the tool name and arguments JSON string, creates a tool call for choice index 0. |
| 903 | func OpenAIToolCallChunk(toolName, arguments string) OpenAIChunk { |
| 904 | return OpenAIChunk{ |
| 905 | ID: fmt.Sprintf("chatcmpl-%s", uuid.New().String()[:8]), |
| 906 | Object: "chat.completion.chunk", |
| 907 | Created: time.Now().Unix(), |
| 908 | Model: "gpt-4", |
| 909 | Choices: []OpenAIChunkChoice{ |
| 910 | { |
| 911 | Index: 0, |
| 912 | ToolCalls: []OpenAIToolCall{ |
| 913 | { |
| 914 | Index: 0, |
| 915 | ID: fmt.Sprintf("call_%s", uuid.New().String()[:8]), |
| 916 | Type: "function", |
| 917 | Function: OpenAIToolCallFunction{ |
| 918 | Name: toolName, |
| 919 | Arguments: arguments, |
| 920 | }, |
| 921 | }, |
| 922 | }, |
| 923 | }, |
| 924 | }, |
| 925 | } |
| 926 | } |