fix: draw the API key once, and let status answer the dimensions question
Release / release (push) Successful in 6s
Release / release (push) Successful in 6s
Two things a user setting this up hit immediately. The card drew `embeddingApiKey` twice. The render loop walked every entry in FIELDS, and the secret — which is drawn by hand, as a write-only password control — was one of them, so a second control appeared beside it: an ordinary text input, echoing the key in clear as you typed. One key, two boxes, one of them visible. The loop skips secrets now, and the tests count controls rather than checking that each expected label is present, because a duplicate beside the real control passed the old assertions. `status` could not answer the one question a new user cannot look up: how wide is this model? The probe that reports it was gated on every required setting being present, so in exactly the state that needs the answer — dimensions unset — it reported nothing and said "Missing: embedding_dimensions". It now runs whenever the endpoint can be named (a model and a base URL), and the status message names the width it observed: Missing: embedding_dimensions. The endpoint is reachable and returned 768 dimensions, so set embeddingDimensions to 768. The probe also tells "not set yet" apart from "set wrong", because the two have different remedies. Also documents both ways to read the width by hand, since a wrong value is frozen into the index at first use and costs a full re-embed to correct.
This commit is contained in:
1 parent
85c0d4dccd
commit
9ebd484e60
7 files changed
+142
-7
No files matched your search
+31
-2
@@ -641,8 +641,37 @@ test('status returns lossless JSON when the endpoint probe SUCCEEDS', async () =
|
||||
}
|
||||
})
|
||||
|
||||
test('status returns lossless JSON when the endpoint probe FAILS', async () => {
|
||||
const { state } = harness({
|
||||
test('status asks the endpoint how wide the model is when embeddingDimensions is unset', async () => {
|
||||
// The question a new user cannot answer from anywhere else. The probe used to
|
||||
// be gated on every required setting being present, which meant it was
|
||||
// unavailable in exactly the state that needs it — so `status` said "Missing:
|
||||
// embedding_dimensions" and left you to guess.
|
||||
const { createServer } = await import('node:http')
|
||||
const server = createServer((request, response) => {
|
||||
response.writeHead(200, { 'content-type': 'application/json' })
|
||||
response.end(JSON.stringify({ data: [{ embedding: new Array(1024).fill(0.01) }] }))
|
||||
})
|
||||
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
|
||||
const { port } = server.address()
|
||||
try {
|
||||
const { state } = harness({
|
||||
embeddingModel: 'ollama/example:latest',
|
||||
embeddingDimensions: 0,
|
||||
embeddingApiBase: `http://127.0.0.1:${port}`,
|
||||
})
|
||||
const value = await state.tools.get('slopo').execute({ action: 'status' }, execContext('/tmp'))
|
||||
assertLossless('status (dimensions unset)', value)
|
||||
assert.deepEqual(value.details.missingSettings, ['embedding_dimensions'])
|
||||
assert.equal(value.details.embeddingEndpoint.checked, true, 'the probe must still run')
|
||||
assert.equal(value.details.embeddingEndpoint.dimensions, 1024, 'the observed width is the answer')
|
||||
assert.match(value.message, /returned 1024 dimensions/)
|
||||
assert.match(value.message, /set embeddingDimensions to 1024/)
|
||||
} finally {
|
||||
await new Promise((resolve) => server.close(resolve))
|
||||
}
|
||||
})
|
||||
|
||||
test('status returns lossless JSON when the endpoint probe FAILS', async () => { const { state } = harness({
|
||||
embeddingModel: 'ollama/example:latest',
|
||||
embeddingDimensions: 768,
|
||||
// Nothing is listening on this port, so the fetch rejects.
|
||||
|
||||
Reference in new issue
Block a user