Add Baidu Qianfan (ERNIE) as a supported model provider - #94
Merged
Conversation
Wires up "baidu" end-to-end alongside openai/openrouter/moonshot/zai, modeled on invokeMoonshot since Qianfan's v2 endpoint is OpenAI-compatible: - src/config/index.js: BAIDU_API_KEY/BAIDU_ENDPOINT/BAIDU_MODEL parsing, config.baidu block, SUPPORTED_MODEL_PROVIDERS entry, hot-reload sync - src/clients/databricks.js: new invokeBaidu (request conversion via openrouter-utils, response converted to Anthropic shape locally), registered in PROVIDER_INVOKERS - src/orchestrator/index.js: destination-url, tool-schema, and response-conversion branches for "baidu" - src/routing/model-tiers.js: baidu case in _getProviderModel - src/api/providers-handler.js, src/api/openai-router.js: discovery listing - bin/lynkr-init.js: onboarding wizard entry + PROVIDER_ORDER + baseline env - .env.example, documentation/providers.md: new provider docs/section - test/baidu-model-mapping.test.js: model mapping, tool conversion, auth, response conversion (mirrors moonshot-model-mapping.test.js) - test/dispatch-registry.test.js, test/init.test.js: anti-drift guard lists - package.json: wire new test file into test:unit Not yet done, flagged in code/docs: sampling-param quirks and the exact ERNIE model roster are best-effort from public docs, not probed against a live key; "baidu" is not yet in DEFAULT_OPENAI_SSE_PROVIDERS (streaming is buffered-only until SSE shape is confirmed); not added to REASONING_CONTENT_PROVIDERS (unconfirmed whether ERNIE reasoning models emit reasoning_content). All 1267 existing unit tests plus the new baidu suite pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Follow-up to 57959c0. Only these three rows + the cloud-provider count are touched — README already had unrelated pending edits (OAuth/wrap-mode policy note) in the working tree that are intentionally left unstaged, they're not part of this branch's scope. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The "Web Tools Test Suite" check has been failing on every PR/push that touches its trigger paths (including src/config/index.js, which this branch's Baidu changes touch) since commit b32e988 deleted src/tools/web.js, src/tools/web-client.js, and test/web-tools.test.js without removing the standalone workflow that ran that test file — this predates and is unrelated to the Baidu provider work, confirmed failing on main itself and on PR #90/#91 too (`gh run list --workflow web-tools-tests.yml`). - Remove .github/workflows/web-tools-tests.yml (nothing left to test) - Remove the same two stale file refs (test/web-tools.test.js, test/code-mode.test.js — deleted in the same commit) from ci.yml's "Tests" job. These didn't fail there since node --test silently skips a missing file when given alongside other real ones in one invocation, but a passing check that silently means "0 tests ran for this file" is a gap worth closing, not a reference worth keeping. - Update workflows/README.md: drop the Web Tools Tests section, renumber remaining sections, drop the dead badge/example command. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
baidu(Baidu Qianfan / ERNIE) as a supported model provider, wired up end-to-end the same way asopenai/openrouter/moonshot/zai. Qianfan's v2 endpoint is OpenAI-Chat-Completions-compatible, soinvokeBaiduis modeled closely oninvokeMoonshot: request-side conversion reuses the sharedopenrouter-utils.jsconverters, and the response is converted to Anthropic shape locally so the orchestrator branch is a plain passthrough.Changes
src/config/index.js—BAIDU_API_KEY/BAIDU_ENDPOINT/BAIDU_MODELparsing,config.baidublock, added toSUPPORTED_MODEL_PROVIDERS, hot-reload syncsrc/clients/databricks.js— newinvokeBaidu, registered inPROVIDER_INVOKERS, exportedsrc/orchestrator/index.js— destination-url, tool-schema, and response-conversion branches forbaidusrc/routing/model-tiers.js—baiducase in_getProviderModelsoTIER_*=baidu:...resolvessrc/api/providers-handler.js,src/api/openai-router.js— discovery-listing entriesbin/lynkr-init.js— onboarding wizard entry,PROVIDER_ORDER, baseline.envdefaults.env.example,documentation/providers.md(new §12),README.md— provider docstest/baidu-model-mapping.test.js(new, 14 tests) — model mapping, tool conversion, auth, response conversion, mirrorsmoonshot-model-mapping.test.jstest/dispatch-registry.test.js,test/init.test.js— updated the hardcoded anti-drift guard listspackage.json— wired the new test file intotest:unitKnown gaps (flagged in code comments, not yet resolved)
baiduis not yet inDEFAULT_OPENAI_SSE_PROVIDERS(sse-transformer.js) — requests are buffered-only until Qianfan's SSE shape is confirmed to match OpenAI's.REASONING_CONTENT_PROVIDERS— unconfirmed whetherernie-x1.1emitsreasoning_contentthe same way Moonshot/OpenAI do.ernie-4.5-turbo-128k,ernie-x1.1,ernie-speed-8k) and defaulttemperature/top_pare best-effort from public docs, not yet probed against a liveBAIDU_API_KEY. Moonshot hit a real landmine here (kimi-k* models reject anytemperatureother than exactly1) — Baidu may have similar undocumented constraints that only surface on first live call.Testing
baidu-model-mapping.test.jssuite.🤖 Generated with Claude Code