-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathstart_ui_example.py
More file actions
39 lines (31 loc) · 1.03 KB
/
start_ui_example.py
File metadata and controls
39 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Launch the M-flow web UI with sample data pre-loaded."""
import asyncio
import time
import m_flow
async def run():
# Seed the system with sample content
print("Seeding sample data...")
await m_flow.add("Deep learning uses neural networks with many layers to learn data representations.")
await m_flow.add("Transformers are a type of neural network architecture used in NLP tasks.")
await m_flow.memorize()
print("Knowledge graph built.\n")
# Start the web interface
print("Launching M-flow UI on http://localhost:3000 ...")
server = m_flow.start_ui(
pid_callback=lambda _pid: None,
port=3000,
open_browser=True,
)
if not server:
print("UI failed to start. Check logs.")
return
print("UI running. Press Ctrl+C to stop.\n")
try:
while server.poll() is None:
time.sleep(1)
except KeyboardInterrupt:
server.terminate()
server.wait()
print("UI stopped.")
if __name__ == "__main__":
asyncio.run(run())