Implement remaining OpenAI-compatible AI stubs#478
Conversation
Greptile SummaryThis PR promotes five AI adapter stubs (Cohere, Kimi/Moonshot, NovitaAI, Parasail, Venice) to full OpenAI-compatible implementations, and adds a
Confidence Score: 4/5The five adapter implementations are correct and safe to ship; the config-merge fix has one gap in When an adapter has never been configured, packages/core/src/setup.ts — the Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant tokenSetup
participant runSetup
participant mergeAdapterConfig
participant ConfigStore
participant generate
User->>tokenSetup: run setup (first time, leave baseUrl blank)
tokenSetup->>tokenSetup: "configExtras['baseUrl'] = ''"
tokenSetup-->>runSetup: "{ ok: true, config: { baseUrl: '' } }"
runSetup->>ConfigStore: getAdapterConfig(adapter.id)
ConfigStore-->>runSetup: undefined (no prior config)
runSetup->>mergeAdapterConfig: "mergeAdapterConfig(undefined, { baseUrl: '' })"
Note over mergeAdapterConfig: isPlainRecord(undefined) → false<br/>early-return: returns next as-is
mergeAdapterConfig-->>runSetup: "{ baseUrl: '' }"
runSetup->>ConfigStore: "setAdapterConfig(id, { baseUrl: '' })"
User->>generate: generate(ctx, prompt, opts, config)
Note over generate: config.baseUrl = ''<br/>'' ?? DEFAULT_BASE = ''
generate->>generate: chatCompletionsUrl('') → '/v1/chat/completions'
generate->>generate: fetch('/v1/chat/completions') → TypeError: Invalid URL ❌
Reviews (3): Last reviewed commit: "fix(setup): allow clearing optional setu..." | Re-trigger Greptile |
| function chatCompletionsUrl(baseUrl: string): string { | ||
| const base = baseUrl.replace(/\/+$/, ''); | ||
| return base.endsWith('/v1') ? `${base}/chat/completions` : `${base}/v1/chat/completions`; | ||
| } |
There was a problem hiding this comment.
chatCompletionsUrl duplicated verbatim in all five adapters
The exact same function is copy-pasted into cohere, kimi, novita, parasail, and venice. Any future fix must be applied in five places. Extracting it once into @profullstack/sh1pt-core alongside the existing tokenSetup / defineAi exports would make it reusable and keep these thin adapters truly thin.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Addressed the Greptile setup-config concern in 4185190: runSetup now merges a returned plain-object setup config over any existing adapter config before saving, so tokenSetup/webhookSetup reuse paths no longer wipe previously stored non-secret fields like baseUrl. I also kept the provider-doc follow-up (Cohere current compatibility model and Parasail max_completion_tokens mapping). |
|
Addressed the latest Greptile note in 6a8c517: tokenSetup now returns an explicit empty string for blank non-secret optional fields, and runSetup treats that as a delete marker when merging adapter config. Reuse still returns an empty config object and preserves existing values, while a fresh re-run with blank baseUrl now clears the override and falls back to provider defaults as prompted. |
Implements the remaining OpenAI-compatible AI stubs from #450:
Each adapter now:
/v1/chat/completionsmaxTokens,temperature, andopts.extraVerification:
packages/ai/openai/src/index.ts