From fdab924901072de549c826fa1ccf81bd79786252 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Thu, 25 Apr 2024 15:49:39 +0100 Subject: [PATCH] update: add mermaid diagrams to README (#12) * update: add mermaid diagrams to README Signed-off-by: Milos Gajdos --------- Signed-off-by: Milos Gajdos --- README.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/README.md b/README.md index f54dd4f..1e7d839 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,80 @@ It uses [NATS jetstream](https://docs.nats.io/nats-concepts/jetstream) for messa > This project was built purely for educational purposes and thus is likely ridden with bugs, inefficiencies, etc. > You should consider this project as highly experimental. +## Bot Conversation Flow + +```mermaid +sequenceDiagram + participant GoTTS as TTS + participant GoLLM as LLM + participant Gobot + participant Rustbot + participant RustLLM as LLM + participant RustTTS as TTS + Gobot->>+Rustbot: Hi Rustbot! + Rustbot->>RustLLM: Hi Rustbot! + RustLLM->>RustTTS: Hi Gobot! + RustLLM->>Rustbot: Hi Gobot! + Rustbot->>-Gobot: Hi Gobot! + activate Gobot + Gobot->>GoLLM: Hi Gobot! + GoLLM->>GoTTS: Teach me about Rust! + GoLLM->>Gobot: Teach me about Rust! + Gobot->>-Rustbot: Teach me about Rust! +``` + +## Architecture + +Zoomed in view on the high-level architecture: + +```mermaid +flowchart TB + subgraph " " + playht(PlayHT API) + ollama(Ollama) + end + bot <-->ollama + bot <-->playht + bot <--> NATS[[NATS JetStream]] +``` + +## Tasks, Goroutines, Channels + +> [!NOTE] +> Mermaid does not have proper support for controlling layout or even basic graph legends +> There are some terrible workarounds, so I've opted not to use them in this README, hence +> the diagram might feel a bit unwieldy + +```mermaid +flowchart TB + ollama{Ollama} + playht{PlayHT} + llm((llm)) + tts((tts)) + jetWriter((jetWriter)) + jetReader((jetReader)) + ttsChunks(ttsChunks) + jetChunks(jetChunks) + prompts(prompts) + ttsDone(ttsDone) + subgraph NATS JetStream + Go(go) + Rust(rust) + end + Go-->jetReader + jetWriter-->Rust + jetReader-->prompts + prompts-->llm + llm-->ollama + llm-->ttsChunks + llm-->jetChunks + jetChunks-->jetWriter + ttsChunks-->tts + tts-->playht + tts-->ttsDone + ttsDone-->jetWriter +``` + # HOWTO There are a few prerequisites: