Skip to content

Commit aa452f4

Browse files
committed
fix(knowledge): validate Ollama auto-detected dimension against bounds
1 parent d308fe0 commit aa452f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/sim/app/api/knowledge/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ export async function POST(req: NextRequest) {
168168

169169
// Auto-correct dimension if the model reports a different one
170170
if (modelInfo.embeddingLength && modelInfo.embeddingLength !== effectiveDimension) {
171+
if (modelInfo.embeddingLength < 64 || modelInfo.embeddingLength > 8192) {
172+
return NextResponse.json(
173+
{
174+
error: `Ollama model "${modelName}" reported an unsupported embedding dimension (${modelInfo.embeddingLength}). Supported range: 64–8192.`,
175+
},
176+
{ status: 400 }
177+
)
178+
}
171179
logger.info(
172180
`[${requestId}] Auto-correcting embedding dimension from ${effectiveDimension} ` +
173181
`to ${modelInfo.embeddingLength} (reported by Ollama model ${modelName})`

0 commit comments

Comments
 (0)