Skip to content

[codex] Implement remaining OpenAI-compatible AI adapters#451

Open
ifanatics-media wants to merge 1 commit into
profullstack:masterfrom
ifanatics-media:codex/integrate-openai-compatible-ai-adapters
Open

[codex] Implement remaining OpenAI-compatible AI adapters#451
ifanatics-media wants to merge 1 commit into
profullstack:masterfrom
ifanatics-media:codex/integrate-openai-compatible-ai-adapters

Conversation

@ifanatics-media
Copy link
Copy Markdown

Summary

  • replace five AI adapter stubs (Kimi, Cohere, NovitaAI, Venice, Parasail) with OpenAI-compatible chat-completions implementations
  • preserve dry-run short-circuiting and pass through system/user messages, max token, temperature, and opts.extra
  • map provider response text/model/token usage and surface HTTP status/body excerpts on errors
  • add focused tests for dry-run, request shape, response mapping, and error handling for each adapter

Closes #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 --noEmit
  • git diff --check

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 27, 2026

Greptile Summary

This 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.

  • Each adapter reads its API key from the vault, builds a messages array, POSTs to the provider's /chat/completions endpoint, and maps the response's choices[0].message.content, model name, and token usage onto the shared return type.
  • The Parasail stub had a pre-existing corruption (using a URL as the secret key and model name); this PR correctly fixes those.
  • All five adapters share an identical structural pattern, keeping the codebase consistent and easy to audit.

Confidence Score: 4/5

Safe 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 opts.extra is spread after messages and model, so a caller can accidentally clobber those fields — but this is consistent with the existing Groq adapter and is unlikely to cause problems in practice. The Parasail stub corruption (secret key and model were both set to a URL) is cleanly fixed.

All five index.ts adapter files share the same ...opts.extra placement; pay attention if the extra API is ever exposed in public documentation so callers understand the override behaviour.

Important Files Changed

Filename Overview
packages/ai/kimi/src/index.ts Stub replaced with real Moonshot/Kimi chat-completions implementation; new default model kimi-k2.6 and expanded model list; consistent with Groq adapter pattern.
packages/ai/cohere/src/index.ts Stub replaced with Cohere compatibility API implementation; default model updated to command-a-plus-05-2026; baseUrl override supported.
packages/ai/novita/src/index.ts Stub replaced with NovitaAI chat-completions implementation; model list unchanged (single model); consistent implementation.
packages/ai/venice/src/index.ts Stub replaced with Venice AI chat-completions implementation; default model changed from llama-3.3-70b to venice-uncensored-1-2; supports Venice-specific venice_parameters via opts.extra.
packages/ai/parasail/src/index.ts Fixes corrupted stub (secret key and default model were both set to URL strings); correct PARASAIL_API_KEY secret and parasail-llama-33-70b-fp8 model now used.
packages/ai/kimi/src/index.test.ts Added dry-run, request-shape, response-mapping, and error-handling tests for the Kimi adapter; covers all main code paths.
packages/ai/cohere/src/index.test.ts Added comprehensive tests for Cohere adapter; request shape test verifies all passed opts including extra are forwarded correctly.
packages/ai/venice/src/index.test.ts Added comprehensive tests for Venice adapter; correctly exercises Venice-specific venice_parameters extension via opts.extra.

Sequence Diagram

sequenceDiagram
    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
Loading

Reviews (1): Last reviewed commit: "Implement remaining OpenAI-compatible AI..." | Re-trigger Greptile

Comment on lines +33 to +39
body: JSON.stringify({
model,
messages,
...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}),
...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}),
...opts.extra,
}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Suggested change
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 } : {}),
}),

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.

Implement OpenAI-compatible generation for remaining AI stubs

1 participant