Skip to content

Commit

Permalink
Merge branch 'master' into feat-request-middleware
Browse files Browse the repository at this point in the history
Signed-off-by: Dave <[email protected]>
  • Loading branch information
dave-gray101 authored Nov 7, 2024
2 parents 8a1725b + e2a8dd6 commit 0ad78eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions core/backend/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func ModelTTS(
opts := ModelOptions(*&backendConfig, appConfig, []model.Option{
model.WithDefaultBackendString(model.PiperBackend),
})

ttsModel, err := loader.BackendLoader(opts...)
if err != nil {
return "", nil, err
Expand Down
16 changes: 8 additions & 8 deletions core/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,14 @@ func discoveryTunnels(ctx context.Context, n *node.Node, token, servicesID strin

data := ledger.LastBlock().Storage[servicesID]

zlog.Debug().Any("data", ledger.LastBlock().Storage).Msg("Ledger data")
if logLevel == logLevelDebug {
// We want to surface this debugging data only if p2p logging is set to debug
// (and not generally the whole application, as this can be really noisy)
zlog.Debug().Any("data", ledger.LastBlock().Storage).Msg("Ledger data")
}

for k, v := range data {
zlog.Debug().Msgf("New worker found in the ledger data '%s'", k)
// New worker found in the ledger data as k (worker id)
nd := &NodeData{}
if err := v.Unmarshal(nd); err != nil {
zlog.Error().Msg("cannot unmarshal node data")
Expand Down Expand Up @@ -269,7 +273,7 @@ func ensureService(ctx context.Context, n *node.Node, nd *NodeData, sserv string
if ndService, found := service[nd.Name]; !found {
if !nd.IsOnline() {
// if node is offline and not present, do nothing
zlog.Debug().Msgf("Node %s is offline", nd.ID)
// Node nd.ID is offline
return
}

Expand Down Expand Up @@ -381,10 +385,6 @@ func newNodeOpts(token string) ([]node.Option, error) {
noDHT := os.Getenv("LOCALAI_P2P_DISABLE_DHT") == "true"
noLimits := os.Getenv("LOCALAI_P2P_ENABLE_LIMITS") == "true"

loglevel := os.Getenv("LOCALAI_P2P_LOGLEVEL")
if loglevel == "" {
loglevel = "info"
}
libp2ploglevel := os.Getenv("LOCALAI_LIBP2P_LOGLEVEL")
if libp2ploglevel == "" {
libp2ploglevel = "fatal"
Expand All @@ -396,7 +396,7 @@ func newNodeOpts(token string) ([]node.Option, error) {
},
NetworkToken: token,
LowProfile: false,
LogLevel: loglevel,
LogLevel: logLevel,
Libp2pLogLevel: libp2ploglevel,
Ledger: config.Ledger{
SyncInterval: defaultInterval,
Expand Down
19 changes: 19 additions & 0 deletions core/p2p/p2p_common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package p2p

import (
"os"
"strings"
)

var logLevel = strings.ToLower(os.Getenv("LOCALAI_P2P_LOGLEVEL"))

const (
logLevelDebug = "debug"
logLevelInfo = "info"
)

func init() {
if logLevel == "" {
logLevel = logLevelInfo
}
}

0 comments on commit 0ad78eb

Please sign in to comment.