Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/cograw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
12 changes: 6 additions & 6 deletions internal/cloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
}
Expand Down
60 changes: 30 additions & 30 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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"`
}

Expand All @@ -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"`
}

Expand Down Expand Up @@ -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(),
}
}
Expand Down Expand Up @@ -587,7 +587,7 @@ func (s *Server) handleDelete(w http.ResponseWriter, r *http.Request) {
}

sendJSON(w, 200, deleteResponse{
Status: "ok",
Status: "ok",
RAMFreedMB: ramFreed,
})
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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()),
Expand Down
Loading