Repository navigation
Expand file tree
/
Copy pathstart_local_ui_frontend_example.py
More file actions
58 lines (46 loc) · 1.69 KB
/
Copy pathstart_local_ui_frontend_example.py
File metadata and controls
58 lines (46 loc) · 1.69 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Example showing how to use cognee.start_ui() to launch the frontend.
This demonstrates the new UI functionality that works similar to DuckDB's start_ui().
"""
import asyncio
import time
import cognee
async def main():
# First, let's add some data to cognee for the UI to display
print("Adding sample data to cognee...")
await cognee.remember(
[
"Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval.",
"Machine learning (ML) is a subset of artificial intelligence that focuses on algorithms and statistical models.",
],
self_improvement=False,
)
print("\n" + "=" * 60)
print("Starting cognee UI...")
print("=" * 60)
# Start the UI server
def dummy_callback(pid):
pass
server = cognee.start_ui(
pid_callback=dummy_callback,
port=3000,
open_browser=True, # This will automatically open your browser
)
if server:
print("UI server started successfully!")
print("The interface will be available at: http://localhost:3000")
print("\nPress Ctrl+C to stop the server when you're done...")
try:
# Keep the server running
while server.poll() is None: # While process is still running
time.sleep(1)
except KeyboardInterrupt:
print("\nStopping UI server...")
server.terminate()
server.wait() # Wait for process to finish
print("UI server stopped.")
else:
print("Failed to start UI server. Check the logs above for details.")
if __name__ == "__main__":
asyncio.run(main())