mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-27 14:05:00 +00:00
[Refactor]: Core/API Split (#1506)
Refactors api folder to core, creates firm split between backend code and api frontend.
This commit is contained in:
parent
bcf02449b3
commit
ab7b4d5ee9
77 changed files with 3441 additions and 3117 deletions
39
pkg/schema/localai.go
Normal file
39
pkg/schema/localai.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue