vasilecampeanu / obsidian-weaver

Weaver is an Obsidian plugin that integrates a ChatGPT-like interface into your note-taking workflow. This plugin makes it easy to access AI-generated suggestions and insights within Obsidian, helping you improve your writing and brainstorming process.
MIT License
199 stars 8 forks source link

Should work with mermaid diagrams #27

Closed halr9000 closed 2 weeks ago

halr9000 commented 1 year ago

Since I saw you put latex in the system role prompt, my first thought was to test my latest chatgpt hobby: text adventure gaming with dynamic diagrams! image

It did not quite work and I'm not sure why. Here's the prompt:

what's the relationship between the sun and its planets? Draw in a mermaid diagram code block

I'll paste an image of the output so you can see that it is overflowing wayyyyy off the screen image

And the text:

The relationship between the sun and its planets can be represented using a mermaid diagram in Obsidian. Here is an example code block that illustrates this relationship:

```mermaid
graph LR
    A[Sun] --> B[Mercury]
    A --> C[Venus]
    A --> D[Earth]
    A --> E[Mars]
    A --> F[Jupiter]
    A --> G[Saturn]
    A --> H[Uranus]
    A --> I[Neptune]

This code block uses Mermaid syntax to create a graph with the Sun at the center and each planet connected to it by an arrow. The arrows represent the gravitational pull of the Sun on each planet, which keeps them in orbit around it.

Note that you will need to have the Mermaid plugin installed in Obsidian to render this code block properly. You can install the plugin by going to the Community Plugins tab in the Obsidian settings menu and searching for "Mermaid".

Any clue what to change here to make it work?

update: looks like it just didn't close the code block. Let me see if I can get the bot to do it w/o code changes.

halr9000 commented 1 year ago

Tried appending this to the system role prompt:

Also, mermaid diagrams are helpful to visualize relationships. Simply wrap them in a mermaid code block with 3 backticks, "mermaid", and ending with 3 more.

It helped in that inference was made without me asking for a literal mermaid diagram. e.g. "tell me about the solar system" resulted in a bunch of text. Then I asked, "can you show me visually?". It tried to give me a mermaid diagram, but it didn't parse well. Different issue than above.

Sure, I can create a visualization of the Solar System for you using Mermaid diagrams.

```mermaid
graph LR
A[Sun] --> B(Mercury)
A --> C(Venus)
A --> D(Earth)
A --> E(Mars)
A --> F(Jupiter)
A --> G(Saturn)
A --> H(Uranus)
A --> I(Neptune)

B1(Ceres) -- located in asteroid belt--> B
F1(Moons) -- has 79 known moons--> F
G1(Moons) -- has 82 known moons--> G
H1(Moons) -- has 27 known moons--> H
I1(Moons) -- has 14 known moons--> I

J(Kuiper Belt Objects) -- located beyond Neptune's orbit--> I

K(Comets) --- orbiting throughout the solar system ---> A

L(Asteroids) --- Mostly found between orbits of Mars and Jupiter ---> E

[3 backticks were here]
This is a basic diagram of the Solar System, where each planet is connected to the Sun, and some planets are also connected to their respective moons. Additionally, dwarf planets are represented by smaller circles next to their corresponding planet or location. The diagram also includes asteroids, comets and Kuiper Belt objects orbiting throughout the solar system.

That looks ok at first glance but I'm no mermaid wizard, maybe I'm running into a new chatgpt flaw in its understanding of mermaid -- but I'd not seen that before, so 🤷

image

vasilecampeanu commented 1 year ago

Hello, thank you for pointing this out. I have experimented with something comparable involving callouts, and the results have been inconsistent, sometimes providing well-formatted responses while other times not adhering to the callout format. I intend to investigate further and implement a system that activates particular system prompts based on specific keywords. However, this needs to wait for a while as my current focus is on developing a more effective method for organizing conversations.