Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,90 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
# Lets try this Mixtral thing because everyone likes MOE right?
|
| 6 |
+
|
| 7 |
+
## Experiemental Mermaid Model: 2x7B Mermaid Mixtral-2x7b
|
| 8 |
+
Lets see if its any good, this is 1 epoch of a synthetic dataset exclusively created using my dataset augmentation toolkit
|
| 9 |
+
using MermaidMistral 7B and MermaidSolar outputs at factual temp range 0.1 to 0.5.
|
| 10 |
+
|
| 11 |
+
Using my method I have created a dataset of mermaid diagrams from models originally trained by the original 500 hand curated dataset entries at varying temperature ranges.
|
| 12 |
+
|
| 13 |
+
My toolkit is released for others to expand their dataset with more diverse examples.
|
| 14 |
+
|
| 15 |
+
This model is an example of training using this method.
|
| 16 |
+
|
| 17 |
+
Link: https://github.com/Troys-Code/AI_Research/tree/main
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
Send this as the most simple example of how to use my model for code to mermaid flow diagrams.
|
| 21 |
+
The rest of the prompt engineering is up to you.
|
| 22 |
+
|
| 23 |
+
-----
|
| 24 |
+
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 25 |
+
|
| 26 |
+
### Instruction:
|
| 27 |
+
Create the mermaid diagram for the following code:
|
| 28 |
+
|
| 29 |
+
### Input:
|
| 30 |
+
import subprocess
|
| 31 |
+
import os
|
| 32 |
+
import tempfile
|
| 33 |
+
|
| 34 |
+
class MermaidDiagramGenerator:
|
| 35 |
+
def __init__(self, theme='dark', background='transparent'):
|
| 36 |
+
self._theme = theme
|
| 37 |
+
self._background = background
|
| 38 |
+
self._cache_dir = os.path.join(os.getcwd(), 'cache')
|
| 39 |
+
os.makedirs(self._cache_dir, exist_ok=True)
|
| 40 |
+
|
| 41 |
+
def convert_to_image(self, input_source):
|
| 42 |
+
mermaid_code = self._read_content(input_source)
|
| 43 |
+
clean_code = self._remove_mermaid_block_markers(mermaid_code)
|
| 44 |
+
output_path = os.path.join(self._cache_dir, "output.png")
|
| 45 |
+
self._generate_image_from_code(clean_code, output_path)
|
| 46 |
+
return output_path
|
| 47 |
+
|
| 48 |
+
def _is_file(self, input_source):
|
| 49 |
+
return os.path.isfile(input_source)
|
| 50 |
+
|
| 51 |
+
def _read_content(self, input_source):
|
| 52 |
+
if self._is_file(input_source):
|
| 53 |
+
with open(input_source, 'r') as file:
|
| 54 |
+
return file.read()
|
| 55 |
+
return input_source
|
| 56 |
+
|
| 57 |
+
def _remove_mermaid_block_markers(self, code):
|
| 58 |
+
code_lines = code.strip().splitlines()
|
| 59 |
+
if code_lines[0].startswith("```mermaid") and code_lines[-1] == "```":
|
| 60 |
+
return "\n".join(code_lines[1:-1]).strip()
|
| 61 |
+
return code
|
| 62 |
+
|
| 63 |
+
def _generate_image_from_code(self, mermaid_code, output_path):
|
| 64 |
+
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.mmd') as temp_file:
|
| 65 |
+
temp_file.write(mermaid_code)
|
| 66 |
+
input_path = temp_file.name
|
| 67 |
+
subprocess.run(["mmdc", "-i", input_path, "-o", output_path, "-t", self._theme, "-b", self._background], check=True)
|
| 68 |
+
os.remove(input_path)
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
generator = MermaidDiagramGenerator()
|
| 72 |
+
|
| 73 |
+
input_sources = ["MermaidGraph_0.txt", "MermaidGraph_1.txt"] # Paths to Mermaid graph files
|
| 74 |
+
current_source_index = 0
|
| 75 |
+
|
| 76 |
+
try:
|
| 77 |
+
while True: # Infinite loop to alternate between input sources
|
| 78 |
+
input_source = input_sources[current_source_index]
|
| 79 |
+
print(f"Generating diagram from: {input_source}")
|
| 80 |
+
image_path = generator.convert_to_image(input_source)
|
| 81 |
+
print(f"Diagram image created at: {image_path}")
|
| 82 |
+
current_source_index = (current_source_index + 1) % len(input_sources)
|
| 83 |
+
except KeyboardInterrupt:
|
| 84 |
+
print("Live Mermaid flow map generation stopped.")
|
| 85 |
+
except Exception as e:
|
| 86 |
+
print(f"Error: {e}")
|
| 87 |
+
|
| 88 |
+
### Response:
|
| 89 |
+
```mermaid
|
| 90 |
+
graph TB;
|