on disk copy

This commit is contained in:
Josh Yan 2024-07-02 12:14:18 -07:00
parent b48420b74b
commit d25f85ede4
3 changed files with 19 additions and 0 deletions

View File

@ -404,3 +404,12 @@ func Authorization(ctx context.Context, request *http.Request) (string, error) {
key, sig, _ := strings.Cut(token, ":")
return fmt.Sprintf("%s:%s:%s", key, base64.StdEncoding.EncodeToString(data), sig), nil
}
// EnvConfig returns the environment configuration for the server.
func (c *Client) ServerConfig(ctx context.Context) (*ServerConfig, error) {
var config ServerConfig
if err := c.do(ctx, http.MethodGet, "/api/config", nil, &config); err != nil {
return nil, err
}
return &config, nil
}

View File

@ -359,6 +359,11 @@ type ModelDetails struct {
QuantizationLevel string `json:"quantization_level"`
}
// EnvConfig is the configuration for the environment.
type ServerConfig struct {
ModelDir string `json:"model_dir"`
}
func (m *Metrics) Summary() {
if m.TotalDuration > 0 {
fmt.Fprintf(os.Stderr, "total duration: %v\n", m.TotalDuration)

View File

@ -966,6 +966,7 @@ func (s *Server) GenerateRoutes() http.Handler {
r.POST("/api/blobs/:digest", s.CreateBlobHandler)
r.HEAD("/api/blobs/:digest", s.HeadBlobHandler)
r.GET("/api/ps", s.ProcessHandler)
r.GET("/api/config", s.ConfigHandler)
// Compatibility endpoints
r.POST("/v1/chat/completions", openai.ChatMiddleware(), s.ChatHandler)
@ -1287,3 +1288,7 @@ func handleScheduleError(c *gin.Context, name string, err error) {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
}
}
func (s *Server) ConfigHandler(c *gin.Context) {
c.JSON(http.StatusOK, api.ServerConfig{ModelDir: envconfig.ModelsDir})
}