Skip to content

Add Composio OpenAI embedding provider#1239

Open
Antman316 wants to merge 1 commit into
garrytan:masterfrom
Antman316:codex/composio-openai-embeddings
Open

Add Composio OpenAI embedding provider#1239
Antman316 wants to merge 1 commit into
garrytan:masterfrom
Antman316:codex/composio-openai-embeddings

Conversation

@Antman316
Copy link
Copy Markdown

Summary

  • add a first-class composio-openai embedding provider
  • route embeddings through Composio CLI OPENAI_CREATE_EMBEDDINGS without requiring local OPENAI_API_KEY
  • register the provider recipe and dimensions handling
  • add regression coverage for availability and embedding via a fake Composio CLI

Verification

  • /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 typecheck

Notes

This keeps raw OpenAI keys inside Composio and lets local gbrain workflows use COMPOSIO_CLI plus embedding_model: composio-openai:text-embedding-3-small|large.

Copilot AI review requested due to automatic review settings May 20, 2026 19:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-openai recipe + implementation type and registers it in the recipes index.
  • Extends the AI gateway to execute COMPOSIO_CLI for embeddings and parse Composio’s output envelope.
  • Adds dimsProviderOptions support 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 thread src/core/ai/gateway.ts
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 thread src/core/ai/gateway.ts
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 thread src/core/ai/gateway.ts
Comment on lines +189 to 190
const COMPOSIO_EMBEDDING_BATCH_SIZE = 20;

Comment thread src/core/ai/gateway.ts
Comment on lines +1365 to +1369
if (recipe.implementation === 'composio-openai') {
const embeddings = await embedComposioOpenAI(texts, model, expectedDims);
recordSubBatchSuccess(recipe);
return embeddings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants