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

Method handleChatCompletions

coderd/x/chatd/chattest/openai.go:213–233  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

211}
212
213func (s *openAIServer) handleChatCompletions(w http.ResponseWriter, r *http.Request) {
214 body, err := io.ReadAll(r.Body)
215 if err != nil {
216 http.Error(w, err.Error(), http.StatusBadRequest)
217 return
218 }
219 var req OpenAIRequest
220 if err := json.NewDecoder(bytes.NewReader(body)).Decode(&req); err != nil {
221 http.Error(w, err.Error(), http.StatusBadRequest)
222 return
223 }
224 req.Request = r
225 req.RawBody = body
226
227 s.mu.Lock()
228 s.request = &req
229 s.mu.Unlock()
230
231 resp := s.handler(&req)
232 s.writeChatCompletionsResponse(w, &req, resp)
233}
234
235func (s *openAIServer) handleResponses(w http.ResponseWriter, r *http.Request) {
236 body, err := io.ReadAll(r.Body)

Callers

nothing calls this directly

Calls 6

handlerMethod · 0.80
ReadAllMethod · 0.45
ErrorMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected