ltcai 0.1.4 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -0
- package/docs/OPERATIONS.md +149 -0
- package/knowledge_graph.py +815 -0
- package/ltcai_cli.py +45 -1
- package/package.json +15 -3
- package/requirements.txt +1 -0
- package/server.py +805 -44
- package/skills/SKILL_TEMPLATE.md +57 -0
- package/skills/code_review/SKILL.md +76 -0
- package/skills/data_analysis/SKILL.md +79 -0
- package/skills/file_edit/SKILL.md +68 -0
- package/skills/web_search/SKILL.md +74 -0
- package/static/account.html +14 -2
- package/static/admin.html +225 -6
- package/static/chat.html +644 -140
- package/static/graph.html +612 -0
- package/static/icons/apple-touch-icon.png +0 -0
- package/static/icons/favicon-32.png +0 -0
- package/static/icons/icon-192.png +0 -0
- package/static/icons/icon-512.png +0 -0
- package/static/manifest.json +35 -0
- package/static/sw.js +51 -0
- package/telegram_bot.py +631 -217
- package/tests/__init__.py +0 -0
- package/tests/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tests/integration/__init__.py +0 -0
- package/tests/integration/test_api.py +94 -0
- package/tests/unit/__init__.py +0 -0
- package/tests/unit/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tests/unit/__pycache__/test_security.cpython-314-pytest-9.0.3.pyc +0 -0
- package/tests/unit/__pycache__/test_tools.cpython-314-pytest-9.0.3.pyc +0 -0
- package/tests/unit/test_security.py +125 -0
- package/tests/unit/test_tools.py +127 -0
- package/tools.py +169 -13
package/ltcai_cli.py
CHANGED
|
@@ -6,6 +6,7 @@ import argparse
|
|
|
6
6
|
import importlib.util
|
|
7
7
|
import os
|
|
8
8
|
import shutil
|
|
9
|
+
import socket
|
|
9
10
|
import sys
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
|
|
@@ -14,6 +15,46 @@ def _has_module(name: str) -> bool:
|
|
|
14
15
|
return importlib.util.find_spec(name) is not None
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
def _local_ips() -> list[str]:
|
|
19
|
+
"""Return all non-loopback IPv4 addresses for this machine."""
|
|
20
|
+
ips: list[str] = []
|
|
21
|
+
try:
|
|
22
|
+
hostname = socket.gethostname()
|
|
23
|
+
for info in socket.getaddrinfo(hostname, None):
|
|
24
|
+
addr = info[4][0]
|
|
25
|
+
if ":" not in addr and not addr.startswith("127."):
|
|
26
|
+
if addr not in ips:
|
|
27
|
+
ips.append(addr)
|
|
28
|
+
except Exception:
|
|
29
|
+
pass
|
|
30
|
+
if not ips:
|
|
31
|
+
try:
|
|
32
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
33
|
+
s.connect(("8.8.8.8", 80))
|
|
34
|
+
ips.append(s.getsockname()[0])
|
|
35
|
+
s.close()
|
|
36
|
+
except Exception:
|
|
37
|
+
pass
|
|
38
|
+
return ips
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _print_banner(host: str, port: int) -> None:
|
|
42
|
+
local_url = f"http://localhost:{port}"
|
|
43
|
+
print()
|
|
44
|
+
print("=" * 56)
|
|
45
|
+
print(" Lattice AI is running")
|
|
46
|
+
print(f" Local: {local_url}")
|
|
47
|
+
if host == "0.0.0.0":
|
|
48
|
+
for ip in _local_ips():
|
|
49
|
+
print(f" Network: http://{ip}:{port}")
|
|
50
|
+
print()
|
|
51
|
+
print(" Other devices on the same Wi-Fi can open the")
|
|
52
|
+
print(" Network URL above in their browser.")
|
|
53
|
+
print(" On iPad/Android: browser menu → 'Add to Home Screen'")
|
|
54
|
+
print("=" * 56)
|
|
55
|
+
print()
|
|
56
|
+
|
|
57
|
+
|
|
17
58
|
def doctor() -> int:
|
|
18
59
|
checks = [
|
|
19
60
|
("Python 3.11+", sys.version_info >= (3, 11), sys.version.split()[0], True),
|
|
@@ -48,7 +89,8 @@ def main() -> None:
|
|
|
48
89
|
parser = argparse.ArgumentParser(prog="LTCAI", description="Run the Lattice AI local server.")
|
|
49
90
|
subparsers = parser.add_subparsers(dest="command")
|
|
50
91
|
subparsers.add_parser("doctor", help="Check local runtime dependencies and configuration.")
|
|
51
|
-
|
|
92
|
+
# Default to 0.0.0.0 so other devices on the same network can connect
|
|
93
|
+
parser.add_argument("--host", default=os.getenv("LATTICEAI_HOST") or "0.0.0.0")
|
|
52
94
|
parser.add_argument("--port", type=int, default=int(os.getenv("LATTICEAI_PORT") or "4825"))
|
|
53
95
|
parser.add_argument("--reload", action="store_true", help="Enable uvicorn reload for local development.")
|
|
54
96
|
args = parser.parse_args()
|
|
@@ -59,6 +101,8 @@ def main() -> None:
|
|
|
59
101
|
app_dir = Path(__file__).resolve().parent
|
|
60
102
|
os.chdir(app_dir)
|
|
61
103
|
|
|
104
|
+
_print_banner(args.host, args.port)
|
|
105
|
+
|
|
62
106
|
import uvicorn
|
|
63
107
|
|
|
64
108
|
uvicorn.run(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ltcai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Lattice AI local MLX/cloud LLM workspace server",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ltcai": "bin/ltcai.js",
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"start": "LTCAI",
|
|
11
11
|
"dev": "python3 ltcai_cli.py --reload",
|
|
12
12
|
"build:python": "python3 -m build",
|
|
13
|
-
"check:python": "python3 -m py_compile ltcai_cli.py server.py llm_router.py p_reinforce.py telegram_bot.py tools.py codex_telegram_bot.py",
|
|
13
|
+
"check:python": "python3 -m py_compile ltcai_cli.py server.py knowledge_graph.py llm_router.py p_reinforce.py telegram_bot.py tools.py codex_telegram_bot.py",
|
|
14
|
+
"test": "python3 -m pytest tests/ -v",
|
|
15
|
+
"test:unit": "python3 -m pytest tests/unit/ -v",
|
|
16
|
+
"test:integration": "python3 -m pytest tests/integration/ -v",
|
|
14
17
|
"publish:npm": "npm publish --access public",
|
|
15
18
|
"publish:pypi": "python3 -m twine upload dist/*"
|
|
16
19
|
},
|
|
@@ -18,7 +21,8 @@
|
|
|
18
21
|
"ltcai",
|
|
19
22
|
"llm",
|
|
20
23
|
"mlx",
|
|
21
|
-
"
|
|
24
|
+
"local-ai",
|
|
25
|
+
"agent"
|
|
22
26
|
],
|
|
23
27
|
"license": "MIT",
|
|
24
28
|
"private": false,
|
|
@@ -27,14 +31,22 @@
|
|
|
27
31
|
"LICENSE",
|
|
28
32
|
"ltcai_cli.py",
|
|
29
33
|
"server.py",
|
|
34
|
+
"knowledge_graph.py",
|
|
30
35
|
"llm_router.py",
|
|
31
36
|
"p_reinforce.py",
|
|
32
37
|
"telegram_bot.py",
|
|
33
38
|
"tools.py",
|
|
34
39
|
"codex_telegram_bot.py",
|
|
40
|
+
"skills/",
|
|
41
|
+
"tests/",
|
|
35
42
|
"static/account.html",
|
|
36
43
|
"static/chat.html",
|
|
37
44
|
"static/admin.html",
|
|
45
|
+
"static/graph.html",
|
|
46
|
+
"static/manifest.json",
|
|
47
|
+
"static/sw.js",
|
|
48
|
+
"static/icons/",
|
|
49
|
+
"docs/",
|
|
38
50
|
"requirements.txt",
|
|
39
51
|
"README.md"
|
|
40
52
|
],
|
package/requirements.txt
CHANGED