Skip to content

Commit 9f976b6

Browse files
committed
fix(embeddings): declare the outputs the legacy openai block returns
openai_embeddings became an alias of embeddings_openai, so the legacy block's runtime payload gained `provider` and `dimensions`. Its declared outputs still listed only embeddings/model/usage, so the tag picker never offered two fields every run demonstrably returns, and downstream blocks could not reference them. Declaring them is additive and does not touch execution. Asserts the legacy block's output keys match the replacement's, since both run the same tool and neither should expose fields the other lacks.
1 parent 0a0f41b commit 9f976b6

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

apps/sim/blocks/blocks.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,37 @@ describe.concurrent('Blocks Module', () => {
849849
expect(replacement?.hideFromToolbar).not.toBe(true)
850850
})
851851

852+
/**
853+
* `openai_embeddings` is an alias of `embeddings_openai`, so the legacy
854+
* block's runtime payload gained `provider` and `dimensions`. Undeclared,
855+
* they were absent from the tag picker and unreferenceable downstream even
856+
* though every run returned them.
857+
*/
858+
it('should declare every output the legacy openai block returns at runtime', () => {
859+
const legacy = getBlock('openai')
860+
const replacement = getBlock('embeddings')
861+
862+
expect(Object.keys(legacy?.outputs ?? {}).sort()).toEqual([
863+
'dimensions',
864+
'embeddings',
865+
'model',
866+
'provider',
867+
'usage',
868+
])
869+
expect(legacy?.outputs?.provider).toEqual({
870+
type: 'string',
871+
description: 'Provider used',
872+
})
873+
expect(legacy?.outputs?.dimensions).toEqual({
874+
type: 'number',
875+
description: 'Dimensionality of each vector',
876+
})
877+
// Both blocks run the same tool, so neither may expose fields the other lacks.
878+
expect(Object.keys(legacy?.outputs ?? {}).sort()).toEqual(
879+
Object.keys(replacement?.outputs ?? {}).sort()
880+
)
881+
})
882+
852883
it('should offer every embeddings provider with a matching tool and model list', () => {
853884
const block = getBlock('embeddings')
854885
const providerSubBlock = block?.subBlocks.find((sb) => sb.id === 'provider')

apps/sim/blocks/blocks/openai.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export const OpenAIBlock: BlockConfig = {
5959
outputs: {
6060
embeddings: { type: 'json', description: 'Generated embeddings' },
6161
model: { type: 'string', description: 'Model used' },
62+
/**
63+
* `openai_embeddings` is an alias of `embeddings_openai`, so the runtime
64+
* payload gained these two. Declaring them is purely additive — it does not
65+
* change execution, and without it the tag picker cannot offer fields the
66+
* block demonstrably returns.
67+
*/
68+
provider: { type: 'string', description: 'Provider used' },
69+
dimensions: { type: 'number', description: 'Dimensionality of each vector' },
6270
usage: { type: 'json', description: 'Token usage' },
6371
},
6472
}

0 commit comments

Comments
 (0)