diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02269919..6f837d7c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,36 @@ cd hindsight-api uv run pytest tests/ ``` -### Code style +### Code Style + +We use [Ruff](https://docs.astral.sh/ruff/) for Python linting and formatting, and ESLint/Prettier for TypeScript. + +#### Setting up git hooks (recommended) + +Set up git hooks to automatically lint and format code before each commit: + +```bash +./scripts/setup-hooks.sh +``` + +This configures git to use the hooks in `.githooks/`, which run all scripts in `scripts/hooks/` on commit. The lint hook runs in parallel: +- **Python**: `ruff check --fix`, `ruff format`, `ty check` +- **TypeScript**: `eslint --fix`, `prettier` + +#### Manual linting and formatting + +```bash +# Run all lints (same as pre-commit) +./scripts/hooks/lint.sh + +# Or run individually for Python: +cd hindsight-api +uv run ruff check --fix . # Lint and auto-fix +uv run ruff format . # Format code +uv run ty check hindsight_api # Type check +``` + +#### Style guidelines - Use Python type hints - Follow existing code patterns diff --git a/hindsight-api/hindsight_api/engine/llm_wrapper.py b/hindsight-api/hindsight_api/engine/llm_wrapper.py index 8b9a32c7..e0d3da8a 100644 --- a/hindsight-api/hindsight_api/engine/llm_wrapper.py +++ b/hindsight-api/hindsight_api/engine/llm_wrapper.py @@ -300,6 +300,8 @@ class LLMProvider: schema_msg + "\n\n" + call_params["messages"][0]["content"] ) if self.provider not in ("lmstudio", "ollama"): + # LM Studio and Ollama don't support json_object response format reliably + # We rely on the schema in the system message instead call_params["response_format"] = {"type": "json_object"} logger.debug(f"Sending request to {self.provider}/{self.model} (timeout={self.timeout})")