The Modeling Agent is the conversational backend used by the BESSER Web Modeling Editor. It interprets natural-language requests and returns structured modeling actions (create, modify, generate, convert) over WebSocket-compatible payloads.
- Creates and modifies UML models from natural language.
- Supports multi-step orchestration (for example: model first, then generate code).
- Supports code generation triggers for multiple BESSER generators.
- Answers UML specification questions using RAG over UML documents.
- Converts uploaded files (PlantUML, KG, images, text) into diagram specifications.
| Diagram type | Single element | Complete system | Modification |
|---|---|---|---|
ClassDiagram |
Yes | Yes | Yes |
ObjectDiagram |
Yes | Yes | Yes |
StateMachineDiagram |
Yes | Yes | Yes |
AgentDiagram |
Yes | Yes | Yes |
GUINoCodeDiagram |
Yes | Yes | Yes |
QuantumCircuitDiagram |
Yes | Yes | Yes |
django, backend, web_app, sql, sqlalchemy, python, java, pydantic, jsonschema, smartdata, agent, qiskit
modeling-agent/
modeling_agent.py # Runtime entrypoint
src/
agent_setup.py # LLM/RAG/factory bootstrapping
execution.py # Operation execution engine
state_bodies.py # Intent state logic
suggestions.py # Context-aware suggestion engine
llm/ # LLM provider abstraction
memory/ # Conversation memory with sliding window
schemas/ # Pydantic schemas for structured LLM output (enforced name lengths, Literal actions)
tracking/ # Token usage and cost tracking
protocol/ # Request parsing and protocol types
orchestrator/ # Multi-operation planning and routing
handlers/ # Generation and file-conversion handlers
utilities/ # Shared context/model/request helpers
diagram_handlers/
core/ # Base handler + deterministic layout
types/ # Concrete per-diagram handlers
registry/ # Factory + metadata registry
*.py # Backward-compat import shims
tests/
docs/
The agent consumes assistant payloads with protocolVersion: "2.0".
In BESSER WebSocket mode, this payload is often serialized inside the top-level message field.
Example payload:
{
"action": "user_message",
"message": "{\"action\":\"user_message\",\"protocolVersion\":\"2.0\",\"clientMode\":\"workspace\",\"message\":\"create a User class\",\"context\":{\"activeDiagramType\":\"ClassDiagram\"}}"
}The agent normalizes this into an internal AssistantRequest object (src/protocol/types.py).
- Python 3.10+
- OpenAI API key
python -m venv .venv
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt- Copy
config_example.yamltoconfig.yaml. - Set
nlp.openai.api_keyinconfig.yaml. - Optional: copy
.env.exampleto.envfor local tooling.
cp config_example.yaml config.yamlpython modeling_agent.pyDefault WebSocket host/port are configured in config.yaml (websocket_platform).
# Full test suite
python -m pytest
# Focused suites
python -m pytest tests/test_diagram_handlers.py
python -m pytest tests/test_request_planner.py
python -m pytest tests/test_protocol.pypip install -r docs/requirements.txt
cd docs
# Windows
make.bat html
# Linux/macOS
make html- Keep behavior changes synchronized across
src/,tests/, anddocs/source/. - Prefer deterministic handler outputs and shared helper functions under
src/utilities/. - Keep backward-compatibility shims when moving modules used by imports/tests.
- Never commit real API keys.
- Use
config_example.yamland.env.exampleas templates.