Skip to content

Phase A: provider catalog covering 18 OpenAI-compatible providers + Anthropic - #40

Merged
FMXExpress merged 1 commit into
mainfrom
claude/pr38-provider-catalog
May 28, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/pr38-provider-catalog

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Replaces the hardcoded anthropic / openai-compat if-else in Factory.NewProviderFromConfig with a catalog table that lights up 18 OpenAI-compatible providers immediately — most of picoclaw's 23+ supported providers actually speak OpenAI Chat Completions, just at a different base URL.

After this PR, adding another OpenAI-compatible provider is a one-row catalog entry — no new code.

New unit: PasClaw.Providers.Catalog

TProtocolFamily = (pfOpenAI, pfAnthropic, pfPlaceholder);
TAuthSchemeKind = (asBearer, asNone, asHeader);
TAuthScheme     = record Kind: TAuthSchemeKind; HeaderName: string; end;
TProviderSpec   = record Kind, DisplayName, DefaultBase, DefaultModel, Notes: string;
                         Family: TProtocolFamily; Auth: TAuthScheme; end;

function LookupProvider(const Kind: string; out Spec: TProviderSpec): Boolean;
function AllProviderSpecs: TProviderSpecArray;   { sorted by display name }
function DefaultBaseFor(const Kind: string): string;

19 catalog rows ship in this PR:

Kind Family Default base Default model Auth
anthropic pfAnthropic api.anthropic.com claude-opus-4-7 x-api-key
openai pfOpenAI api.openai.com gpt-4o-mini Bearer
openrouter pfOpenAI openrouter.ai/api (user picks) Bearer
zhipu pfOpenAI open.bigmodel.cn glm-4 Bearer
deepseek pfOpenAI api.deepseek.com deepseek-chat Bearer
volcengine pfOpenAI ark.cn-beijing.volces.com (user picks) Bearer
qwen pfOpenAI dashscope.aliyuncs.com qwen-max Bearer
groq pfOpenAI api.groq.com/openai (user picks) Bearer
moonshot pfOpenAI api.moonshot.cn moonshot-v1-32k Bearer
minimax pfOpenAI api.minimax.chat (user picks) Bearer
mistral pfOpenAI api.mistral.ai mistral-large-latest Bearer
nvidia pfOpenAI integrate.api.nvidia.com (user picks) Bearer
cerebras pfOpenAI api.cerebras.ai (user picks) Bearer
novita pfOpenAI api.novita.ai (user picks) Bearer
mimo pfOpenAI (user-configured) (user picks) Bearer
ollama pfOpenAI localhost:11434 (user picks) none
vllm pfOpenAI localhost:8000 (user picks) none
litellm pfOpenAI (user-configured) (user picks) Bearer
gemini pfPlaceholder generativelanguage.googleapis.com gemini-1.5-flash (returns clear error until Phase B lands)

Modified

  • TOpenAIProvider — overloaded constructor accepts TAuthScheme + a display name. Existing 3-arg constructor forwards with asBearer / 'openai' so every existing call site is byte-identical. BuildAuthHeaders centralizes the auth-header construction; logs now show e.g. groq POST ... instead of openai POST ... for a Groq config.
  • Factory.NewProviderFromConfig — looks up the kind in the catalog, falls back to catalog defaults for empty APIBase / Model, dispatches on Family. pfPlaceholder kinds return a clear "implementation not yet bundled" error.
  • Cmd.Onboard — replaces the anthropic/openai prompt with a numbered list from AllProviderSpecs. Selection writes a TProviderConfig populated from the catalog. The API key prompt is skipped for asNone providers (Ollama, vLLM).
  • PasClaw.dproj — new unit added to DCCReference. FPC Makefile UNIT_DIRS already covers src/pkg/providers, no change needed there.

Deferred to follow-up PRs

Each follow-up adds one new TProtocolFamily enum value + one new case branch in Factory. Wiring stays the same.

  • Gemini — TGeminiProvider for the generateContent REST shape (~300 LOC).
  • AWS Bedrock — SigV4 signing + per-model schemas; build-tag gated like picoclaw.
  • Azure OpenAI — asHeader is already reserved; needs path quirks (deployment-id, api-version query).
  • GitHub Copilot — OAuth device flow.
  • Antigravity — Google Cloud OAuth.

Test plan

  • FPC build (make) and Delphi .dproj both build cleanly with the new unit
  • Existing anthropic / openai configs work unchanged (pasclaw agent "hi") — regression check on the factory refactor
  • Hand-edit ~/.pasclaw/config.json with kind: "groq" + an API key; pasclaw status lists it; pasclaw agent "hi" round-trips through Groq
  • Same drill with kind: "deepseek", kind: "openrouter"
  • pasclaw onboard shows the numbered list, accepts a pick, writes the right APIBase from the catalog
  • Onboarding ollama doesn't prompt for an API key (asNone); a chat call to a local Ollama endpoint sends no Authorization header
  • pasclaw agent "hi" against a kind: "gemini" entry returns the documented "not yet bundled" error rather than crashing

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

…nthropic

The CLI's previous if/else over Kind only covered anthropic and a loose
openai-compat family (openai/groq/together/ollama). Picoclaw supports
23+ providers via uniform protocol/model config, and most of those
providers actually speak OpenAI Chat Completions with just a different
base URL — so they fit the existing TOpenAIProvider implementation
once it can pick its auth header and surface its real name.

New unit src/pkg/providers/PasClaw.Providers.Catalog.pas:

  TProtocolFamily   pfOpenAI / pfAnthropic / pfPlaceholder (reserved
                    for Gemini/Bedrock/etc. follow-up PRs).
  TAuthScheme       asBearer (default) / asNone (Ollama, vLLM) /
                    asHeader (carries a custom header name, reserved
                    for Azure's api-key style).
  TProviderSpec     Kind / DisplayName / Family / DefaultBase /
                    DefaultModel / Auth / Notes — one row per
                    provider.
  LookupProvider(Kind, out Spec): Boolean
  AllProviderSpecs: TProviderSpecArray (sorted by display name)
  DefaultBaseFor(Kind): string

Phase A catalog ships 19 entries: anthropic, openai, openrouter, zhipu,
deepseek, volcengine, qwen, groq, moonshot, minimax, mistral, nvidia,
cerebras, novita, mimo, ollama, vllm, litellm, and a pfPlaceholder
gemini row so the kind is reserved.

TOpenAIProvider gets an overloaded constructor that accepts a
TAuthScheme + DisplayName. BuildAuthHeaders centralizes header
construction:

  asBearer -> Authorization: Bearer <key>  (skipped if key empty,
                                            so a misconfigured local
                                            still works)
  asNone   -> no auth header at all
  asHeader -> single header named TAuthScheme.HeaderName carrying the
              key verbatim

The existing 3-arg constructor still works — it forwards to the new
one with asBearer + 'openai', so every existing call site is
byte-identical. GetName returns the configured display name so logs
show 'groq POST ...' instead of 'openai POST ...' for a Groq config.

PasClaw.Providers.Factory now looks the kind up via the catalog and
case-dispatches on Family. Empty Cfg.APIBase / Cfg.Model fall back to
the catalog's defaults so a freshly-onboarded provider works with no
manual fields. pfPlaceholder kinds return a clear "implementation not
bundled yet" error.

PasClaw.Cmd.Onboard replaces the anthropic/openai prompt with a
numbered list from AllProviderSpecs. Selection writes a TProviderConfig
populated from the catalog (Kind, APIBase, default Model). The API
key prompt is skipped entirely for asNone providers (Ollama, vLLM).
Existing config gets updated in place — no schema migration.

PasClaw.dproj gets the new unit added in DCCReference order between
HTTP and Anthropic. FPC's Makefile UNIT_DIRS already includes
src/pkg/providers, so no Makefile change is needed.

Deferred to follow-up PRs (each gets its own implementation, slots
into the existing case-dispatch with one new enum value):
  - Gemini (pfGemini) — generateContent REST shape
  - AWS Bedrock — SigV4 signing + per-model schemas, build-tag gated
  - Azure OpenAI — api-key auth + deployment path quirks
  - GitHub Copilot — OAuth device-code flow
  - Antigravity — Google Cloud OAuth

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress merged commit 7ae33dd into main May 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fcfdde6ee4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Kind := LowerCase(Cfg.Providers[Idx].Kind);
if Kind = '' then Kind := LowerCase(Cfg.Providers[Idx].Name);

if not LookupProvider(Kind, Spec) then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the openai-compat alias

Existing configs that use the previously supported kind of openai-compat now fail this lookup and return “unsupported provider kind”, even though they can still be routed through TOpenAIProvider. This affects users with custom OpenAI-compatible endpoints configured before the catalog change; add an alias/catalog entry or normalize openai-compat to the OpenAI-compatible family before rejecting it.

Useful? React with 👍 / 👎.

Comment on lines +155 to +156
Model := ReadLineEcho('Default model (provider does not advertise one — required): ');
if Trim(Model) = '' then Model := Spec.DefaultModel;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require a model when no catalog default exists

For providers whose catalog DefaultModel is empty, this “required” prompt still accepts a blank response and saves no model; later TOpenAIProvider.Create substitutes gpt-4o-mini, so selecting Groq/OpenRouter/Ollama/etc. with a blank model sends an OpenAI model name to that provider instead of stopping for a valid model. Reject blank input here when Spec.DefaultModel = '' or avoid falling back to the OpenAI default for catalog-backed providers.

Useful? React with 👍 / 👎.

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