From 8635aacb46ceda44ed35f37512c827dc57e96450 Mon Sep 17 00:00:00 2001 From: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Date: Mon, 15 Sep 2025 23:15:53 -0700 Subject: [PATCH 1/2] =?UTF-8?q?Enhance=20LLM=20model=20configuration=20val?= =?UTF-8?q?idation=20to=20include=20active=20status=20c=E2=80=A6=20(#25759?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- api/services/workflow_service.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/api/services/workflow_service.py b/api/services/workflow_service.py index abda024555..ea73b6105e 100644 --- a/api/services/workflow_service.py +++ b/api/services/workflow_service.py @@ -375,13 +375,14 @@ class WorkflowService: def _validate_llm_model_config(self, tenant_id: str, provider: str, model_name: str) -> None: """ - Validate that an LLM model configuration can fetch valid credentials. + Validate that an LLM model configuration can fetch valid credentials and has active status. This method attempts to get the model instance and validates that: 1. The provider exists and is configured 2. The model exists in the provider 3. Credentials can be fetched for the model 4. The credentials pass policy compliance checks + 5. The model status is ACTIVE (not NO_CONFIGURE, DISABLED, etc.) :param tenant_id: The tenant ID :param provider: The provider name @@ -391,6 +392,7 @@ class WorkflowService: try: from core.model_manager import ModelManager from core.model_runtime.entities.model_entities import ModelType + from core.provider_manager import ProviderManager # Get model instance to validate provider+model combination model_manager = ModelManager() @@ -402,6 +404,22 @@ class WorkflowService: # via ProviderConfiguration.get_current_credentials() -> _check_credential_policy_compliance() # If it fails, an exception will be raised + # Additionally, check the model status to ensure it's ACTIVE + provider_manager = ProviderManager() + provider_configurations = provider_manager.get_configurations(tenant_id) + models = provider_configurations.get_models(provider=provider, model_type=ModelType.LLM) + + target_model = None + for model in models: + if model.model == model_name and model.provider.provider == provider: + target_model = model + break + + if target_model: + target_model.raise_for_status() + else: + raise ValueError(f"Model {model_name} not found for provider {provider}") + except Exception as e: raise ValueError( f"Failed to validate LLM model configuration (provider: {provider}, model: {model_name}): {str(e)}" From ecb22226d6d2862ba88d1f702204c55dca7367eb Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 16 Sep 2025 14:22:14 +0800 Subject: [PATCH 2/2] refactor: remove Claude-specific references from documentation files (#25760) --- AGENTS.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++- CLAUDE.md | 90 +------------------------------------------------------ 2 files changed, 88 insertions(+), 90 deletions(-) mode change 120000 => 100644 AGENTS.md mode change 100644 => 120000 CLAUDE.md diff --git a/AGENTS.md b/AGENTS.md deleted file mode 120000 index 681311eb9c..0000000000 --- a/AGENTS.md +++ /dev/null @@ -1 +0,0 @@ -CLAUDE.md \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000000..44f7b30360 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,87 @@ +# AGENTS.md + +## Project Overview + +Dify is an open-source platform for developing LLM applications with an intuitive interface combining agentic AI workflows, RAG pipelines, agent capabilities, and model management. + +The codebase consists of: + +- **Backend API** (`/api`): Python Flask application with Domain-Driven Design architecture +- **Frontend Web** (`/web`): Next.js 15 application with TypeScript and React 19 +- **Docker deployment** (`/docker`): Containerized deployment configurations + +## Development Commands + +### Backend (API) + +All Python commands must be prefixed with `uv run --project api`: + +```bash +# Start development servers +./dev/start-api # Start API server +./dev/start-worker # Start Celery worker + +# Run tests +uv run --project api pytest # Run all tests +uv run --project api pytest tests/unit_tests/ # Unit tests only +uv run --project api pytest tests/integration_tests/ # Integration tests + +# Code quality +./dev/reformat # Run all formatters and linters +uv run --project api ruff check --fix ./ # Fix linting issues +uv run --project api ruff format ./ # Format code +uv run --directory api basedpyright # Type checking +``` + +### Frontend (Web) + +```bash +cd web +pnpm lint # Run ESLint +pnpm eslint-fix # Fix ESLint issues +pnpm test # Run Jest tests +``` + +## Testing Guidelines + +### Backend Testing + +- Use `pytest` for all backend tests +- Write tests first (TDD approach) +- Test structure: Arrange-Act-Assert + +## Code Style Requirements + +### Python + +- Use type hints for all functions and class attributes +- No `Any` types unless absolutely necessary +- Implement special methods (`__repr__`, `__str__`) appropriately + +### TypeScript/JavaScript + +- Strict TypeScript configuration +- ESLint with Prettier integration +- Avoid `any` type + +## Important Notes + +- **Environment Variables**: Always use UV for Python commands: `uv run --project api ` +- **Comments**: Only write meaningful comments that explain "why", not "what" +- **File Creation**: Always prefer editing existing files over creating new ones +- **Documentation**: Don't create documentation files unless explicitly requested +- **Code Quality**: Always run `./dev/reformat` before committing backend changes + +## Common Development Tasks + +### Adding a New API Endpoint + +1. Create controller in `/api/controllers/` +1. Add service logic in `/api/services/` +1. Update routes in controller's `__init__.py` +1. Write tests in `/api/tests/` + +## Project-Specific Conventions + +- All async tasks use Celery with Redis as broker +- **Internationalization**: Frontend supports multiple languages with English (`web/i18n/en-US/`) as the source. All user-facing text must use i18n keys, no hardcoded strings. Edit corresponding module files in `en-US/` directory for translations. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index aea23db703..0000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,89 +0,0 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Project Overview - -Dify is an open-source platform for developing LLM applications with an intuitive interface combining agentic AI workflows, RAG pipelines, agent capabilities, and model management. - -The codebase consists of: - -- **Backend API** (`/api`): Python Flask application with Domain-Driven Design architecture -- **Frontend Web** (`/web`): Next.js 15 application with TypeScript and React 19 -- **Docker deployment** (`/docker`): Containerized deployment configurations - -## Development Commands - -### Backend (API) - -All Python commands must be prefixed with `uv run --project api`: - -```bash -# Start development servers -./dev/start-api # Start API server -./dev/start-worker # Start Celery worker - -# Run tests -uv run --project api pytest # Run all tests -uv run --project api pytest tests/unit_tests/ # Unit tests only -uv run --project api pytest tests/integration_tests/ # Integration tests - -# Code quality -./dev/reformat # Run all formatters and linters -uv run --project api ruff check --fix ./ # Fix linting issues -uv run --project api ruff format ./ # Format code -uv run --directory api basedpyright # Type checking -``` - -### Frontend (Web) - -```bash -cd web -pnpm lint # Run ESLint -pnpm eslint-fix # Fix ESLint issues -pnpm test # Run Jest tests -``` - -## Testing Guidelines - -### Backend Testing - -- Use `pytest` for all backend tests -- Write tests first (TDD approach) -- Test structure: Arrange-Act-Assert - -## Code Style Requirements - -### Python - -- Use type hints for all functions and class attributes -- No `Any` types unless absolutely necessary -- Implement special methods (`__repr__`, `__str__`) appropriately - -### TypeScript/JavaScript - -- Strict TypeScript configuration -- ESLint with Prettier integration -- Avoid `any` type - -## Important Notes - -- **Environment Variables**: Always use UV for Python commands: `uv run --project api ` -- **Comments**: Only write meaningful comments that explain "why", not "what" -- **File Creation**: Always prefer editing existing files over creating new ones -- **Documentation**: Don't create documentation files unless explicitly requested -- **Code Quality**: Always run `./dev/reformat` before committing backend changes - -## Common Development Tasks - -### Adding a New API Endpoint - -1. Create controller in `/api/controllers/` -1. Add service logic in `/api/services/` -1. Update routes in controller's `__init__.py` -1. Write tests in `/api/tests/` - -## Project-Specific Conventions - -- All async tasks use Celery with Redis as broker -- **Internationalization**: Frontend supports multiple languages with English (`web/i18n/en-US/`) as the source. All user-facing text must use i18n keys, no hardcoded strings. Edit corresponding module files in `en-US/` directory for translations. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000000..47dc3e3d86 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file