Skip to content

Commit b1643ee

Browse files
waleedlatif1claude
andcommitted
fix(knowledge): only enforce single embedding model when query is present
Tag-only searches don't generate a query embedding, so two KBs with different embedding models can be filtered together. Gate the guard on hasQuery so cross-model tag-only queries no longer 400. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 97fa4d5 commit b1643ee

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • apps/sim/app/api/knowledge/search

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
251251
const useReranker = validatedData.rerankerEnabled && Boolean(validatedData.query?.trim())
252252
const rerankerModel = useReranker ? validatedData.rerankerModel : null
253253

254+
const hasQuery = validatedData.query && validatedData.query.trim().length > 0
254255
const embeddingModels = Array.from(new Set(accessibleKbs.map((kb) => kb.embeddingModel)))
255-
if (embeddingModels.length > 1) {
256+
if (hasQuery && embeddingModels.length > 1) {
256257
return NextResponse.json(
257258
{
258259
error:
@@ -263,7 +264,6 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
263264
}
264265
const queryEmbeddingModel = embeddingModels[0]
265266

266-
const hasQuery = validatedData.query && validatedData.query.trim().length > 0
267267
const queryEmbeddingPromise = hasQuery
268268
? generateSearchEmbedding(validatedData.query!, queryEmbeddingModel, workspaceId)
269269
: Promise.resolve(null)

0 commit comments

Comments
 (0)