Varshithdharmajv commited on
Commit
8eac7f1
·
verified ·
1 Parent(s): 290ca89

Upload flow_module.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. flow_module.py +29 -19
flow_module.py CHANGED
@@ -1,13 +1,13 @@
1
  def generate_flow_html(active_phase="idle"):
2
  """
3
  Generates animated SVG for the MVM² Architecture Flow.
4
- Phases: 'idle', 'enhance', 'ocr', 'reasoning', 'verification', 'consensus', 'success'
5
  """
6
 
7
  # Define colors
8
  bg_color = "#1e293b"
9
- accent = "#6366f1"
10
- success = "#10b981"
11
  text = "#94a3b8"
12
 
13
  # Pulse animation logic
@@ -15,23 +15,26 @@ def generate_flow_html(active_phase="idle"):
15
  return 'active-pulse' if active_phase == phase else ''
16
 
17
  def get_node_style(phase):
18
- if active_phase == 'success': return 'stroke: #10b981; filter: drop-shadow(0 0 8px #10b981);'
19
  if active_phase == phase: return f'stroke: {accent}; filter: drop-shadow(0 0 8px {accent});'
20
  return 'stroke: rgba(255,255,255,0.1);'
21
 
22
  html = f"""
23
- <div class="glass-card" style="width: 100%; height: 400px; display: flex; justify-content: center; align-items: center; overflow: hidden; position: relative;">
24
  <svg width="800" height="350" viewBox="0 0 800 350" preserveAspectRatio="xMidYMid meet">
25
  <!-- Definitions for markers and gradients -->
26
  <defs>
27
  <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="0" refY="3.5" orient="auto">
28
  <polygon points="0 0, 10 3.5, 0 7" fill="{text}" />
29
  </marker>
30
- <linearGradient id="pulse-grad" x1="0%" y1="0%" x2="100%" y2="0%">
31
- <stop offset="0%" stop-color="transparent" />
32
- <stop offset="50%" stop-color="{accent}" />
33
- <stop offset="100%" stop-color="transparent" />
34
- </linearGradient>
 
 
 
35
  </defs>
36
 
37
  <!-- CONNECTIONS -->
@@ -42,10 +45,13 @@ def generate_flow_html(active_phase="idle"):
42
  <path d="M300 175 H400" class="flow-line {get_pulse('ocr')}" stroke="{text}" stroke-width="2" marker-end="url(#arrowhead)" />
43
 
44
  <!-- Reasoning to Consensus (4 Parallel) -->
45
- <path d="M500 100 Q 550 175 600 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
46
- <path d="M500 150 Q 550 175 600 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
47
- <path d="M500 200 Q 550 175 600 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
48
- <path d="M500 250 Q 550 175 600 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
 
 
 
49
 
50
  <!-- Symbolic Bridge -->
51
  <path d="M450 300 Q 450 250 450 250" class="flow-line {get_pulse('verification')}" stroke="{success}" stroke-width="3" stroke-dasharray="5,5" />
@@ -53,11 +59,11 @@ def generate_flow_html(active_phase="idle"):
53
  <!-- NODES -->
54
  <!-- 1. Input/Enhance -->
55
  <rect x="20" y="140" width="80" height="70" rx="10" fill="{bg_color}" style="{get_node_style('enhance')}" />
56
- <text x="60" y="180" text-anchor="middle" fill="white" font-size="12">ENHANCE</text>
57
 
58
  <!-- 2. OCR Module -->
59
  <circle cx="250" cy="175" r="45" fill="{bg_color}" style="{get_node_style('ocr')}" />
60
- <text x="250" y="180" text-anchor="middle" fill="white" font-size="12">OCR</text>
61
 
62
  <!-- 3. Reasoning Agents (Parallel) -->
63
  <g class="{'thinking' if active_phase == 'reasoning' else ''}">
@@ -68,13 +74,17 @@ def generate_flow_html(active_phase="idle"):
68
  <text x="450" y="45" text-anchor="middle" fill="{text}" font-size="10">REASONING</text>
69
  </g>
70
 
71
- <!-- 4. Verification Bridge (SymPy) -->
 
 
 
 
72
  <rect x="400" y="300" width="100" height="40" rx="5" fill="{bg_color}" style="{get_node_style('verification')}" />
73
  <text x="450" y="325" text-anchor="middle" fill="{success}" font-size="10" font-weight="bold">SYMPY CORE</text>
74
 
75
- <!-- 5. Consensus -->
76
  <polygon points="650,125 750,175 650,225" fill="{bg_color}" style="{get_node_style('consensus')}" />
77
- <text x="680" y="180" text-anchor="middle" fill="white" font-size="12">CONSENSUS</text>
78
  </svg>
79
 
80
  <div style="position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); font-size: 0.8em; color: {text};">
 
1
  def generate_flow_html(active_phase="idle"):
2
  """
3
  Generates animated SVG for the MVM² Architecture Flow.
4
+ Phases: 'idle', 'enhance', 'ocr', 'reasoning', 'heuristics', 'verification', 'consensus', 'success'
5
  """
6
 
7
  # Define colors
8
  bg_color = "#1e293b"
9
+ accent = "#e63946" # Red to match local dashboard theme
10
+ success = "#16a34a"
11
  text = "#94a3b8"
12
 
13
  # Pulse animation logic
 
15
  return 'active-pulse' if active_phase == phase else ''
16
 
17
  def get_node_style(phase):
18
+ if active_phase == 'success': return f'stroke: {success}; filter: drop-shadow(0 0 8px {success});'
19
  if active_phase == phase: return f'stroke: {accent}; filter: drop-shadow(0 0 8px {accent});'
20
  return 'stroke: rgba(255,255,255,0.1);'
21
 
22
  html = f"""
23
+ <div style="width: 100%; height: 400px; display: flex; justify-content: center; align-items: center; overflow: hidden; position: relative; background: rgba(30, 30, 30, 0.6); border-radius: 12px; border: 1px solid rgba(255,255,255,0.05);">
24
  <svg width="800" height="350" viewBox="0 0 800 350" preserveAspectRatio="xMidYMid meet">
25
  <!-- Definitions for markers and gradients -->
26
  <defs>
27
  <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="0" refY="3.5" orient="auto">
28
  <polygon points="0 0, 10 3.5, 0 7" fill="{text}" />
29
  </marker>
30
+ <style>
31
+ .flow-line {{ stroke-dasharray: 1000; stroke-dashoffset: 1000; }}
32
+ .active-pulse {{ stroke-dashoffset: 0; animation: pulse-flow 2s infinite linear; stroke: {accent} !important; opacity: 1; }}
33
+ @keyframes pulse-flow {{ 0% {{ stroke-dashoffset: 1000; opacity: 0.3; }} 50% {{ opacity: 1; }} 100% {{ stroke-dashoffset: 0; opacity: 0.3; }} }}
34
+ .thinking circle {{ animation: thinking-pulse 1.5s infinite ease-in-out; }}
35
+ @keyframes thinking-pulse {{ 0%, 100% {{ transform: scale(1); opacity: 0.8; }} 50% {{ transform: scale(1.1); opacity: 1; filter: brightness(1.2); }} }}
36
+ .thinking {{ transform-origin: 450px 175px; }}
37
+ </style>
38
  </defs>
39
 
40
  <!-- CONNECTIONS -->
 
45
  <path d="M300 175 H400" class="flow-line {get_pulse('ocr')}" stroke="{text}" stroke-width="2" marker-end="url(#arrowhead)" />
46
 
47
  <!-- Reasoning to Consensus (4 Parallel) -->
48
+ <path d="M500 100 Q 525 100 550 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
49
+ <path d="M500 150 Q 525 150 550 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
50
+ <path d="M500 200 Q 525 200 550 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
51
+ <path d="M500 250 Q 525 250 550 175" class="flow-line {get_pulse('reasoning')}" stroke="{text}" stroke-width="1.5" />
52
+
53
+ <!-- Heuristics to Consensus -->
54
+ <path d="M600 175 H640" class="flow-line {get_pulse('heuristics')}" stroke="{accent}" stroke-width="2" marker-end="url(#arrowhead)" />
55
 
56
  <!-- Symbolic Bridge -->
57
  <path d="M450 300 Q 450 250 450 250" class="flow-line {get_pulse('verification')}" stroke="{success}" stroke-width="3" stroke-dasharray="5,5" />
 
59
  <!-- NODES -->
60
  <!-- 1. Input/Enhance -->
61
  <rect x="20" y="140" width="80" height="70" rx="10" fill="{bg_color}" style="{get_node_style('enhance')}" />
62
+ <text x="60" y="180" text-anchor="middle" fill="white" font-size="10" font-weight="600">ENHANCE</text>
63
 
64
  <!-- 2. OCR Module -->
65
  <circle cx="250" cy="175" r="45" fill="{bg_color}" style="{get_node_style('ocr')}" />
66
+ <text x="250" y="180" text-anchor="middle" fill="white" font-size="10" font-weight="600">OCR</text>
67
 
68
  <!-- 3. Reasoning Agents (Parallel) -->
69
  <g class="{'thinking' if active_phase == 'reasoning' else ''}">
 
74
  <text x="450" y="45" text-anchor="middle" fill="{text}" font-size="10">REASONING</text>
75
  </g>
76
 
77
+ <!-- 4. Heuristics Module -->
78
+ <rect x="550" y="150" width="50" height="50" rx="5" fill="{bg_color}" style="{get_node_style('heuristics')}" />
79
+ <text x="575" y="180" text-anchor="middle" fill="white" font-size="8" font-weight="600">FILTER</text>
80
+
81
+ <!-- 5. Verification Bridge (SymPy) -->
82
  <rect x="400" y="300" width="100" height="40" rx="5" fill="{bg_color}" style="{get_node_style('verification')}" />
83
  <text x="450" y="325" text-anchor="middle" fill="{success}" font-size="10" font-weight="bold">SYMPY CORE</text>
84
 
85
+ <!-- 6. Consensus -->
86
  <polygon points="650,125 750,175 650,225" fill="{bg_color}" style="{get_node_style('consensus')}" />
87
+ <text x="680" y="180" text-anchor="middle" fill="white" font-size="10" font-weight="600">CONSENSUS</text>
88
  </svg>
89
 
90
  <div style="position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); font-size: 0.8em; color: {text};">