Skip to content

Commit 7fdcd28

Browse files
committed
Merge branch 'main' into add-testcontainers
2 parents 65b0d8a + b51ca01 commit 7fdcd28

File tree

12 files changed

+667
-219
lines changed

12 files changed

+667
-219
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ model-distribution-tool:
4242

4343
# Run the application locally
4444
run: build
45-
LLAMA_ARGS="$(LLAMA_ARGS)" \
46-
./$(APP_NAME)
45+
@LLAMACPP_BIN="llamacpp/install/bin"; \
46+
if [ "$(LOCAL_LLAMA)" = "1" ]; then \
47+
echo "Using local llama.cpp build from $${LLAMACPP_BIN}"; \
48+
export LLAMA_SERVER_PATH="$$(pwd)/$${LLAMACPP_BIN}"; \
49+
fi; \
50+
LLAMA_ARGS="$(LLAMA_ARGS)" ./$(APP_NAME)
4751

4852
# Clean build artifacts
4953
clean:
@@ -160,9 +164,11 @@ help:
160164
@echo ""
161165
@echo "Backend configuration options:"
162166
@echo " LLAMA_ARGS - Arguments for llama.cpp (e.g., \"--verbose --jinja -ngl 999 --ctx-size 2048\")"
167+
@echo " LOCAL_LLAMA - Use local llama.cpp build from llamacpp/install/bin (set to 1 to enable)"
163168
@echo ""
164169
@echo "Example usage:"
165170
@echo " make run LLAMA_ARGS=\"--verbose --jinja -ngl 999 --ctx-size 2048\""
171+
@echo " make run LOCAL_LLAMA=1"
166172
@echo " make docker-run LLAMA_ARGS=\"--verbose --jinja -ngl 999 --threads 4 --ctx-size 2048\""
167173
@echo ""
168174
@echo "Model distribution tool examples:"

cmd/cli/commands/integration_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestIntegration_PullModel(t *testing.T) {
153153
require.NoError(t, err)
154154

155155
if len(models) != 0 {
156-
t.Fatal("No models found after pull")
156+
t.Fatal("Expected no initial models, but found some")
157157
}
158158

159159
// Create and push a test model
@@ -174,7 +174,10 @@ func TestIntegration_PullModel(t *testing.T) {
174174
t.Fatal("No models found after pull")
175175
}
176176

177-
if strings.Contains(models, modelID) == false {
178-
t.Fatalf("Pulled model ID %s not found in model list", modelID)
177+
// Extract truncated ID format (sha256:xxx... -> xxx where xxx is 12 chars)
178+
// listModels with quiet=true returns modelID[7:19]
179+
truncatedID := modelID[7:19]
180+
if strings.Contains(models, truncatedID) == false {
181+
t.Fatalf("Pulled model ID %s (truncated: %s) not found in model list:\n%s", modelID, truncatedID, models)
179182
}
180183
}

cmd/cli/commands/list.go

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"os"
7+
"sort"
78
"strconv"
89
"strings"
910
"time"
@@ -114,6 +115,68 @@ func listModels(openai bool, desktopClient *desktop.Client, quiet bool, jsonForm
114115
}
115116

116117
func prettyPrintModels(models []dmrm.Model) string {
118+
type displayRow struct {
119+
displayName string
120+
tag string
121+
model dmrm.Model
122+
}
123+
124+
var rows []displayRow
125+
126+
for _, m := range models {
127+
if len(m.Tags) == 0 {
128+
rows = append(rows, displayRow{
129+
displayName: "<none>",
130+
tag: "<none>",
131+
model: m,
132+
})
133+
continue
134+
}
135+
136+
for _, tag := range m.Tags {
137+
displayName := stripDefaultsFromModelName(tag)
138+
rows = append(rows, displayRow{
139+
displayName: displayName,
140+
tag: tag,
141+
model: m,
142+
})
143+
}
144+
}
145+
146+
// Helper function to split display name into base and variant
147+
splitDisplayName := func(displayName string) (base, variant string) {
148+
if idx := strings.LastIndex(displayName, ":"); idx != -1 {
149+
return displayName[:idx], displayName[idx+1:]
150+
}
151+
return displayName, ""
152+
}
153+
154+
// Sort all rows by display name
155+
sort.Slice(rows, func(i, j int) bool {
156+
displayI := rows[i].displayName
157+
displayJ := rows[j].displayName
158+
159+
// Split on last ':' to get base name and variant
160+
baseI, variantI := splitDisplayName(displayI)
161+
baseJ, variantJ := splitDisplayName(displayJ)
162+
163+
baseILower := strings.ToLower(baseI)
164+
baseJLower := strings.ToLower(baseJ)
165+
if baseILower != baseJLower {
166+
return baseILower < baseJLower
167+
}
168+
169+
// If base names are equal, compare variants
170+
// Empty variants (no ':' in name) come first
171+
if variantI == "" && variantJ != "" {
172+
return true
173+
}
174+
if variantI != "" && variantJ == "" {
175+
return false
176+
}
177+
return strings.ToLower(variantI) < strings.ToLower(variantJ)
178+
})
179+
117180
var buf bytes.Buffer
118181
table := tablewriter.NewWriter(&buf)
119182

@@ -137,14 +200,8 @@ func prettyPrintModels(models []dmrm.Model) string {
137200
})
138201
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
139202

140-
for _, m := range models {
141-
if len(m.Tags) == 0 {
142-
appendRow(table, "<none>", m)
143-
continue
144-
}
145-
for _, tag := range m.Tags {
146-
appendRow(table, tag, m)
147-
}
203+
for _, row := range rows {
204+
appendRow(table, row.tag, row.model)
148205
}
149206

150207
table.Render()

0 commit comments

Comments
 (0)