This is backend for Diagrams Creator HuggingChat assistant:
https://hf.co/chat/assistant/65e71408a6654bcc68624d8d
Install dependencies:
sudo apt install graphviz
python3 -m venv .venv
source .venv/bin/activate
pip install fastapi graphviz uvicorn
or if on AWS linux
sudo yum install graphviz
python3 -m venv .venv
source .venv/bin/activate
pip install fastapi graphviz uvicorn
Run the code:
uvicorn main:app --reload
To use first of all write your DOT code:
digraph G { A -> B; }
URI encode it:
digraph%20G%20%7B%20A%20-%3E%20B%3B%20%7D
And send HTTP GET request and save the image to the file:
curl "http://localhost:8000/gen?dot=digraph%20G%20%7B%20A%20-%3E%20B%3B%20%7D" --output graph.png
See the result: