mirror of
https://github.com/mudler/LocalAI.git
synced 2024-06-07 19:40:48 +00:00
ab7b4d5ee9
Refactors api folder to core, creates firm split between backend code and api frontend.
40 lines
932 B
Go
40 lines
932 B
Go
package schema
|
|
|
|
import (
|
|
"context"
|
|
|
|
gopsutil "github.com/shirou/gopsutil/v3/process"
|
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/metric"
|
|
)
|
|
|
|
type BackendMonitorRequest struct {
|
|
Model string `json:"model" yaml:"model"`
|
|
}
|
|
|
|
type BackendMonitorResponse struct {
|
|
MemoryInfo *gopsutil.MemoryInfoStat
|
|
MemoryPercent float32
|
|
CPUPercent float64
|
|
}
|
|
|
|
type TTSRequest struct {
|
|
Model string `json:"model" yaml:"model"`
|
|
Input string `json:"input" yaml:"input"`
|
|
Backend string `json:"backend" yaml:"backend"`
|
|
}
|
|
|
|
type LocalAIMetrics struct {
|
|
Meter metric.Meter
|
|
ApiTimeMetric metric.Float64Histogram
|
|
}
|
|
|
|
func (m *LocalAIMetrics) ObserveAPICall(method string, path string, duration float64) {
|
|
opts := metric.WithAttributes(
|
|
attribute.String("method", method),
|
|
attribute.String("path", path),
|
|
)
|
|
m.ApiTimeMetric.Record(context.Background(), duration, opts)
|
|
}
|