[codex] Implement remaining OpenAI-compatible AI adapters#451
[codex] Implement remaining OpenAI-compatible AI adapters#451ifanatics-media wants to merge 1 commit into
Conversation
Greptile SummaryThis PR replaces five AI adapter stubs (Kimi, Cohere, NovitaAI, Venice, Parasail) with real OpenAI-compatible chat-completions implementations, following the same pattern already established by the Groq adapter. Accompanying focused test suites cover dry-run short-circuiting, request shape, response mapping, and error surfacing for each adapter.
Confidence Score: 4/5Safe to merge; the five adapters follow an identical, well-tested pattern already established by the Groq adapter. The implementations are clean and the test suites are thorough. The one notable design point is that All five Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Adapter as AI Adapter
participant Vault as ctx.secret()
participant Provider as Provider API
Caller->>Adapter: generate(ctx, prompt, opts, config)
Adapter->>Vault: secret('PROVIDER_API_KEY')
Vault-->>Adapter: apiKey (or throws if missing)
alt ctx.dryRun
Adapter-->>Caller: "{ text: '[dry-run]', model }"
else
Adapter->>Provider: POST /chat/completions
alt res.ok
Provider-->>Adapter: "{ choices, model, usage }"
Adapter-->>Caller: "{ text, model, inputTokens?, outputTokens? }"
else
Provider-->>Adapter: HTTP error
Adapter-->>Caller: "throws Error("Provider {status}: {excerpt}")"
end
end
Reviews (1): Last reviewed commit: "Implement remaining OpenAI-compatible AI..." | Re-trigger Greptile |
| body: JSON.stringify({ | ||
| model, | ||
| messages, | ||
| ...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}), | ||
| ...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}), | ||
| ...opts.extra, | ||
| }), |
There was a problem hiding this comment.
opts.extra is spread last, so any key it contains — including model, messages, max_tokens, or temperature — silently overrides the values the adapter already constructed. For instance, opts.extra = { messages: [] } would wipe out the system + user messages before the request is sent. The same pattern exists across all five new adapters. Consider spreading opts.extra before the explicit fields, or documenting that callers must not shadow these keys.
| body: JSON.stringify({ | |
| model, | |
| messages, | |
| ...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}), | |
| ...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}), | |
| ...opts.extra, | |
| }), | |
| body: JSON.stringify({ | |
| ...opts.extra, | |
| model, | |
| messages, | |
| ...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}), | |
| ...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}), | |
| }), |
Summary
opts.extraCloses #450.
Sources checked
Validation
./node_modules/.bin/vitest.cmd run packages/ai/kimi/src/index.test.ts packages/ai/cohere/src/index.test.ts packages/ai/novita/src/index.test.ts packages/ai/venice/src/index.test.ts packages/ai/parasail/src/index.test.ts./node_modules/.bin/tsc.cmd -p packages/ai/kimi/tsconfig.json --noEmit./node_modules/.bin/tsc.cmd -p packages/ai/cohere/tsconfig.json --noEmit./node_modules/.bin/tsc.cmd -p packages/ai/novita/tsconfig.json --noEmit./node_modules/.bin/tsc.cmd -p packages/ai/venice/tsconfig.json --noEmit./node_modules/.bin/tsc.cmd -p packages/ai/parasail/tsconfig.json --noEmitgit diff --check