Skip to content

Commit c61ccbe

Browse files
committed
Minor fixups
1 parent 399f4de commit c61ccbe

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

core/http/views/p2p.html

+36-17
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@
88
{{template "views/partials/navbar" .}}
99
<div class="container mx-auto px-4 flex-grow">
1010

11-
<div class="models mt-12 text-center">
11+
<div class="workers mt-12 text-center">
1212
<h2 class="text-3xl font-semibold text-gray-100 mb-8">
13-
<i class="fa-solid fa-network-wired"></i> P2P Network</h2>
14-
15-
<div class="bg-gray-800 p-6 rounded-lg shadow-lg mb-8 inline-block">
16-
<p class="text-xl font-semibold text-gray-200">Total Workers Detected: {{ len .Nodes}}</p>
17-
{{ $online:=0 }}
18-
{{ range .Nodes }}
19-
{{ if .IsOnline }}
20-
{{ $online = add $online 1 }}
21-
{{ end }}
22-
{{ end }}
23-
<p class="text-xl font-semibold text-gray-200">Total Online Workers: {{$online}}</p>
24-
</div>
13+
<i class="fa-solid fa-network-wired"></i> P2P Network
14+
<a href="https://localai.io/features/distribute/" target="_blank">
15+
<i class="fas fa-circle-info pr-2"></i>
16+
</a>
17+
</h2>
2518

2619
<div class="bg-gray-800 p-6 rounded-lg shadow-lg mb-8 inline-block text-left">
2720
<h3 class="text-2xl font-semibold text-gray-100 mb-4">Start a New Worker</h3>
@@ -32,11 +25,32 @@ <h3 class="text-2xl font-semibold text-gray-100 mb-4">Start a New Worker</h3>
3225
</code>
3326
</div>
3427

35-
<div class="text-center text-xs font-semibold text-gray-100">
28+
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 mb-8">
29+
<div class="bg-gray-800 p-6 rounded-lg shadow-lg text-left">
30+
<p class="text-xl font-semibold text-gray-200">Total Workers Detected: {{ len .Nodes }}</p>
31+
{{ $online := 0 }}
32+
{{ range .Nodes }}
33+
{{ if .IsOnline }}
34+
{{ $online = add $online 1 }}
35+
{{ end }}
36+
{{ end }}
37+
<p class="text-xl font-semibold text-gray-200">Total Online Workers: {{$online}}</p>
38+
</div>
39+
3640
{{ range .Nodes }}
37-
<button hx-post="/browse/search/models" class="text-blue-500 hover:text-blue-300"
38-
hx-target="#search-results" hx-vals='{"search": "{{.ID}}"}'
39-
hx-indicator=".htmx-indicator" >{{.ID}} (Online: {{.IsOnline}})</button>
41+
<div class="bg-gray-800 p-4 rounded-lg shadow-lg text-left">
42+
<div class="flex items-center mb-2">
43+
<i class="fas fa-desktop text-gray-400 mr-2"></i>
44+
<span class="text-gray-200 font-semibold">{{.ID}}</span>
45+
</div>
46+
<p class="text-sm text-gray-400 mt-2 flex items-center">
47+
Status:
48+
<i class="fas fa-circle {{ if .IsOnline }}text-green-500{{ else }}text-red-500{{ end }} ml-2 mr-1"></i>
49+
<span class="{{ if .IsOnline }}text-green-400{{ else }}text-red-400{{ end }}">
50+
{{ if .IsOnline }}Online{{ else }}Offline{{ end }}
51+
</span>
52+
</p>
53+
</div>
4054
{{ end }}
4155
</div>
4256
</div>
@@ -49,6 +63,11 @@ <h3 class="text-2xl font-semibold text-gray-100 mb-4">Start a New Worker</h3>
4963
.token {
5064
word-break: break-all;
5165
}
66+
.workers .grid div {
67+
display: flex;
68+
flex-direction: column;
69+
justify-content: space-between;
70+
}
5271
</style>
5372

5473
</body>

core/p2p/p2p.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func LLamaCPPRPCServerDiscoverer(ctx context.Context, token string) error {
166166
AddNode(tunnel)
167167

168168
var tunnelAddresses []string
169-
for _, v := range nodes {
169+
for _, v := range GetAvailableNodes() {
170170
if v.IsOnline() {
171171
tunnelAddresses = append(tunnelAddresses, v.TunnelAddress)
172172
} else {
@@ -237,7 +237,9 @@ func discoveryTunnels(ctx context.Context, token string) (chan NodeData, error)
237237
}
238238
ensureService(ctx, n, nd, k)
239239
muservice.Lock()
240-
tunnels <- service[nd.Name].NodeData
240+
if _, ok := service[nd.Name]; ok {
241+
tunnels <- service[nd.Name].NodeData
242+
}
241243
muservice.Unlock()
242244
}
243245
}

0 commit comments

Comments
 (0)