MCPcopy Create free account
hub / github.com/coder/coder / OpenAINonStreamingResponse

Function OpenAINonStreamingResponse

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

OpenAINonStreamingResponse creates a non-streaming response with the given text.

(text string)

Source from the content-addressed store, hash-verified

843
844// OpenAINonStreamingResponse creates a non-streaming response with the given text.
845func OpenAINonStreamingResponse(text string) OpenAIResponse {
846 return OpenAIResponse{
847 Response: &OpenAICompletion{
848 ID: fmt.Sprintf("chatcmpl-%s", uuid.New().String()[:8]),
849 Object: "chat.completion",
850 Created: time.Now().Unix(),
851 Model: "gpt-4",
852 Choices: []OpenAICompletionChoice{
853 {
854 Index: 0,
855 Message: OpenAIMessage{
856 Role: "assistant",
857 Content: text,
858 },
859 FinishReason: "stop",
860 },
861 },
862 Usage: OpenAICompletionUsage{
863 PromptTokens: 10,
864 CompletionTokens: 5,
865 TotalTokens: 15,
866 },
867 },
868 }
869}
870
871// OpenAITextChunks creates streaming chunks with text deltas.
872// Each delta string becomes a separate chunk with a single choice.

Calls 2

NewMethod · 0.65
StringMethod · 0.45