diff --git a/cmd/cograw/main.go b/cmd/cograw/main.go index 24e5114..a3029d7 100644 --- a/cmd/cograw/main.go +++ b/cmd/cograw/main.go @@ -168,10 +168,10 @@ type ValidatePackageRequestParams struct { PackageName string `json:"package_name"` Version string `json:"version,omitempty"` ManifestMetadata *struct { - HasRawModel bool `json:"has_raw_model,omitempty"` - DiskSpaceMB int64 `json:"disk_space_mb,omitempty"` - Registry string `json:"registry,omitempty"` - IsCritical bool `json:"is_critical,omitempty"` + HasRawModel bool `json:"has_raw_model,omitempty"` + DiskSpaceMB int64 `json:"disk_space_mb,omitempty"` + Registry string `json:"registry,omitempty"` + IsCritical bool `json:"is_critical,omitempty"` } `json:"manifest_metadata,omitempty"` } diff --git a/internal/cloud/provider.go b/internal/cloud/provider.go index ae2b6c8..1859580 100644 --- a/internal/cloud/provider.go +++ b/internal/cloud/provider.go @@ -21,11 +21,11 @@ type Config struct { } type CloudBackend struct { - mu sync.Mutex - config *Config - loaded bool + mu sync.Mutex + config *Config + loaded bool modelInfo *llm.ModelInfo - client *http.Client + client *http.Client } func New(cfg *Config) *CloudBackend { @@ -112,8 +112,8 @@ type chatResponse struct { FinishReason *string `json:"finish_reason"` } `json:"choices"` Usage struct { - TotalTokens int `json:"total_tokens"` - PromptTokens int `json:"prompt_tokens"` + TotalTokens int `json:"total_tokens"` + PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` } `json:"usage"` } diff --git a/internal/server/server.go b/internal/server/server.go index 152614f..728ef1e 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -47,14 +47,14 @@ type rawModelInfo struct { } type hardwareInfo struct { - TotalRAMMB int64 `json:"total_ram_mb"` - AvailableRAMMB int64 `json:"available_ram_mb"` - TotalVRAMMB int64 `json:"total_vram_mb,omitempty"` + TotalRAMMB int64 `json:"total_ram_mb"` + AvailableRAMMB int64 `json:"available_ram_mb"` + TotalVRAMMB int64 `json:"total_vram_mb,omitempty"` AvailableVRAMMB int64 `json:"available_vram_mb,omitempty"` - CPUCores int `json:"cpu_cores"` - CPUThreads int `json:"cpu_threads"` - NPUAvailable bool `json:"npu_available,omitempty"` - NPUMemoryMB int64 `json:"npu_memory_mb,omitempty"` + CPUCores int `json:"cpu_cores"` + CPUThreads int `json:"cpu_threads"` + NPUAvailable bool `json:"npu_available,omitempty"` + NPUMemoryMB int64 `json:"npu_memory_mb,omitempty"` } type capabilitiesResponse struct { @@ -83,9 +83,9 @@ type negotiateError struct { } type negotiateAlt struct { - Model string `json:"model"` - RAMUsageMB int64 `json:"ram_usage_mb"` - PerformanceTokensPerS float64 `json:"performance_tokens_per_second"` + Model string `json:"model"` + RAMUsageMB int64 `json:"ram_usage_mb"` + PerformanceTokensPerS float64 `json:"performance_tokens_per_second"` } type generateRequest struct { @@ -97,9 +97,9 @@ type generateRequest struct { } type chatRequest struct { - Model string `json:"model"` - Messages []llm.ChatMsg `json:"messages"` - Stream bool `json:"stream"` + Model string `json:"model"` + Messages []llm.ChatMsg `json:"messages"` + Stream bool `json:"stream"` Options map[string]interface{} `json:"options,omitempty"` } @@ -118,7 +118,7 @@ type healthResponse struct { } type deleteResponse struct { - Status string `json:"status"` + Status string `json:"status"` RAMFreedMB int64 `json:"ram_freed_mb,omitempty"` } @@ -156,10 +156,10 @@ func New(modelDir string, backendType string, cloudCfg *cloud.Config) *Server { } return &Server{ - models: model.NewManager(modelDir), - backend: b, - startTime: time.Now(), - backendType: backendType, + models: model.NewManager(modelDir), + backend: b, + startTime: time.Now(), + backendType: backendType, lastActivity: time.Now(), } } @@ -587,7 +587,7 @@ func (s *Server) handleDelete(w http.ResponseWriter, r *http.Request) { } sendJSON(w, 200, deleteResponse{ - Status: "ok", + Status: "ok", RAMFreedMB: ramFreed, }) } @@ -706,7 +706,7 @@ func (s *Server) handleStatus(w http.ResponseWriter, r *http.Request) { ModelsLoaded: modelsLoaded, ActiveModel: mi, RawModel: rawInfo, - Hardware: &hardwareInfo{ + Hardware: &hardwareInfo{ TotalRAMMB: totalRAM, AvailableRAMMB: availableRAM, CPUCores: cpuCores, @@ -795,11 +795,11 @@ func (s *Server) handleCapabilities(w http.ResponseWriter, r *http.Request) { caps := capabilitiesResponse{ Backends: map[string]bool{ - "cpu": true, - "cuda": false, - "vulkan": false, - "npu": false, - "metal": false, + "cpu": true, + "cuda": false, + "vulkan": false, + "npu": false, + "metal": false, }, PreferredBackend: "cpu", MaxModelSizeMB: 4096, @@ -815,25 +815,25 @@ func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) { if !s.backend.IsLoaded() { status = "degraded" } - + var mem runtime.MemStats runtime.ReadMemStats(&mem) - + totalRAM, _ := readMemMB() ramPct := 0 if totalRAM > 0 { ramPct = int(int64(mem.Alloc) * 100 / (totalRAM * 1024 * 1024)) } - + modelsLoaded := 0 if s.backend.IsLoaded() { modelsLoaded = 1 } - + s.mu.Lock() lastErr := s.lastError s.mu.Unlock() - + sendJSON(w, 200, healthResponse{ Status: status, UptimeSeconds: int64(time.Since(s.startTime).Seconds()),