Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9614a28
feat(knowledge): add embedding model selection and Cohere reranker
waleedlatif1 Apr 30, 2026
c56b7a4
fix(knowledge): split reranker model constants into client-safe module
waleedlatif1 Apr 30, 2026
5d1446f
fix(knowledge): bill rerank on every successful API call and fix MDX …
waleedlatif1 Apr 30, 2026
553021a
test(knowledge): align embedding tests with provider abstraction changes
waleedlatif1 Apr 30, 2026
542d2ed
fix(knowledge): require explicit Azure deployment per OpenAI embeddin…
waleedlatif1 Apr 30, 2026
d70ac8f
fix(knowledge): skip platform reranker billing for BYOK Cohere keys
waleedlatif1 Apr 30, 2026
57589cb
fix(knowledge): match search tokenizer to embedding provider; remove …
waleedlatif1 Apr 30, 2026
96cf4dd
fix(knowledge): match chunk tokenizer to KB embedding provider
waleedlatif1 Apr 30, 2026
14538a1
refactor(knowledge): centralize tokenizer mapping on EmbeddingModelInfo
waleedlatif1 Apr 30, 2026
7a9ba8b
refactor(knowledge): lock embedding model to KB_EMBEDDING_MODEL env var
waleedlatif1 Apr 30, 2026
53624f3
fix(knowledge): use provider tokenizer for chunks and bound rerank in…
waleedlatif1 Apr 30, 2026
97fa4d5
fix(knowledge): use .count from estimateTokenCount return value
waleedlatif1 Apr 30, 2026
b1643ee
fix(knowledge): only enforce single embedding model when query is pre…
waleedlatif1 Apr 30, 2026
78d6af7
fix(knowledge): use getConfiguredEmbeddingModel in copilot KB creation
waleedlatif1 Apr 30, 2026
687b7f5
fix(knowledge): make EMBEDDING_DIMENSIONS a literal type
waleedlatif1 Apr 30, 2026
f7eef61
fix(knowledge): use per-KB embedding model in v1 search route
waleedlatif1 Apr 30, 2026
cb1cab7
chore(knowledge): polish embedding/reranker implementation
waleedlatif1 Apr 30, 2026
5dfaed2
fix(knowledge): resolve type errors and unhandled rejection in search…
waleedlatif1 Apr 30, 2026
b73c218
fix(knowledge): pass Gemini API key via x-goog-api-key header
waleedlatif1 Apr 30, 2026
64a17db
fix(knowledge): default Azure deployment name to embedding model name
waleedlatif1 Apr 30, 2026
99743d9
fix(knowledge): cap Gemini batches at 100 items, add singular GEMINI_…
waleedlatif1 Apr 30, 2026
8fd0557
fix(knowledge): prefer singular Cohere key before rotation
waleedlatif1 Apr 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/docs/content/docs/en/tools/firecrawl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ Parse uploaded documents (PDF, DOCX, HTML, etc.) into clean markdown using Firec
| `proxy` | string | No | Proxy mode: "basic" or "auto" |
| `zeroDataRetention` | boolean | No | Enable zero data retention. Defaults to false. |
| `apiKey` | string | Yes | Firecrawl API key |
| `pricing` | custom | No | No description |
| `metadata` | string | No | No description |
| `rateLimit` | string | No | No description |

#### Output
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/content/docs/en/tools/knowledge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Search for similar content in a knowledge base using vector similarity
| `properties` | string | No | No description |
| `tagName` | string | No | No description |
| `tagValue` | string | No | No description |
| `rerankerEnabled` | boolean | No | Whether to apply Cohere reranking to vector search results |
| `rerankerModel` | string | No | Cohere rerank model to use \(one of: rerank-v4.0-pro, rerank-v4.0-fast, rerank-v3.5\) |
| `tagFilters` | string | No | No description |

#### Output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ export const POST = withRouteHandler(

let cost = null
try {
cost = calculateCost('text-embedding-3-small', newChunk.tokenCount, 0, false)
cost = calculateCost(
accessCheck.knowledgeBase.embeddingModel,
newChunk.tokenCount,
0,
false
)
} catch (error) {
logger.warn(`[${requestId}] Failed to calculate cost for chunk upload`, {
error: error instanceof Error ? error.message : 'Unknown error',
Expand All @@ -240,7 +245,7 @@ export const POST = withRouteHandler(
completion: 0,
total: newChunk.tokenCount,
},
model: 'text-embedding-3-small',
model: accessCheck.knowledgeBase.embeddingModel,
pricing: cost.pricing,
},
}
Expand Down
2 changes: 0 additions & 2 deletions apps/sim/app/api/knowledge/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const logger = createLogger('KnowledgeBaseByIdAPI')
const UpdateKnowledgeBaseSchema = z.object({
name: z.string().min(1, 'Name is required').optional(),
description: z.string().optional(),
embeddingModel: z.literal('text-embedding-3-small').optional(),
embeddingDimension: z.literal(1536).optional(),
workspaceId: z.string().nullable().optional(),
chunkingConfig: z
.object({
Expand Down
11 changes: 7 additions & 4 deletions apps/sim/app/api/knowledge/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getSession } from '@/lib/auth'
import { PlatformEvents } from '@/lib/core/telemetry'
import { generateRequestId } from '@/lib/core/utils/request'
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
import { EMBEDDING_DIMENSIONS, getConfiguredEmbeddingModel } from '@/lib/knowledge/embeddings'
import {
createKnowledgeBase,
getKnowledgeBases,
Expand All @@ -20,8 +21,6 @@ const CreateKnowledgeBaseSchema = z.object({
name: z.string().min(1, 'Name is required'),
description: z.string().optional(),
workspaceId: z.string().min(1, 'Workspace ID is required'),
embeddingModel: z.literal('text-embedding-3-small').default('text-embedding-3-small'),
embeddingDimension: z.literal(1536).default(1536),
chunkingConfig: z
.object({
maxSize: z.number().min(100).max(4000).default(1024),
Expand Down Expand Up @@ -118,9 +117,13 @@ export const POST = withRouteHandler(async (req: NextRequest) => {
try {
const validatedData = CreateKnowledgeBaseSchema.parse(body)

const embeddingModel = getConfiguredEmbeddingModel()

const createData = {
...validatedData,
userId: session.user.id,
embeddingModel,
embeddingDimension: EMBEDDING_DIMENSIONS,
}

const newKnowledgeBase = await createKnowledgeBase(createData, requestId)
Expand Down Expand Up @@ -166,8 +169,8 @@ export const POST = withRouteHandler(async (req: NextRequest) => {
metadata: {
name: validatedData.name,
description: validatedData.description,
embeddingModel: validatedData.embeddingModel,
embeddingDimension: validatedData.embeddingDimension,
embeddingModel,
embeddingDimension: EMBEDDING_DIMENSIONS,
chunkingStrategy: validatedData.chunkingConfig.strategy,
chunkMaxSize: validatedData.chunkingConfig.maxSize,
chunkMinSize: validatedData.chunkingConfig.minSize,
Expand Down
15 changes: 14 additions & 1 deletion apps/sim/app/api/knowledge/search/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -524,6 +525,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -571,6 +573,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -625,6 +628,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -694,6 +698,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -739,6 +744,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -877,6 +883,7 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})

Expand Down Expand Up @@ -921,11 +928,17 @@ describe('Knowledge Search API Route', () => {
userId: 'user-123',
name: 'Test KB',
deletedAt: null,
embeddingModel: 'text-embedding-3-small',
},
})
.mockResolvedValueOnce({
hasAccess: true,
knowledgeBase: { id: 'kb-456', userId: 'user-123', name: 'Test KB 2' },
knowledgeBase: {
id: 'kb-456',
userId: 'user-123',
name: 'Test KB 2',
embeddingModel: 'text-embedding-3-small',
},
})

mockGetDocumentTagDefinitions.mockResolvedValue(mockTagDefinitions)
Expand Down
Loading
Loading