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

Method aiBridgeListModels

enterprise/coderd/aibridge.go:540–581  ·  view source on GitHub ↗

aiBridgeListModels returns all AI Bridge models a user can see. @Summary List AI Bridge models @ID list-ai-bridge-models @Security CoderSessionToken @Produce json @Tags AI Bridge @Success 200 {array} string @Router /api/v2/aibridge/models [get]

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

538// @Success 200 {array} string
539// @Router /api/v2/aibridge/models [get]
540func (api *API) aiBridgeListModels(rw http.ResponseWriter, r *http.Request) {
541 ctx := r.Context()
542
543 page, ok := coderd.ParsePagination(rw, r)
544 if !ok {
545 return
546 }
547
548 if page.Limit == 0 {
549 page.Limit = defaultListModelsLimit
550 }
551
552 if page.Limit > maxListModelsLimit || page.Limit < 1 {
553 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
554 Message: "Invalid pagination limit value.",
555 Detail: fmt.Sprintf("Pagination limit must be in range (0, %d]", maxListModelsLimit),
556 })
557 return
558 }
559
560 queryStr := r.URL.Query().Get("q")
561 filter, errs := searchquery.AIBridgeModels(queryStr, page)
562
563 if len(errs) > 0 {
564 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
565 Message: "Invalid AI Bridge models search query.",
566 Validations: errs,
567 })
568 return
569 }
570
571 models, err := api.Database.ListAIBridgeModels(ctx, filter)
572 if err != nil {
573 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
574 Message: "Internal error getting AI Bridge models.",
575 Detail: err.Error(),
576 })
577 return
578 }
579
580 httpapi.Write(ctx, rw, http.StatusOK, models)
581}
582
583// aiBridgeListClients returns all AI Bridge clients a user can see.
584//

Callers

nothing calls this directly

Calls 7

ParsePaginationFunction · 0.92
WriteFunction · 0.92
AIBridgeModelsFunction · 0.92
ContextMethod · 0.65
GetMethod · 0.65
ListAIBridgeModelsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected