MCPcopy Index your code
hub / github.com/docker/docker-agent / getSessionModels

Method getSessionModels

pkg/server/server.go:756–776  ·  view source on GitHub ↗

getSessionModels lists the models the user can pick from for the session's current agent. Returns 404 if the session has no active runtime (it must have been started at least once or be attached out-of-band) or 422 if the runtime does not support model switching.

(c echo.Context)

Source from the content-addressed store, hash-verified

754// (it must have been started at least once or be attached out-of-band)
755// or 422 if the runtime does not support model switching.
756func (s *Server) getSessionModels(c echo.Context) error {
757 sessionID := c.Param("id")
758
759 agentName, current, choices, err := s.sm.AvailableSessionModels(c.Request().Context(), sessionID)
760 if err != nil {
761 switch {
762 case errors.Is(err, ErrModelSwitchingNotSupported):
763 return echo.NewHTTPError(http.StatusUnprocessableEntity, err.Error())
764 case errors.Is(err, ErrSessionNotRunning):
765 return echo.NewHTTPError(http.StatusNotFound, err.Error())
766 default:
767 return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
768 }
769 }
770
771 return c.JSON(http.StatusOK, runtime.SessionModelsResponse{
772 Agent: agentName,
773 CurrentModelRef: current,
774 Models: choices,
775 })
776}
777
778func (s *Server) batchDeleteSessions(c echo.Context) error {
779 var req api.BatchDeleteSessionsRequest

Callers

nothing calls this directly

Calls 3

ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected