Skip to content

fix(openai_api_compatible): add provider_credential_schema for Knowledge Pipeline flow (#3682) - #3858

Closed
Taranum01 wants to merge 1 commit into
langgenius:mainfrom
Taranum01:fix/3682-provider-credential-schema-knowledge-pipeline
Closed

Taranum01 wants to merge 1 commit into
langgenius:mainfrom
Taranum01:fix/3682-provider-credential-schema-knowledge-pipeline

Conversation

@Taranum01

Copy link
Copy Markdown
Contributor

"Fixes #3682.\n\n## Problem\n\nConfiguring a credential for an OpenAI-API-compatible custom model in a Knowledge Pipeline failed with \"does not have provider_credential_schema\" \u2014 the form could not render and the user saw a red error toast.\n\nDify requires every provider used in a Knowledge Pipeline to declare a top-level provider_credential_schema so the authorization form can render. The OpenAI-API-compatible plugin only declared model_credential_schema, so the provider-level schema was missing. (Other configurable-model plugins like openai, anthropic, gemini, mistral, etc. all have it.)\n\n## Fix\n\nAdded the missing provider_credential_schema with the two universal fields every OpenAI-compatible server needs:\n\n| Field | Type | Required | Notes |\n| --- | --- | --- | --- |\n| api_key | secret-input | yes | The bearer token for the provider. |\n| endpoint_url | text-input | no | The OpenAI-compatible server URL. Empty falls back to the default OpenAI endpoint; set to point at LM Studio / vLLM / LiteLLM / etc. |\n\nThe model-level credential_form_schemas is preserved unchanged, so existing per-model configuration flows (LLM / Embedding / Rerank / Speech2Text / TTS) are not affected. The configurate_methods list still contains only customizable-model, so the global provider credential form is the only new entry point.\n\n## Tests\n\nmodels/openai_api_compatible/tests/test_provider_credential_schema.py (5 tests):\n\n- test_provider_yaml_declares_provider_credential_schema \u2014 the whole point of the fix.\n- test_provider_credential_form_has_api_key \u2014 pins type (secret-input), required flag, and bilingual label.\n- test_provider_credential_form_has_optional_endpoint_url \u2014 pins type (text-input), required flag = False.\n- test_model_credential_schema_preserved \u2014 guards against accidentally dropping the per-model schema during the refactor.\n- test_provider_yaml_round_trip \u2014 PyYAML safe_load round-trip, catches accidentally using !!python/str or other unsafe tags.\n\n\n$ uv run pytest tests/test_provider_credential_schema.py -v\n========================= 5 passed, 2 warnings in 0.11s ==========================\n\n\n$ uv run pytest tests/ \u2014 93 passed (88 pre-existing + 5 new). ruff check and ruff format --check clean on the new file.\n\n## Release Notes\n\n- fix(openai_api_compatible): add the top-level provider_credential_schema so the Knowledge Pipeline credential form can render. Previously, configuring a credential for an OpenAI-API-compatible custom model in a Knowledge Pipeline failed with "does not have provider_credential_schema" \u2014 the form could not render and the user saw a red error toast. The new schema adds api_key (required) and endpoint_url (optional) form fields. The per-model credential_form_schemas is preserved unchanged. Bumps the plugin from 0.0.66 \u2192 0.0.68.\n"

…dge Pipeline flow (langgenius#3682)

Configuring a credential for an OpenAI-API-compatible custom model in a
Knowledge Pipeline failed with "does not have
provider_credential_schema" -- the form could not render and the user
saw a red error toast. Dify requires every provider used in a
Knowledge Pipeline to declare a top-level provider_credential_schema
so the authorization form can render; the OpenAI-API-compatible plugin
only declared model_credential_schema, so the provider-level schema
was missing.

This change adds the missing provider_credential_schema with the two
universal fields every OpenAI-compatible server needs:

- api_key (required, secret-input): the bearer token for the provider.
- endpoint_url (optional, text-input): the OpenAI-compatible server
  URL. Empty falls back to the default OpenAI endpoint; set to point
  at LM Studio / vLLM / LiteLLM / etc.

The model-level credential_form_schemas is preserved unchanged, so
existing per-model configuration flows are not affected.

Tests:
- tests/test_provider_credential_schema.py (5 tests): pins the
  presence of provider_credential_schema, the form shape, the
  api_key / endpoint_url field types and required flags, that the
  per-model schema is unchanged, and a yaml round-trip.
- All 88 existing tests still pass; 5 new tests pass.

Bumps the plugin version 0.0.66 -> 0.0.68.
@crazywoola

Copy link
Copy Markdown
Member

Thank you for your contribution, @Taranum01! This PR currently has merge conflicts with main, so we are closing it for now. Please update your branch against the latest main and resolve the conflicts — note that the consolidated dependency refresh (#4106–#4111) has bumped plugin manifest.yaml versions on main, so please bump models/openai_api_compatible/manifest.yaml to the next unused version when you rebase. You are welcome to open a new PR with the updated changes and link back to this one. We appreciate your time and effort!

If these changes are still wanted, they can be folded into #3795 when you update it.

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.

[Bug] OpenAI API Compatible plugin: "does not have provider_credential_schema" in knowledge pipeline credential setup

2 participants