2024-08-25 12:36:09 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import grpc "github.com/mudler/LocalAI/pkg/grpc"
|
|
|
|
|
|
|
|
type Model struct {
|
2024-09-25 16:00:23 +00:00
|
|
|
ID string `json:"id"`
|
2024-08-25 12:36:09 +00:00
|
|
|
address string
|
|
|
|
client grpc.Backend
|
|
|
|
}
|
|
|
|
|
2024-09-25 16:00:23 +00:00
|
|
|
func NewModel(ID, address string) *Model {
|
2024-08-25 12:36:09 +00:00
|
|
|
return &Model{
|
2024-09-25 16:00:23 +00:00
|
|
|
ID: ID,
|
2024-08-25 12:36:09 +00:00
|
|
|
address: address,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Model) GRPC(parallel bool, wd *WatchDog) grpc.Backend {
|
|
|
|
if m.client != nil {
|
|
|
|
return m.client
|
|
|
|
}
|
|
|
|
|
|
|
|
enableWD := false
|
|
|
|
if wd != nil {
|
|
|
|
enableWD = true
|
|
|
|
}
|
|
|
|
|
2024-08-30 13:20:39 +00:00
|
|
|
m.client = grpc.NewClient(m.address, parallel, wd, enableWD)
|
|
|
|
return m.client
|
2024-08-25 12:36:09 +00:00
|
|
|
}
|