Repository navigation
Phase A: provider catalog covering 18 OpenAI-compatible providers + Anthropic - #40
Conversation
…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
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 👍 / 👎.
| Model := ReadLineEcho('Default model (provider does not advertise one — required): '); | ||
| if Trim(Model) = '' then Model := Spec.DefaultModel; |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Replaces the hardcoded
anthropic/openai-compatif-else inFactory.NewProviderFromConfigwith 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.Catalog19 catalog rows ship in this PR:
Modified
TOpenAIProvider— overloaded constructor acceptsTAuthScheme+ a display name. Existing 3-arg constructor forwards withasBearer/'openai'so every existing call site is byte-identical.BuildAuthHeaderscentralizes the auth-header construction; logs now show e.g.groq POST ...instead ofopenai POST ...for a Groq config.Factory.NewProviderFromConfig— looks up the kind in the catalog, falls back to catalog defaults for emptyAPIBase/Model, dispatches onFamily.pfPlaceholderkinds return a clear "implementation not yet bundled" error.Cmd.Onboard— replaces the anthropic/openai prompt with a numbered list fromAllProviderSpecs. Selection writes aTProviderConfigpopulated from the catalog. The API key prompt is skipped forasNoneproviders (Ollama, vLLM).PasClaw.dproj— new unit added to DCCReference. FPCMakefileUNIT_DIRS already coverssrc/pkg/providers, no change needed there.Deferred to follow-up PRs
Each follow-up adds one new
TProtocolFamilyenum value + one newcasebranch inFactory. Wiring stays the same.TGeminiProviderfor thegenerateContentREST shape (~300 LOC).asHeaderis already reserved; needs path quirks (deployment-id, api-version query).Test plan
make) and Delphi.dprojboth build cleanly with the new unitanthropic/openaiconfigs work unchanged (pasclaw agent "hi") — regression check on the factory refactor~/.pasclaw/config.jsonwithkind: "groq"+ an API key;pasclaw statuslists it;pasclaw agent "hi"round-trips through Groqkind: "deepseek",kind: "openrouter"pasclaw onboardshows the numbered list, accepts a pick, writes the rightAPIBasefrom the catalogollamadoesn't prompt for an API key (asNone); a chat call to a local Ollama endpoint sends no Authorization headerpasclaw agent "hi"against akind: "gemini"entry returns the documented "not yet bundled" error rather than crashinghttps://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code