mirza.town
about archive rss

23/07/2023

What is DiagramGPT?

In short; it’s a service that creates charts from given text explanations. You explain what you want to see, and it draws it for you. Pretty neat, me think so.

Let’s say that I want to make a robot copy of my cat, I can describe its daily routine like this:

The cat will start its day by eating the food if it's hungry. 
If not hungry, it will lie down. 
If it has lain down for 3 hours, it will stretch and scratch my sofa.
After scratching, the process resets.

And DiagramGPT will output this:

A basic DiagramGPT output.

Perfect? No. But it’s a good start. Depending on the complexity of the explanation, the results can be much better.

Side note: It is so satisfying to see the output one box at a time.

But wait, there’s more! DiagramGPT can also draw sequence, entitity relationship, cloud architecture, and flow diagrams. It can also auto detect the type of diagram you want to draw from your explanation.

How does it work?

It’s not Stable Diffusion, that’s for sure. We also saw how it outputs the diagrams one box at a time. Looks and feels suspiciously like ChatGPT. We do know that ChatGPT can output only text, so how does it draw the diagrams?

Well, the part that draws the diagrams is a separate mechanism. ChatGPT translates human input to a specific syntax (which is documented here, and is also similar to MermaidJS) and leaves the rest to the diagram drawing mechanism.

The output for the cat example is this:

// Define nodes and relationships
Start [shape: oval, icon: flag] > Is the cat hungry? [shape: diamond, icon: question]
Is the cat hungry? > Cat eats food [icon: food]: Yes
Is the cat hungry? > Cat lies down [icon: bed]: No
Cat lies down > Has cat lain down for 3 hours? [shape: diamond, icon: clock]
Has cat lain down for 3 hours? > Cat stretches and scratches sofa [icon: paw]: Yes
Has cat lain down for 3 hours? > Cat continues to lie down [icon: bed]: No
Cat stretches and scratches sofa > Is the cat hungry?

// Define Groups
Cat's daily routine [icon: repeat] {
  Is the cat hungry?
  Cat eats food
  Cat lies down
  Has cat lain down for 3 hours?
  Cat stretches and scratches sofa
}

With this approach, not only you get a simple to use diagram drawing service, but you also get the ability to change generated diagrams with additional input.

Shortcomings

The biggest factor that determines the quality of the output is the quality of the input. If you don’t know how to explain what you want to see, you won’t get a good result.

There’s also ChatGPT related problems. For starters, there is icon support but ChatGPT’s context length isn’t enough to process all of them. It gets it right most of the times, but be prepared to see some missing icons here and there. There’s also an issue with the syntax. If you have a node called, let’s say, “Cat-Food” and you want to use it in a relationship, you will have to pray that ChatGPT doesn’t output exactly “Cat-Food”, as it breaks the syntax and the whole line will be ignored. Is it a big deal? No. But it’s a sign that there might be unforeseen problems with the syntax.