A FastAPI-based web service that automatically generates standardized documentation comments for code blocks using a local LLM (Ollama). It detects the programming language, references the appropriate comment convention (JSDoc, TSDoc, PEP 257, etc.), and returns the original code enriched with professional inline documentation.
- Python 3.14
- FastAPI + Uvicorn — REST API server
- LangChain + langchain-ollama — LLM agent orchestration
- Ollama — local LLM runtime (default model:
qwen2.5:7b) - codelang-detect — automatic programming language detection
- docling — web crawling for convention reference URLs
- Pydantic — request/response validation
-
Install Ollama and pull the model:
ollama pull qwen2.5:7b
-
Install dependencies (using uv or pip):
uv sync # or pip install -e .
-
Start the server:
python main.py
The server listens on
http://127.0.0.1:8085. -
Send a code block for commenting via
POST /invoke:curl -X POST http://127.0.0.1:8085/invoke \ -H "Content-Type: application/json" \ -d '{"code_block": "def add(a, b):\n return a + b"}'
The response contains the original code with generated documentation comments.