Add Composio OpenAI embedding provider#1239
Open
Antman316 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new embedding provider that routes OpenAI embedding requests through the Composio CLI, including recipe registration, dimensions validation, and an end-to-end Bun test.
Changes:
- Introduces a
composio-openairecipe + implementation type and registers it in the recipes index. - Extends the AI gateway to execute
COMPOSIO_CLIfor embeddings and parse Composio’s output envelope. - Adds
dimsProviderOptionssupport and a Bun test covering availability + embedding output parsing.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ai/composio-openai-embedding.test.ts | Adds integration-style test using a fake Composio CLI script to validate availability and embedding parsing. |
| src/core/ai/types.ts | Extends the Implementation union to include composio-openai. |
| src/core/ai/recipes/index.ts | Registers the new composioOpenAI recipe. |
| src/core/ai/recipes/composio-openai.ts | Defines Composio OpenAI embedding recipe metadata and declared models. |
| src/core/ai/gateway.ts | Implements Composio CLI embedding execution, envelope parsing, and wiring into embedSubBatch. |
| src/core/ai/dims.ts | Adds dimension validation/options behavior for composio-openai embedding models. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+996
to
+1005
| function parseComposioEnvelope(stdout: string): any { | ||
| const firstJson = stdout.indexOf('{'); | ||
| if (firstJson < 0) { | ||
| throw new AIConfigError( | ||
| `Composio CLI returned no JSON envelope.`, | ||
| `Check COMPOSIO_CLI and run \`$COMPOSIO_CLI whoami\`.`, | ||
| ); | ||
| } | ||
| const envelope = JSON.parse(stdout.slice(firstJson)); | ||
| if (!envelope.successful) { |
Comment on lines
+1041
to
+1056
| const proc = Bun.spawn([ | ||
| composioCli, | ||
| 'execute', | ||
| 'OPENAI_CREATE_EMBEDDINGS', | ||
| '-d', | ||
| JSON.stringify({ | ||
| model: modelId, | ||
| input: texts, | ||
| dimensions: expectedDims, | ||
| encoding_format: 'float', | ||
| }), | ||
| ], { | ||
| stdout: 'pipe', | ||
| stderr: 'pipe', | ||
| env, | ||
| }); |
| models: ['text-embedding-3-large', 'text-embedding-3-small'], | ||
| default_dims: 1536, | ||
| dims_options: [256, 512, 768, 1024, 1536, 3072], | ||
| cost_per_1m_tokens_usd: 0.13, |
Comment on lines
+189
to
190
| const COMPOSIO_EMBEDDING_BATCH_SIZE = 20; | ||
|
|
Comment on lines
+1365
to
+1369
| if (recipe.implementation === 'composio-openai') { | ||
| const embeddings = await embedComposioOpenAI(texts, model, expectedDims); | ||
| recordSubBatchSuccess(recipe); | ||
| return embeddings; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
composio-openaiembedding providerOPENAI_CREATE_EMBEDDINGSwithout requiring localOPENAI_API_KEYVerification
/opt/homebrew/bin/bun test test/ai/composio-openai-embedding.test.ts/opt/homebrew/bin/bun test test/ai/gateway.test.ts test/ai/adaptive-embed-batch.test.ts test/ai/recipes-existing-regression.test.ts test/ai/composio-openai-embedding.test.ts/opt/homebrew/bin/bun run typecheckNotes
This keeps raw OpenAI keys inside Composio and lets local gbrain workflows use
COMPOSIO_CLIplusembedding_model: composio-openai:text-embedding-3-small|large.