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)
| 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. |
| 756 | func (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 | |
| 778 | func (s *Server) batchDeleteSessions(c echo.Context) error { |
| 779 | var req api.BatchDeleteSessionsRequest |
nothing calls this directly
no test coverage detected