Skip to content

Commit ca35ea0

Browse files
fix(embeddings): preserve legacy provider default
1 parent 58a9cb5 commit ca35ea0

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

apps/sim/blocks/blocks.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,17 @@ describe.concurrent('Blocks Module', () => {
899899
// Each provider routes to its own registered tool...
900900
const toolId = block?.tools.config?.tool?.({ provider })
901901
expect(block?.tools.access).toContain(toolId)
902-
// ...and has a model dropdown with at least one option.
902+
// ...and has either a static model list or a dynamic model loader.
903903
const modelSubBlock = block?.subBlocks.find(
904904
(sb) => sb.id === 'model' && sb.condition?.value === provider
905905
)
906-
expect(
907-
Array.isArray(modelSubBlock?.options) ? modelSubBlock.options.length : 0
908-
).toBeGreaterThan(0)
906+
if (provider === 'openrouter') {
907+
expect(modelSubBlock?.fetchOptions).toBeTypeOf('function')
908+
} else {
909+
expect(
910+
Array.isArray(modelSubBlock?.options) ? modelSubBlock.options.length : 0
911+
).toBeGreaterThan(0)
912+
}
909913
}
910914
})
911915

apps/sim/blocks/blocks/embeddings.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ describe('Embeddings block', () => {
146146
expect(EmbeddingsBlock.tools.config?.tool?.({ provider })).toBe(toolId)
147147
}
148148
expect(EmbeddingsBlock.tools.access).toHaveLength(Object.keys(TOOL_ID_BY_PROVIDER).length)
149+
expect(EmbeddingsBlock.tools.config?.tool?.({})).toBe('embeddings_openai')
150+
expect(() => EmbeddingsBlock.tools.config?.tool?.({ provider: 'unknown' })).toThrow(
151+
'Unsupported embedding provider: unknown'
152+
)
149153
})
150154

151155
it('loads every OpenRouter embedding model and maps its dedicated key', async () => {

apps/sim/blocks/blocks/embeddings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export const EmbeddingsBlock: BlockConfig<EmbeddingsResponse> = {
209209
* `<Block.output>` references.
210210
*/
211211
tool: (params) => {
212-
const provider = params.provider as EmbeddingBlockProvider
212+
const provider = (params.provider as EmbeddingBlockProvider | undefined) ?? 'openai'
213213
const toolId = TOOL_ID_BY_PROVIDER[provider]
214214
if (!toolId) throw new Error(`Unsupported embedding provider: ${String(params.provider)}`)
215215
return toolId

0 commit comments

Comments
 (0)