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

Function OpenAI

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

OpenAI creates a fake OpenAI-compatible test server with a sensible default handler and returns its base URL. It handles both the Responses API (/responses) and the Chat Completions API (/chat/completions). Non-streaming requests (e.g. structured-output title generation) receive a JSON payload sati

(t testing.TB)

Source from the content-addressed store, hash-verified

176// text chunk. Use NewOpenAI when a test needs control over the
177// response.
178func OpenAI(t testing.TB) string {
179 t.Helper()
180 return NewOpenAI(t, func(req *OpenAIRequest) OpenAIResponse {
181 if req.Stream {
182 return OpenAIStreamingResponse(OpenAITextChunks("Hello from test server.")...)
183 }
184 return OpenAINonStreamingResponse(`{"title": "Test Chat"}`)
185 })
186}
187
188// NewOpenAI creates a new OpenAI test server with a handler function.
189// The handler is called for each request and should return either a streaming

Callers 3

seedChatDependenciesFunction · 0.92

Calls 5

OpenAIStreamingResponseFunction · 0.85
OpenAITextChunksFunction · 0.85
NewOpenAIFunction · 0.70
HelperMethod · 0.65

Tested by 1

seedChatDependenciesFunction · 0.74