Skip to content

docs/examples: add a minimal Qianfan onboarding example#3433

Closed
jimmyzhuu wants to merge 1 commit into
openai:mainfrom
jimmyzhuu:feat/qianfan-onboarding-example
Closed

docs/examples: add a minimal Qianfan onboarding example#3433
jimmyzhuu wants to merge 1 commit into
openai:mainfrom
jimmyzhuu:feat/qianfan-onboarding-example

Conversation

@jimmyzhuu
Copy link
Copy Markdown

Summary

This PR adds a small, built-in OpenAI-compatible onboarding path for Baidu Qianfan without introducing any new provider abstraction.

Changes in scope:

  • adds 1 new example: examples/model_providers/qianfan_provider.py
  • adds 1 focused test module: tests/test_qianfan_model_provider_example.py
  • adds 1 example discovery assertion in tests/test_run_examples_script.py
  • updates 2 existing documentation entry points:
    • examples/model_providers/README.md
    • docs/models/index.md

What the example does:

  • configures AsyncOpenAI against Qianfan's OpenAI-compatible base URL
  • uses set_default_openai_client(...)
  • uses the Chat Completions path via set_default_openai_api("chat_completions")
  • demonstrates one minimal function tool call
  • exits safely with a skip message when QIANFAN_API_KEY is not set

Why this shape:

  • it stays within the repository's existing "non-OpenAI models" integration patterns
  • it keeps the first Qianfan-facing change reviewable and low-risk
  • it avoids introducing a vendor-specific abstraction for a single provider example

Validation notes:

  • the Qianfan onboarding path in this PR was validated locally against ernie-5.0
  • baseline chat and function tool calling both succeeded on the OpenAI-compatible Chat Completions path
  • the example and tests remain CI-safe because automated coverage does not require external credentials
  • this PR focuses on the provider path that was validated end-to-end for onboarding

Non-goals:

  • no LiteLLM or any-llm routing changes
  • no top-level README changes
  • no translation updates
  • no network-dependent test coverage in CI

Test plan

Automated local verification:

uv run pytest tests/test_qianfan_model_provider_example.py tests/test_run_examples_script.py::test_discover_examples_finds_qianfan_provider -v

Result:

  • 3 targeted checks passed
  • verified default Qianfan settings loading
  • verified the no-credential safe-exit path
  • verified that the new example is discoverable by the example runner

Credentialed provider validation against Qianfan's OpenAI-compatible endpoint:

  • listed accessible models for the provided account and confirmed the validated model ID is ernie-5.0
  • ran a live smoke test against ernie-5.0
  • verified baseline chat succeeds
  • verified function tool calling succeeds

Example safety check without credentials:

uv run python -m examples.model_providers.qianfan_provider

Result:

  • prints Skipping run because no valid QIANFAN_API_KEY was provided.
  • exits successfully without attempting a provider call

Formatting and linting:

make format
make lint

Result:

  • formatting completed successfully
  • lint checks passed

Docs verification:

make build-docs

Result:

  • docs build completed successfully
  • no docs errors were introduced by the Qianfan example/docs changes

Issue number

N/A

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@seratch
Copy link
Copy Markdown
Member

seratch commented May 17, 2026

Thanks for sharing this. While we won't have this in this repo, please feel free to share it in your own repo or resources.

@seratch seratch closed this May 17, 2026
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