Repository navigation
fix(openai_api_compatible): add provider_credential_schema for Knowledge Pipeline flow (#3682) - #3858
Closed
Taranum01 wants to merge 1 commit into
Conversation
…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.
Member
|
Thank you for your contribution, @Taranum01! This PR currently has merge conflicts with If these changes are still wanted, they can be folded into #3795 when you update it. |
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.
"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-levelprovider_credential_schemaso the authorization form can render. The OpenAI-API-compatible plugin only declaredmodel_credential_schema, so the provider-level schema was missing. (Other configurable-model plugins likeopenai,anthropic,gemini,mistral, etc. all have it.)\n\n## Fix\n\nAdded the missingprovider_credential_schemawith 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-levelcredential_form_schemasis preserved unchanged, so existing per-model configuration flows (LLM / Embedding / Rerank / Speech2Text / TTS) are not affected. Theconfigurate_methodslist still contains onlycustomizable-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/stror 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 checkandruff format --checkclean on the new file.\n\n## Release Notes\n\n- fix(openai_api_compatible): add the top-levelprovider_credential_schemaso 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 addsapi_key(required) andendpoint_url(optional) form fields. The per-modelcredential_form_schemasis preserved unchanged. Bumps the plugin from 0.0.66 \u2192 0.0.68.\n"