neuronum 5.3.0__tar.gz → 5.4.1__tar.gz

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.

Potentially problematic release.


This version of neuronum might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuronum
3
- Version: 5.3.0
3
+ Version: 5.4.1
4
4
  Summary: Official client library to interact with the Neuronum Network
5
5
  Home-page: https://neuronum.net
6
6
  Author: Neuronum Cybernetics
@@ -18,6 +18,7 @@ Requires-Dist: click
18
18
  Requires-Dist: questionary
19
19
  Requires-Dist: python-dotenv
20
20
  Requires-Dist: requests
21
+ Requires-Dist: rapidfuzz
21
22
  Dynamic: author
22
23
  Dynamic: author-email
23
24
  Dynamic: classifier
@@ -30,10 +31,23 @@ Dynamic: requires-dist
30
31
  Dynamic: requires-python
31
32
  Dynamic: summary
32
33
 
33
- ![Neuronum Logo](https://neuronum.net/static/logo_pip.png "Neuronum")
34
+ <h1 align="center">
35
+ <img src="https://neuronum.net/static/neuronum.svg" alt="Neuronum" width="100">
36
+ </h1>
37
+ <h4 align="center">Build, connect, and automate serverless data infrastructures with Neuronum</h4>
34
38
 
35
- [![Website](https://img.shields.io/badge/Website-Neuronum-blue)](https://neuronum.net) [![Documentation](https://img.shields.io/badge/Docs-Read%20now-green)](https://github.com/neuronumcybernetics/neuronum)
39
+ <p align="center">
40
+ <a href="https://neuronum.net">
41
+ <img src="https://img.shields.io/badge/Website-Neuronum-blue" alt="Website">
42
+ </a>
43
+ <a href="https://github.com/neuronumcybernetics/neuronum">
44
+ <img src="https://img.shields.io/badge/Docs-Read%20now-green" alt="Documentation">
45
+ </a>
46
+ <img src="https://img.shields.io/badge/Version-5.4.0-blueviolet" alt="Lib Version">
47
+ <img src="https://img.shields.io/badge/Python-3.9%2B-yellow" alt="Python Version">
48
+ </p>
36
49
 
50
+ ---
37
51
 
38
52
  ## **Getting Started Goals**
39
53
  - Learn about Neuronum
@@ -56,10 +70,13 @@ Neuronum is a framework to build serverless connected app & data gateways automa
56
70
  - Circuits (CTX): Store data in cloud-based key-value-label databases
57
71
  - Streams (STX): Stream, synchronize, and control data in real time
58
72
 
73
+ **Cellai**
74
+ - Cellai is a CLI-based assistant that helps you interact with Neuronum
75
+
59
76
 
60
77
  #### Requirements
61
- - Python >= 3.8 -> https://www.python.org/downloads/
62
- - neuronum >= 5.3.0 -> https://pypi.org/project/neuronum/
78
+ - Python >= 3.9 -> https://www.python.org/downloads/
79
+ - neuronum >= 5.4.0 -> https://pypi.org/project/neuronum/
63
80
 
64
81
 
65
82
  ------------------
@@ -76,6 +93,12 @@ Create Cell:
76
93
  neuronum create-cell # create Cell / Cell type / Cell network
77
94
  ```
78
95
 
96
+ or
97
+
98
+ Connect Cell:
99
+ ```sh
100
+ neuronum connect-cell # connect Cell
101
+ ```
79
102
 
80
103
  ------------------
81
104
 
@@ -104,7 +127,18 @@ Visit: https://github.com/neuronumcybernetics/neuronum/tree/main/how_tos/nodes
104
127
 
105
128
 
106
129
  ### **Interact with Neuronum**
130
+ Web-based:
107
131
  1. Visit: https://neuronum.net
108
132
  2. Connect your Cell
109
133
  3. Explore Transmitters
110
134
  4. Activate Transmitters
135
+
136
+ Code-based:
137
+ ```python
138
+ TX = txID # select the Transmitter TX
139
+ data = {
140
+ "say": "hello",
141
+ }
142
+ tx_response = await cell.activate_tx(TX, data) # activate TX - > get response back
143
+ print(tx_response)
144
+ ```
@@ -1,7 +1,20 @@
1
- ![Neuronum Logo](https://neuronum.net/static/logo_pip.png "Neuronum")
2
-
3
- [![Website](https://img.shields.io/badge/Website-Neuronum-blue)](https://neuronum.net) [![Documentation](https://img.shields.io/badge/Docs-Read%20now-green)](https://github.com/neuronumcybernetics/neuronum)
4
-
1
+ <h1 align="center">
2
+ <img src="https://neuronum.net/static/neuronum.svg" alt="Neuronum" width="100">
3
+ </h1>
4
+ <h4 align="center">Build, connect, and automate serverless data infrastructures with Neuronum</h4>
5
+
6
+ <p align="center">
7
+ <a href="https://neuronum.net">
8
+ <img src="https://img.shields.io/badge/Website-Neuronum-blue" alt="Website">
9
+ </a>
10
+ <a href="https://github.com/neuronumcybernetics/neuronum">
11
+ <img src="https://img.shields.io/badge/Docs-Read%20now-green" alt="Documentation">
12
+ </a>
13
+ <img src="https://img.shields.io/badge/Version-5.4.0-blueviolet" alt="Lib Version">
14
+ <img src="https://img.shields.io/badge/Python-3.9%2B-yellow" alt="Python Version">
15
+ </p>
16
+
17
+ ---
5
18
 
6
19
  ## **Getting Started Goals**
7
20
  - Learn about Neuronum
@@ -24,10 +37,13 @@ Neuronum is a framework to build serverless connected app & data gateways automa
24
37
  - Circuits (CTX): Store data in cloud-based key-value-label databases
25
38
  - Streams (STX): Stream, synchronize, and control data in real time
26
39
 
40
+ **Cellai**
41
+ - Cellai is a CLI-based assistant that helps you interact with Neuronum
42
+
27
43
 
28
44
  #### Requirements
29
- - Python >= 3.8 -> https://www.python.org/downloads/
30
- - neuronum >= 5.3.0 -> https://pypi.org/project/neuronum/
45
+ - Python >= 3.9 -> https://www.python.org/downloads/
46
+ - neuronum >= 5.4.0 -> https://pypi.org/project/neuronum/
31
47
 
32
48
 
33
49
  ------------------
@@ -44,6 +60,12 @@ Create Cell:
44
60
  neuronum create-cell # create Cell / Cell type / Cell network
45
61
  ```
46
62
 
63
+ or
64
+
65
+ Connect Cell:
66
+ ```sh
67
+ neuronum connect-cell # connect Cell
68
+ ```
47
69
 
48
70
  ------------------
49
71
 
@@ -72,7 +94,18 @@ Visit: https://github.com/neuronumcybernetics/neuronum/tree/main/how_tos/nodes
72
94
 
73
95
 
74
96
  ### **Interact with Neuronum**
97
+ Web-based:
75
98
  1. Visit: https://neuronum.net
76
99
  2. Connect your Cell
77
100
  3. Explore Transmitters
78
- 4. Activate Transmitters
101
+ 4. Activate Transmitters
102
+
103
+ Code-based:
104
+ ```python
105
+ TX = txID # select the Transmitter TX
106
+ data = {
107
+ "say": "hello",
108
+ }
109
+ tx_response = await cell.activate_tx(TX, data) # activate TX - > get response back
110
+ print(tx_response)
111
+ ```
@@ -0,0 +1,118 @@
1
+ import asyncio
2
+ from rapidfuzz import process
3
+ import neuronum
4
+ import datetime
5
+ from pathlib import Path
6
+
7
+
8
+ def log_interaction(user_input, output, log_path=Path("cellai.log")):
9
+ log_path = Path(log_path)
10
+
11
+ timestamp = datetime.datetime.now().isoformat()
12
+ with open(log_path, "a", encoding="utf-8") as log_file:
13
+ log_file.write(f"[{timestamp}]\n")
14
+ log_file.write(f"USER: {user_input}")
15
+ log_file.write(f"{output}\n\n")
16
+
17
+
18
+ async def main(host, password, network, synapse):
19
+ cell = neuronum.Cell(
20
+ host=host,
21
+ password=password,
22
+ network=network,
23
+ synapse=synapse
24
+ )
25
+
26
+ tx = await cell.list_tx()
27
+ nodes = await cell.list_nodes()
28
+
29
+ transmitters = tx
30
+ transmitters_by_id = {t["txID"]: t for t in transmitters}
31
+
32
+ info_to_gateway = []
33
+ for node in nodes:
34
+ for g in node["Node.md"]["gateways"]:
35
+ info_to_gateway.append({
36
+ "nodeID": node["nodeID"],
37
+ "gateway": g,
38
+ "info": g["info"],
39
+ "descr": node["descr"]
40
+ })
41
+
42
+ print("Cellai: Ready for your instruction!")
43
+ loop = asyncio.get_event_loop()
44
+
45
+ while True:
46
+ try:
47
+ user_input = await loop.run_in_executor(None, input, ">> ")
48
+ user_input = user_input.strip()
49
+ if user_input.lower() in {"exit", "quit"}:
50
+ log_interaction(user_input, "Session ended by user.")
51
+ break
52
+
53
+ match, score, idx = process.extractOne(user_input, [x["info"] for x in info_to_gateway])
54
+ best = info_to_gateway[idx]
55
+
56
+ output_log = (
57
+ f"\nMatched: {match} ({score:.1f}%)\n"
58
+ f"Node: {best['descr']} [{best['nodeID']}]\n"
59
+ f"Gateway: {best['gateway']['id']} ({best['gateway']['type']})"
60
+ )
61
+ print(output_log)
62
+
63
+ if best['gateway']['type'] == "transmitter":
64
+ tx_id = best['gateway']['id']
65
+ tx_data = transmitters_by_id.get(tx_id)
66
+ if tx_data:
67
+ print(f"Executing transmitter: {tx_data['descr']}")
68
+
69
+ dynamic_payload = {}
70
+ for key in tx_data["data"].keys():
71
+ prompt = f"Enter value for '{key}': "
72
+ value = await loop.run_in_executor(None, input, prompt)
73
+ dynamic_payload[key] = value
74
+
75
+ print(f"Payload: {dynamic_payload}")
76
+ TX = tx_id
77
+ tx_response = await cell.activate_tx(TX, dynamic_payload)
78
+ print(tx_response["json"])
79
+ output_log += f"\nTransmitter executed: {tx_data['descr']}\nPayload: {dynamic_payload}\nResponse: {tx_response['json']}"
80
+ else:
81
+ warning = "Transmitter not found."
82
+ print(warning)
83
+ output_log += f"{warning}"
84
+
85
+ elif best['gateway']['type'] == "stream":
86
+ STX = best['gateway']['id']
87
+ print(f"Starting stream sync for STX: {STX}")
88
+ async for operation in cell.sync(STX):
89
+ label = operation.get("label")
90
+ data = operation.get("data")
91
+ ts = operation.get("time")
92
+ stxID = operation.get("stxID")
93
+ operator = operation.get("operator")
94
+ line = f"[{ts}] {label} | Operator: {operator} | STX: {stxID}\nData: {data}"
95
+ print(line)
96
+ output_log += f"\n{line}"
97
+ elif best['gateway']['type'] == "circuit":
98
+ CTX = best['gateway']['id']
99
+ label = await loop.run_in_executor(None, input, "Enter label to load from circuit: ")
100
+ label = label.strip()
101
+ data = await cell.load(label, CTX)
102
+ print(data)
103
+ output_log += f"\nCircuit loaded from CTX: {CTX} with label '{label}'\nData: {data}"
104
+ else:
105
+ msg = "Unknown gateway type."
106
+ print(msg)
107
+ output_log += f"{msg}"
108
+
109
+ log_interaction(user_input, output_log)
110
+
111
+ except KeyboardInterrupt:
112
+ print("\nExiting.")
113
+ log_interaction("KeyboardInterrupt", "Session exited with Ctrl+C")
114
+ break
115
+
116
+
117
+ if __name__ == "__main__":
118
+ asyncio.run(main(host, password, network, synapse))
File without changes
@@ -324,40 +324,24 @@ async def async_init_node(sync, stream, app):
324
324
 
325
325
  ```json
326
326
  {
327
- "info": {
328
- "use_case": "This Node...",
329
- "github": "https://github.com/user"
330
- },
331
327
  "gateways": [
332
328
  {
333
329
  "type": "stream",
334
330
  "id": "id::stx",
335
- "link": "https://neuronum.net/stream/id::stx"
331
+ "link": "https://neuronum.net/stream/id::stx",
332
+ "info": "stream info"
336
333
  },
337
334
  {
338
335
  "type": "transmitter",
339
336
  "id": "id::tx",
340
- "link": "https://neuronum.net/tx/id::tx",
341
- }
337
+ "link": "https://neuronum.net/tx/id::tx",
338
+ "info": "transmitter info"
339
+ },
342
340
  {
343
341
  "type": "circuit",
344
342
  "id": "id::ctx",
345
- "link": "https://neuronum.net/circuit/id::ctx",
346
- }
347
- ],
348
- "initialization": {
349
- "command": "neuronum init-node --sync id::stx"
350
- },
351
- "requirements": [
352
- {
353
- "name": "Python",
354
- "version": ">= 3.8",
355
- "link": "https://www.python.org/downloads/"
356
- },
357
- {
358
- "name": "neuronum",
359
- "version": ">= 5.1.0",
360
- "link": "https://pypi.org/project/neuronum/"
343
+ "link": "https://neuronum.net/circuit/id::ctx",
344
+ "info": "circuit info"
361
345
  }
362
346
  ]
363
347
  }
@@ -888,6 +872,42 @@ async def async_delete_node():
888
872
  click.echo(f"Neuronum Node '{nodeID}' deleted!")
889
873
 
890
874
 
875
+ @click.command()
876
+ def call_cellai():
877
+ try:
878
+ credentials_folder_path = Path.home() / ".neuronum"
879
+ env_path = credentials_folder_path / ".env"
880
+
881
+ env_data = {}
882
+
883
+ try:
884
+ with open(env_path, "r") as f:
885
+ for line in f:
886
+ key, value = line.strip().split("=")
887
+ env_data[key] = value
888
+
889
+ host = env_data.get("HOST", "")
890
+ password = env_data.get("PASSWORD", "")
891
+ network = env_data.get("NETWORK", "")
892
+ synapse = env_data.get("SYNAPSE", "")
893
+ except FileNotFoundError:
894
+ click.echo("No cell connected. Connect your cell with command neuronum connect-cell")
895
+ return
896
+ except Exception as e:
897
+ click.echo(f"Error reading .env file: {e}")
898
+ return
899
+
900
+ from cellai import cellai
901
+ asyncio.run(cellai.main(host, password, network, synapse))
902
+
903
+ except FileNotFoundError:
904
+ click.echo("Error: .env with credentials not found")
905
+ except ImportError:
906
+ click.echo("Cellai not found. Please check the necessary dependencies.")
907
+ except Exception as e:
908
+ click.echo(f"Unexpected error: {e}")
909
+
910
+
891
911
  cli.add_command(create_cell)
892
912
  cli.add_command(connect_cell)
893
913
  cli.add_command(view_cell)
@@ -900,6 +920,7 @@ cli.add_command(connect_node)
900
920
  cli.add_command(update_node)
901
921
  cli.add_command(disconnect_node)
902
922
  cli.add_command(delete_node)
923
+ cli.add_command(call_cellai)
903
924
 
904
925
 
905
926
  if __name__ == "__main__":
@@ -92,8 +92,6 @@ class Cell:
92
92
  try:
93
93
  async with websockets.connect(full_url) as ws:
94
94
  await ws.send(json.dumps(auth_payload))
95
- print("Listening to Stream...")
96
-
97
95
  try:
98
96
  while True:
99
97
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuronum
3
- Version: 5.3.0
3
+ Version: 5.4.1
4
4
  Summary: Official client library to interact with the Neuronum Network
5
5
  Home-page: https://neuronum.net
6
6
  Author: Neuronum Cybernetics
@@ -18,6 +18,7 @@ Requires-Dist: click
18
18
  Requires-Dist: questionary
19
19
  Requires-Dist: python-dotenv
20
20
  Requires-Dist: requests
21
+ Requires-Dist: rapidfuzz
21
22
  Dynamic: author
22
23
  Dynamic: author-email
23
24
  Dynamic: classifier
@@ -30,10 +31,23 @@ Dynamic: requires-dist
30
31
  Dynamic: requires-python
31
32
  Dynamic: summary
32
33
 
33
- ![Neuronum Logo](https://neuronum.net/static/logo_pip.png "Neuronum")
34
+ <h1 align="center">
35
+ <img src="https://neuronum.net/static/neuronum.svg" alt="Neuronum" width="100">
36
+ </h1>
37
+ <h4 align="center">Build, connect, and automate serverless data infrastructures with Neuronum</h4>
34
38
 
35
- [![Website](https://img.shields.io/badge/Website-Neuronum-blue)](https://neuronum.net) [![Documentation](https://img.shields.io/badge/Docs-Read%20now-green)](https://github.com/neuronumcybernetics/neuronum)
39
+ <p align="center">
40
+ <a href="https://neuronum.net">
41
+ <img src="https://img.shields.io/badge/Website-Neuronum-blue" alt="Website">
42
+ </a>
43
+ <a href="https://github.com/neuronumcybernetics/neuronum">
44
+ <img src="https://img.shields.io/badge/Docs-Read%20now-green" alt="Documentation">
45
+ </a>
46
+ <img src="https://img.shields.io/badge/Version-5.4.0-blueviolet" alt="Lib Version">
47
+ <img src="https://img.shields.io/badge/Python-3.9%2B-yellow" alt="Python Version">
48
+ </p>
36
49
 
50
+ ---
37
51
 
38
52
  ## **Getting Started Goals**
39
53
  - Learn about Neuronum
@@ -56,10 +70,13 @@ Neuronum is a framework to build serverless connected app & data gateways automa
56
70
  - Circuits (CTX): Store data in cloud-based key-value-label databases
57
71
  - Streams (STX): Stream, synchronize, and control data in real time
58
72
 
73
+ **Cellai**
74
+ - Cellai is a CLI-based assistant that helps you interact with Neuronum
75
+
59
76
 
60
77
  #### Requirements
61
- - Python >= 3.8 -> https://www.python.org/downloads/
62
- - neuronum >= 5.3.0 -> https://pypi.org/project/neuronum/
78
+ - Python >= 3.9 -> https://www.python.org/downloads/
79
+ - neuronum >= 5.4.0 -> https://pypi.org/project/neuronum/
63
80
 
64
81
 
65
82
  ------------------
@@ -76,6 +93,12 @@ Create Cell:
76
93
  neuronum create-cell # create Cell / Cell type / Cell network
77
94
  ```
78
95
 
96
+ or
97
+
98
+ Connect Cell:
99
+ ```sh
100
+ neuronum connect-cell # connect Cell
101
+ ```
79
102
 
80
103
  ------------------
81
104
 
@@ -104,7 +127,18 @@ Visit: https://github.com/neuronumcybernetics/neuronum/tree/main/how_tos/nodes
104
127
 
105
128
 
106
129
  ### **Interact with Neuronum**
130
+ Web-based:
107
131
  1. Visit: https://neuronum.net
108
132
  2. Connect your Cell
109
133
  3. Explore Transmitters
110
134
  4. Activate Transmitters
135
+
136
+ Code-based:
137
+ ```python
138
+ TX = txID # select the Transmitter TX
139
+ data = {
140
+ "say": "hello",
141
+ }
142
+ tx_response = await cell.activate_tx(TX, data) # activate TX - > get response back
143
+ print(tx_response)
144
+ ```
@@ -1,6 +1,8 @@
1
1
  LICENSE
2
2
  README.md
3
3
  setup.py
4
+ cellai/__init__.py
5
+ cellai/cellai.py
4
6
  cli/__init__.py
5
7
  cli/main.py
6
8
  neuronum/__init__.py
@@ -4,3 +4,4 @@ click
4
4
  questionary
5
5
  python-dotenv
6
6
  requests
7
+ rapidfuzz
@@ -1,2 +1,3 @@
1
+ cellai
1
2
  cli
2
3
  neuronum
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neuronum',
5
- version='5.3.0',
5
+ version='5.4.1',
6
6
  author='Neuronum Cybernetics',
7
7
  author_email='welcome@neuronum.net',
8
8
  description='Official client library to interact with the Neuronum Network',
@@ -12,7 +12,7 @@ setup(
12
12
  project_urls={
13
13
  "GitHub": "https://github.com/neuronumcybernetics/neuronum",
14
14
  },
15
- packages=find_packages(include=["neuronum", "cli"]),
15
+ packages=find_packages(include=["neuronum", "cellai", "cli"]),
16
16
  classifiers=[
17
17
  "Programming Language :: Python :: 3",
18
18
  "License :: OSI Approved :: MIT License",
@@ -26,6 +26,7 @@ setup(
26
26
  'questionary',
27
27
  'python-dotenv',
28
28
  'requests',
29
+ 'rapidfuzz',
29
30
  ],
30
31
  entry_points={
31
32
  "console_scripts": [
File without changes
File without changes
File without changes