Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(p2p): Federation and AI swarms #2723

Merged
merged 18 commits into from
Jul 8, 2024
Prev Previous commit
Next Next commit
make federated nodes visible from the WebUI
  • Loading branch information
mudler committed Jul 8, 2024
commit 72755f1739d517e718aea36e59b96046e3fd8327
6 changes: 0 additions & 6 deletions core/cli/federated.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"fmt"
"io"
"net"
"os"
"strings"
"time"

"math/rand/v2"
Expand Down Expand Up @@ -99,10 +97,6 @@ func Proxy(ctx context.Context, node *node.Node, listenAddr, service string) err
log.Info().Msgf("Node %s is offline", v.ID)
}
}
tunnelEnvVar := strings.Join(tunnelAddresses, ",")

os.Setenv("LLAMACPP_GRPC_SERVERS", tunnelEnvVar)
log.Debug().Msgf("setting LLAMACPP_GRPC_SERVERS to %s", tunnelEnvVar)

// open a TCP stream to one of the tunnels
// chosen randomly
Expand Down
7 changes: 7 additions & 0 deletions core/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ func (r *RunCMD) Run(ctx *cliContext.Context) error {
if err := p2p.ExposeService(context.Background(), "localhost", port, token, p2p.FederatedID); err != nil {
return err
}
node, err := p2p.NewNode(token)
if err != nil {
return err
}
if err := p2p.ServiceDiscoverer(context.Background(), node, token, p2p.FederatedID, nil); err != nil {
return err
}
}

idleWatchDog := r.EnableWatchdogIdle
Expand Down
5 changes: 3 additions & 2 deletions core/http/routes/localai.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ func RegisterLocalAIRoutes(app *fiber.App,
app.Get("/backend/monitor", auth, localai.BackendMonitorEndpoint(backendMonitorService))
app.Post("/backend/shutdown", auth, localai.BackendShutdownEndpoint(backendMonitorService))

//p2p
// p2p
if p2p.IsP2PEnabled() {
app.Get("/api/p2p", auth, func(c *fiber.Ctx) error {
// Render index
return c.JSON(map[string]interface{}{
"Nodes": p2p.GetAvailableNodes(""),
"Nodes": p2p.GetAvailableNodes(""),
"FederatedNodes": p2p.GetAvailableNodes(p2p.FederatedID),
})
})
app.Get("/api/p2p/token", auth, func(c *fiber.Ctx) error {
Expand Down