MCPcopy Index your code
hub / github.com/coder/coder / OpenAIToolCallChunk

Function OpenAIToolCallChunk

coderd/x/chatd/chattest/openai.go:903–926  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
903func 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}

Calls 2

NewMethod · 0.65
StringMethod · 0.45