unaiverse 0.1.12__py3-none-any.whl
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.
- unaiverse/__init__.py +19 -0
- unaiverse/agent.py +2226 -0
- unaiverse/agent_basics.py +2389 -0
- unaiverse/clock.py +234 -0
- unaiverse/dataprops.py +1282 -0
- unaiverse/hsm.py +2471 -0
- unaiverse/modules/__init__.py +18 -0
- unaiverse/modules/cnu/__init__.py +17 -0
- unaiverse/modules/cnu/cnus.py +536 -0
- unaiverse/modules/cnu/layers.py +261 -0
- unaiverse/modules/cnu/psi.py +60 -0
- unaiverse/modules/hl/__init__.py +15 -0
- unaiverse/modules/hl/hl_utils.py +411 -0
- unaiverse/modules/networks.py +1509 -0
- unaiverse/modules/utils.py +748 -0
- unaiverse/networking/__init__.py +16 -0
- unaiverse/networking/node/__init__.py +18 -0
- unaiverse/networking/node/connpool.py +1332 -0
- unaiverse/networking/node/node.py +2752 -0
- unaiverse/networking/node/profile.py +446 -0
- unaiverse/networking/node/tokens.py +79 -0
- unaiverse/networking/p2p/__init__.py +188 -0
- unaiverse/networking/p2p/go.mod +127 -0
- unaiverse/networking/p2p/go.sum +548 -0
- unaiverse/networking/p2p/golibp2p.py +18 -0
- unaiverse/networking/p2p/golibp2p.pyi +136 -0
- unaiverse/networking/p2p/lib.go +2765 -0
- unaiverse/networking/p2p/lib_types.py +311 -0
- unaiverse/networking/p2p/message_pb2.py +50 -0
- unaiverse/networking/p2p/messages.py +360 -0
- unaiverse/networking/p2p/mylogger.py +78 -0
- unaiverse/networking/p2p/p2p.py +900 -0
- unaiverse/networking/p2p/proto-go/message.pb.go +846 -0
- unaiverse/stats.py +1506 -0
- unaiverse/streamlib/__init__.py +15 -0
- unaiverse/streamlib/streamlib.py +210 -0
- unaiverse/streams.py +804 -0
- unaiverse/utils/__init__.py +16 -0
- unaiverse/utils/lone_wolf.json +28 -0
- unaiverse/utils/misc.py +441 -0
- unaiverse/utils/sandbox.py +292 -0
- unaiverse/world.py +384 -0
- unaiverse-0.1.12.dist-info/METADATA +366 -0
- unaiverse-0.1.12.dist-info/RECORD +47 -0
- unaiverse-0.1.12.dist-info/WHEEL +5 -0
- unaiverse-0.1.12.dist-info/licenses/LICENSE +177 -0
- unaiverse-0.1.12.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unaiverse
|
|
3
|
+
Version: 0.1.12
|
|
4
|
+
Summary: UNaIVERSE: A Collectionless AI Project. The new web of humans & AI Agents, built on privacy, control, and reduced energy consumption.
|
|
5
|
+
Author-email: Stefano Melacci <stefano.melacci@unisi.it>, Christian Di Maio <christian.dimaio@phd.unipi.it>, Tommaso Guidi <tommaso.guidi.1998@gmail.com>
|
|
6
|
+
Maintainer-email: Stefano Melacci <stefano.melacci@unisi.it>, Christian Di Maio <christian.dimaio@phd.unipi.it>, Tommaso Guidi <tommaso.guidi.1998@gmail.com>
|
|
7
|
+
Project-URL: A-Homepage, https://unaiverse.io
|
|
8
|
+
Project-URL: B-CollectionlessAI, https://collectionless.ai
|
|
9
|
+
Project-URL: C-Source, https://github.com/collectionlessai/unaiverse-src
|
|
10
|
+
Project-URL: D-Starting, https://github.com/collectionlessai/unaiverse-src/blob/main/README.md
|
|
11
|
+
Project-URL: E-Examples, https://github.com/collectionlessai/unaiverse-examples
|
|
12
|
+
Project-URL: F-Documentation, https://github.com/collectionlessai/unaiverse-src/blob/main/README.md
|
|
13
|
+
Keywords: UNaIVERSE,Collectionless AI,AI,Agentic AI,Agents,Machine Learning,Learning Over Time
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: opencv-python
|
|
25
|
+
Requires-Dist: Flask
|
|
26
|
+
Requires-Dist: flask_cors
|
|
27
|
+
Requires-Dist: graphviz
|
|
28
|
+
Requires-Dist: ntplib
|
|
29
|
+
Requires-Dist: numpy
|
|
30
|
+
Requires-Dist: Pillow
|
|
31
|
+
Requires-Dist: protobuf
|
|
32
|
+
Requires-Dist: psutil
|
|
33
|
+
Requires-Dist: PyJWT
|
|
34
|
+
Requires-Dist: cryptography
|
|
35
|
+
Requires-Dist: Requests
|
|
36
|
+
Requires-Dist: torch
|
|
37
|
+
Requires-Dist: torchvision
|
|
38
|
+
Requires-Dist: transformers
|
|
39
|
+
Requires-Dist: sortedcontainers
|
|
40
|
+
Requires-Dist: plotly
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
<div align="center">
|
|
44
|
+
<h1 style="text-align: center;">Welcome to UNaIVERSE ~ https://unaiverse.io</h1>
|
|
45
|
+
<img src="./assets/caicat_planets.png" alt="UNaIVERSE Logo" style="width:450px;">
|
|
46
|
+
</div>
|
|
47
|
+
<br>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<em>Welcome to a new "UN(a)IVERSE," where humans and artificial agents coexist, interact, learn from each other, grow together, in a privacy and low-energy oriented reality.</em>
|
|
51
|
+
</p>
|
|
52
|
+
<br>
|
|
53
|
+
|
|
54
|
+
UNaIVERSE is a project framed in the context of [Collectionless AI](https://collectionless.ai), our perspective on Artificial Intelligence rooted in **privacy**, **low energy consumption**, and, more importantly, a **decentralized** model.
|
|
55
|
+
|
|
56
|
+
UN(a)IVERSE is a **peer-to-peer network**, aiming to become the new incarnation of the Web, combining (in the long run) the principles of Social Networks and AI under a **privacy** lens—a perspective that is crucial given how the Web, especially Social Networks, and AI are used today by both businesses and individual users.
|
|
57
|
+
|
|
58
|
+
- Enter UNaIVERSE: [**UNaIVERSE portal (login/register)**](https://unaiverse.io)
|
|
59
|
+
- Check our preprint of Collectionless AI & UNaIVERSE, to explore [**UNaIVERSE features**](./UNaIVERSE_techrep.pdf)
|
|
60
|
+
- Read more on our ideas: [**Collectionless AI website**](https://collectionless.ai)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🚀 Features
|
|
65
|
+
|
|
66
|
+
Check our presentation, starting from Collectionless AI and ending up in [**UNaIVERSE and its features**](./UNaIVERSE.pdf).
|
|
67
|
+
|
|
68
|
+
UNaIVERSE is a peer-to-peer network where each node is either a **world** or an **agent**. What can you do?
|
|
69
|
+
- You can create your own **agents**, based on [PyTorch modules](https://pytorch.org/), and, in function of their capabilities, they are ready to join the existing worlds and interact with others. Feel free to join a world, stay there for a while, leave it and join another one! They can also just showcase your technology, hence not join any worlds, becoming what we call **lone wolves**.
|
|
70
|
+
- You can create your own **worlds** as well. Different worlds are about different topics, tasks, whatever (think about a school, a shop, a chat room, an industrial plant, ...), and you don't have to write any code to let your agent participate in a world! It is the world designer that defines the expected **roles** and corresponding agent **behaviors** (special State Machines): join a world, get a role, and you are ready to behave coherently with your role!
|
|
71
|
+
- In UNaIVERSE, you, as **human**, are an agent as the other ones. The browser is your interface to UNaIVERSE, and you are already set up! No need to install anything, just jump into the UNaIVERSE portal, login, and you are a citizen of UNaIVERSE.
|
|
72
|
+
|
|
73
|
+
Remarks:
|
|
74
|
+
- *Are you a researcher?* This is perfect to study models that learn over time (Lifelong/Continual Learning), and social dynamics of different categories of models! Feel free to propose novel ideas to exploit UNaIVERSE in your research!
|
|
75
|
+
- *Are you in the industry or, more generally, business oriented?* **Think about privacy-oriented solutions that we can build over this new UN(a)IVERSE!**
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## ⚡ Status
|
|
80
|
+
|
|
81
|
+
- Very first version: we think it will always stay alpha/beta/whatever 😎, but right now there are many features we plan to add and several parts to improve, **thanks to your feedback!**
|
|
82
|
+
- Missing features (work-in-progress): mobile agents running on dedicated Web App; build customizable UIs for human agents in the browser; fully decentralized discovery of new Peers; actual social network features (right now it is very preliminary, not really showcasing where we want to go)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 📦 Installation
|
|
87
|
+
|
|
88
|
+
Jump to [https://unaiverse.io](https://unaiverse.io), create a new account (free!) or log in with an existing one. If you did not already do it, click on the top-right icon with "a person" on it:
|
|
89
|
+
|
|
90
|
+
<img src="./assets/unaiverse8443-me.png" alt="UNaIVERSE Logo" style="width:150px;">
|
|
91
|
+
|
|
92
|
+
Then click on "Generate a Token":
|
|
93
|
+
|
|
94
|
+
<img src="./assets/unaiverse8443-token.png" alt="UNaIVERSE Logo" style="width:500px;">
|
|
95
|
+
|
|
96
|
+
**COPY THE TOKEN**, you won't be able to see it twice! Now, let's focus on Python:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install unaiverse
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
That's it. Of course, if you want to dive into details, you find the source code here in this repo.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🛠 Mini Tutorial
|
|
107
|
+
|
|
108
|
+
The simplest usage you can think of is the one which does not exploit the real features of UNaIVERSE, but it is so simple that is a good way to put you in touch with UNaIVERSE itself.
|
|
109
|
+
|
|
110
|
+
You can **showcase** your PyTorch networks (actually, it can be every kind of model son of the PyTorch [*torch.nn.Module*](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html) class) as follows. Let's focus on ResNet for simplicity.
|
|
111
|
+
|
|
112
|
+
Alright, let's discuss the code in the [assets/tutorial](./assets/tutorial) folder of this repo, composed of numbered scripts.
|
|
113
|
+
|
|
114
|
+
### Step A1. Do you know how to set up a network in PyTorch?
|
|
115
|
+
|
|
116
|
+
Let us set up a ResNet50 in the most basic PyTorch manner. The code is composed of a **generator of tensors** interpreted as pictures (actually, an ugly tensor with randomly colored pixels) and a pretrained **resnet classifier** which classifies the pictures generating a probability distribution over 1,000 classes. Try to run [script 1](./assets/tutorial/A_move_to_unaiverse/1_generator_and_resnet.py) from the [assets/tutorial](./assets/tutorial) folder. We report it here, carefully read the comments!
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
import torch
|
|
120
|
+
import torchvision
|
|
121
|
+
|
|
122
|
+
# Downloading PyTorch module (ResNet)
|
|
123
|
+
net = torchvision.models.resnet50(weights="IMAGENET1K_V1").eval()
|
|
124
|
+
|
|
125
|
+
# Generating a random image (don't care about it, it is just a toy example,
|
|
126
|
+
# think it is a nice image!)
|
|
127
|
+
inp = torch.rand((1, 3, 224, 224), dtype=torch.float32)
|
|
128
|
+
|
|
129
|
+
# Inference: expects as input a tensor of type torch.float32, custom width and
|
|
130
|
+
# height, but 3 channels and batch dimension must be there; the output is a
|
|
131
|
+
# tensor with shape (1, 1000), i.e., a tensor in which batch dimension is
|
|
132
|
+
# present and then 1000 elements.
|
|
133
|
+
out = net(inp)
|
|
134
|
+
|
|
135
|
+
# Print shapes
|
|
136
|
+
print(f"Input shape: {tuple(inp.shape)}, dtype: {inp.dtype}")
|
|
137
|
+
print(f"Output shape: {tuple(out.shape)}, dtype: {out.dtype}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Step A2. Let's create UNaIVERSE agents!
|
|
141
|
+
|
|
142
|
+
We are going to create two agents, **independently running and possibly located in different places/machines**.
|
|
143
|
+
- One is based on the **resnet classifier**, waiting to be asked (by some other agents) for a prediction about a given image.
|
|
144
|
+
- The other is the **generator of tensors**, ready to generate a tensor (representation of a picture) and ask another agent to classify it.
|
|
145
|
+
|
|
146
|
+
Here is the **resnet classifier** agent, running forever and waiting for somebody to ask for a prediction, taken from [script 2](./assets/tutorial/A_move_to_unaiverse/2_agent_resnet.py) in the [assets/tutorial](./assets/tutorial) folder:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
import torch
|
|
150
|
+
import torchvision
|
|
151
|
+
from unaiverse.agent import Agent
|
|
152
|
+
from unaiverse.dataprops import Data4Proc
|
|
153
|
+
from unaiverse.networking.node.node import Node
|
|
154
|
+
|
|
155
|
+
# Downloading PyTorch module (ResNet)
|
|
156
|
+
net = torchvision.models.resnet50(weights="IMAGENET1K_V1").eval()
|
|
157
|
+
|
|
158
|
+
# Agent: we pass the network as "processor".
|
|
159
|
+
# Check the input and output properties of the processor, they are coherent with the
|
|
160
|
+
# input and output shapes of ResNet; here "None" means "whatever, but this axis must be
|
|
161
|
+
# there!". By default, this agent will act as a serving "lone wolf", serving whoever asks for
|
|
162
|
+
# a prediction.
|
|
163
|
+
agent = Agent(proc=net,
|
|
164
|
+
proc_inputs=[Data4Proc(data_type="tensor", tensor_shape=(None, 3, None, None),
|
|
165
|
+
tensor_dtype=torch.float32)],
|
|
166
|
+
proc_outputs=[Data4Proc(data_type="tensor", tensor_shape=(None, 1000),
|
|
167
|
+
tensor_dtype=torch.float32)])
|
|
168
|
+
|
|
169
|
+
# Node hosting agent: a node will be created in your account with this name, if not
|
|
170
|
+
# existing; it is "hidden" meaning that only you can see it in UNaIVERSE (since it is
|
|
171
|
+
# just a test!); the clock speed can be tuned accordingly to your needed and computing
|
|
172
|
+
# power.
|
|
173
|
+
node = Node(node_name="Test0", hosted=agent, hidden=True, clock_delta=1. / 5.)
|
|
174
|
+
|
|
175
|
+
# Running node (forever)
|
|
176
|
+
node.run()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Run it. Now, here is the agent capable of **generating tensors** (let's say images), which is asked to get in touch with the resnet agent, taken from [script 3](./assets/tutorial/A_move_to_unaiverse/3_agent_generator.py) in the [assets/tutorial](./assets/tutorial) folder:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
import torch
|
|
183
|
+
from unaiverse.agent import Agent
|
|
184
|
+
from unaiverse.dataprops import Data4Proc
|
|
185
|
+
from unaiverse.networking.node.node import Node
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# Custom generator network: a module that simply generates an image with
|
|
189
|
+
# "random" pixel intensities; we will use this as processor of our new agent.
|
|
190
|
+
class Net(torch.nn.Module):
|
|
191
|
+
def __init__(self):
|
|
192
|
+
super().__init__()
|
|
193
|
+
|
|
194
|
+
# The input will be ignored, and a default None value is needed
|
|
195
|
+
def forward(self, x: torch.Tensor | None = None):
|
|
196
|
+
inp = torch.rand((1, 3, 224, 224), dtype=torch.float32)
|
|
197
|
+
print(f"Generated data shape: {tuple(inp.shape)}, dtype: {inp.dtype}")
|
|
198
|
+
return inp
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
# Agent: we use the generator as processor.
|
|
202
|
+
agent = Agent(proc=Net(),
|
|
203
|
+
proc_inputs=[Data4Proc(data_type="all")], # Able to get every type of data (since it won't use it :))
|
|
204
|
+
proc_outputs=[Data4Proc(data_type="tensor", tensor_shape=(1, 3, 224, 224),
|
|
205
|
+
tensor_dtype="torch.float32")], # These are the properties of generator output
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# To retrieve the result we got from the ResNet agent, we define a hook
|
|
209
|
+
# that will be called at the end of every run cycle
|
|
210
|
+
def hook(_node: Node):
|
|
211
|
+
# Printing the last received data from the ResNet agent
|
|
212
|
+
_out = _node.agent.get_last_streamed_data('Test0')[0]
|
|
213
|
+
if _out is not None:
|
|
214
|
+
_node.agent.print(f"Received data shape: {tuple(_out.shape)}, dtype: {_out.dtype}")
|
|
215
|
+
|
|
216
|
+
# Node hosting agent
|
|
217
|
+
node = Node(node_name="Test1", hosted=agent, hidden=True, clock_delta=1. / 5., run_hook=hook)
|
|
218
|
+
|
|
219
|
+
# Running node for 10 seconds
|
|
220
|
+
node.run(get_in_touch="Test0", max_time=10.0)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Run this script as well, and what will happen is that the generator will send its picture through the peer-to-peer network, reaching the resnet agent, and getting back a prediction.
|
|
224
|
+
|
|
225
|
+
### Step B1. Embellishment
|
|
226
|
+
|
|
227
|
+
We can upgrade the **resnet agent** to take real-world images as input, instead of random tensors, and to output class names (text) instead of a probability distribution. All we need to do is to re-define the properties of the inputs/outputs of the agent processor, and add transformations. Dive into [script 4](./assets/tutorial/B_improve_A_and_use_browser/4_agent_resnet_img_text.py):
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
import torchvision
|
|
231
|
+
import urllib.request
|
|
232
|
+
from unaiverse.agent import Agent
|
|
233
|
+
from unaiverse.dataprops import Data4Proc
|
|
234
|
+
from unaiverse.networking.node.node import Node
|
|
235
|
+
|
|
236
|
+
# Downloading PyTorch module (ResNet)
|
|
237
|
+
net = torchvision.models.resnet50(weights="IMAGENET1K_V1").eval()
|
|
238
|
+
|
|
239
|
+
# Getting input transforms from PyTorch model
|
|
240
|
+
transforms = torchvision.transforms.Compose([
|
|
241
|
+
torchvision.transforms.Lambda(lambda x: x.convert("RGB")),
|
|
242
|
+
torchvision.models.ResNet50_Weights.IMAGENET1K_V1.transforms(),
|
|
243
|
+
torchvision.transforms.Lambda(lambda x: x.unsqueeze(0))
|
|
244
|
+
])
|
|
245
|
+
|
|
246
|
+
# Getting output class names
|
|
247
|
+
with urllib.request.urlopen("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt") as f:
|
|
248
|
+
c_names = [line.strip().decode('utf-8') for line in f.readlines()]
|
|
249
|
+
|
|
250
|
+
# Agent: we change the data type, to be able to handle stream of images (instead of tensors).
|
|
251
|
+
# We can customize the transformations from the streamed format to the processor inference
|
|
252
|
+
# format (every callable function is fine!). Similarly, we can customize the way we go from
|
|
253
|
+
# the actual output of the processor and what will be streamed (here we go from class
|
|
254
|
+
# probabilities to winning class name).
|
|
255
|
+
agent = Agent(proc=net,
|
|
256
|
+
proc_inputs=[Data4Proc(data_type="img", stream_to_proc_transforms=transforms)],
|
|
257
|
+
proc_outputs=[Data4Proc(data_type="text", proc_to_stream_transforms=lambda p: c_names[p.argmax(1)[0]])])
|
|
258
|
+
|
|
259
|
+
# Node hosting agent
|
|
260
|
+
node = Node(node_name="Test0", hosted=agent, hidden=True, clock_delta=1. / 5.)
|
|
261
|
+
|
|
262
|
+
# Running node
|
|
263
|
+
node.run()
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Now let us promote the **generator** to an agent that downloads and offers a picture of a cat and expects to get back a text description of it (the class name in this case - this is [script 5](./assets/tutorial/B_improve_A_and_use_browser/5_agent_generator_img.py)):
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
import torch
|
|
270
|
+
import urllib.request
|
|
271
|
+
from PIL import Image
|
|
272
|
+
from io import BytesIO
|
|
273
|
+
from unaiverse.agent import Agent
|
|
274
|
+
from unaiverse.dataprops import Data4Proc
|
|
275
|
+
from unaiverse.networking.node.node import Node
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
# Image offering network: a module that simpy downloads and offers an image as its output
|
|
279
|
+
class Net(torch.nn.Module):
|
|
280
|
+
def __init__(self):
|
|
281
|
+
super().__init__()
|
|
282
|
+
|
|
283
|
+
def forward(self, x: torch.Tensor | None = None):
|
|
284
|
+
with urllib.request.urlopen("https://cataas.com/cat") as response:
|
|
285
|
+
inp = Image.open(BytesIO(response.read()))
|
|
286
|
+
# inp.show() # Let's see the pic (watch out: random pic with a cat somewhere)
|
|
287
|
+
print(f"Downloaded image shape {inp.size}, type: {type(inp)}, expected-content: cat")
|
|
288
|
+
return inp
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
# Agent
|
|
292
|
+
agent = Agent(proc=Net(),
|
|
293
|
+
proc_inputs=[Data4Proc(data_type="all")],
|
|
294
|
+
proc_outputs=[Data4Proc(data_type="img")], # A PIL image is being "generated" here
|
|
295
|
+
behav_lone_wolf="ask")
|
|
296
|
+
|
|
297
|
+
# To retrieve the result we got from the ResNet agent, we define a hook
|
|
298
|
+
# that will be called at the end of every run cycle
|
|
299
|
+
def hook(_node: Node):
|
|
300
|
+
# Printing the last received data from the ResNet agent
|
|
301
|
+
out = _node.agent.get_last_streamed_data('Test0')[0]
|
|
302
|
+
_node.agent.print(f"Received response: {out}") # Now we expect a textual response
|
|
303
|
+
_node.agent.print("")
|
|
304
|
+
_node.agent.print(f"Notice: instead of using this agent, you can also: search for the ResNet node (ResNetAgent) "
|
|
305
|
+
f"in the UNaIVERSE portal, connect to it using our in-browser agent, select a picture from "
|
|
306
|
+
f"your disk, send it to the agent, get back the text response!")
|
|
307
|
+
|
|
308
|
+
# Node hosting agent
|
|
309
|
+
node = Node(node_name="Test1", hosted=agent, hidden=True, clock_delta=1. / 5., run_hook=hook)
|
|
310
|
+
|
|
311
|
+
# Running node for 45 seconds
|
|
312
|
+
node.run(max_time=45.0, get_in_touch="Test0")
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Step B2. Connect to your ResNet agent by means of a browser running agent!
|
|
316
|
+
|
|
317
|
+
Instead of using the artificial generator agent, **you can become the generator agent**!
|
|
318
|
+
Search for the ResNet node (ResNetAgent) in the UNaIVERSE portal, connect to it using the in-browser agent, select a picture from your disk, send it to the agent, get back the text response!
|
|
319
|
+
|
|
320
|
+
### Step C. Unleash UNaIVERSE!
|
|
321
|
+
|
|
322
|
+
What you did so far is just to showcase your model. UNaIVERSE is composed of several **worlds** that you can create and customize. Your agent can enter one world at a time, stay there, leave it, enter another, and so on.
|
|
323
|
+
Agents will behave according to what the world indicates, and you don't have to write any extra code to act in worlds you have never been into!
|
|
324
|
+
|
|
325
|
+
Alright, there are so many things to say, but examples are always a good thing!
|
|
326
|
+
We prepared a repository with examples of many worlds and different lone wolves, go there in order to continue your journey into UNaIVERSE!
|
|
327
|
+
|
|
328
|
+
*THE TUTORIAL CONTINUES:* [https://github.com/collectionlessai/unaiverse-examples](https://github.com/collectionlessai/unaiverse-examples)
|
|
329
|
+
|
|
330
|
+
**See you in our UNaIVERSE!**
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## 📄 License
|
|
335
|
+
|
|
336
|
+
This project is licensed under the Apache 2.0 License.
|
|
337
|
+
Commercial licenses can be provided.
|
|
338
|
+
See the [LICENSE](./LICENSE) file for details (research, etc.).
|
|
339
|
+
See the Contributor License Agreement [CLA.md](./CLA.md) if you want to contribute.
|
|
340
|
+
This project includes third-party libraries. See [THIRD_PARTY_LICENSES.md](./THIRD_PARTY_LICENSES.md) for details.
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## 📚 Documentation
|
|
345
|
+
|
|
346
|
+
You can find an API reference in file [docs.html](./docs.html), that you can visualize here:
|
|
347
|
+
- [API Reference](https://collectionlessai.github.io/unaiverse-docs.github.io/)
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## 🤝 Contributing
|
|
352
|
+
|
|
353
|
+
Contributions are welcome!
|
|
354
|
+
|
|
355
|
+
Please contact us in order to suggest changes, report bugs, and suggest ideas for novel applications based on UNaIVERSE!
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 👨💻 Main Authors
|
|
360
|
+
|
|
361
|
+
- Stefano Melacci (Project Leader) [stefano.melacci@unisi.it](stefano.melacci@unisi.it)
|
|
362
|
+
- Christian Di Maio [christian.dimaio@phd.unipi.it](christian.dimaio@phd.unipi.it)
|
|
363
|
+
- Tommaso Guidi [tommaso.guidi.1998@gmail.com](tommaso.guidi.1998@gmail.com)
|
|
364
|
+
- Marco Gori (Scientific Advisor) [marco.gori@unisi.it](marco.gori@unisi.it)
|
|
365
|
+
|
|
366
|
+
---
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
unaiverse/__init__.py,sha256=YYNWMcC8LVmLLVaHYQLTc_BDhEOq3OKeIsvsX4MloSQ,2515
|
|
2
|
+
unaiverse/agent.py,sha256=KIsyfQd_e85w0ljAc3-u8hDia7On7R6JjOkHx6Rsyg0,114439
|
|
3
|
+
unaiverse/agent_basics.py,sha256=T27KnHSavbXLPAZXG7IoVTeq80Ig6p0EP5H-0rLN-6s,122689
|
|
4
|
+
unaiverse/clock.py,sha256=RfJarEnUj2m6H3ky1wIxR34-2J4DjhfXhp_flizfL_M,11377
|
|
5
|
+
unaiverse/dataprops.py,sha256=HOHN2hLJuGOIMZIZnTouQHhJOHY10kQ6aNCO9iiVDZk,57881
|
|
6
|
+
unaiverse/hsm.py,sha256=PXKF_FSgQoApPcYHnzJWFSoE_wQRhd2Vd6KToqULYLE,116287
|
|
7
|
+
unaiverse/stats.py,sha256=RVePMNNbHt-uM3n9uC1iphOAkHRuWUmp0vsHte9Vep0,64970
|
|
8
|
+
unaiverse/streams.py,sha256=wocEQvzN_oh9xkI8fe_bFafPtApb9eSaKtTrxMwJRmQ,32379
|
|
9
|
+
unaiverse/world.py,sha256=7cEc9VIozgiS9UR40CsWjG10CSKXlimRLM1K1SycFSA,18920
|
|
10
|
+
unaiverse/modules/__init__.py,sha256=dqddn8Z5cggyU3ZaIC4cZk69Y0Xe7AquEGa9UFOfiKk,2501
|
|
11
|
+
unaiverse/modules/networks.py,sha256=qpOXni5WWZ0RUjk2iym3e12WhgQeBXanx8VLM8K-3a0,65977
|
|
12
|
+
unaiverse/modules/utils.py,sha256=99YUDAjNQnfZgjoj0IODmSrCoOGP3Y5j5cd_8HUAOKM,34969
|
|
13
|
+
unaiverse/modules/cnu/__init__.py,sha256=qOHbNfhk_aJsoCPecPSo5QoWHVEbwaGsyQxXDt2wGho,2481
|
|
14
|
+
unaiverse/modules/cnu/cnus.py,sha256=HjWgeYWCLMowbyRMEPywzewjBEx3OPrThmJQjZkElQA,27614
|
|
15
|
+
unaiverse/modules/cnu/layers.py,sha256=KnZa5_GvAZhCgfB_FpbFj4Ps82mZ1uE_nuKvOIP83gk,13221
|
|
16
|
+
unaiverse/modules/cnu/psi.py,sha256=Kp4sWFtY6howuOdIGWZf0GSyrcr0fQzu3_Jpug7-9ro,3890
|
|
17
|
+
unaiverse/modules/hl/__init__.py,sha256=zG1j2LCuLKOAdOc5csSs52yLSyjHllF96z0hPn-pY1o,2446
|
|
18
|
+
unaiverse/modules/hl/hl_utils.py,sha256=Xt2eWuwak6kDtTy2hQ1Ps8_M_REtte9HA-PzfCovlA8,18292
|
|
19
|
+
unaiverse/networking/__init__.py,sha256=qc3A8KJpTLFM6hefwmqj-wAaUULtzXivaXsr-xKKYGU,2460
|
|
20
|
+
unaiverse/networking/node/__init__.py,sha256=DEXbZzPt7dgall1TZKODuQIXhjq3lr39QCBISGUSWww,2508
|
|
21
|
+
unaiverse/networking/node/connpool.py,sha256=UzaBRjQc-uEcG9xm0N-vZtL1X6gMG4eaQo0WubVMqTk,56786
|
|
22
|
+
unaiverse/networking/node/node.py,sha256=jubFRGugdydsbGKO1NaYF7alcESPFQe0Meo2lAH1o0Y,147211
|
|
23
|
+
unaiverse/networking/node/profile.py,sha256=uRJyd10JQWzqemYUh-sVAfoC0PMVfTn3JbMJXF6BdwY,20245
|
|
24
|
+
unaiverse/networking/node/tokens.py,sha256=Cr_jQVMKlh6rElYaTxH_sYpq-iQ5Tu4syjxCBzTBnzU,5271
|
|
25
|
+
unaiverse/networking/p2p/__init__.py,sha256=qaTT3iUet7j9mVRgJloyXC3nj2t-ELGVb25AcnsJuK0,9499
|
|
26
|
+
unaiverse/networking/p2p/go.mod,sha256=4Ns2-PJmYPg7JWLGZ8QTUoZ9e7zMhrya8OkT8dd9TUo,5846
|
|
27
|
+
unaiverse/networking/p2p/go.sum,sha256=CB9nVc8EeN6-zCBVfPAm5sU4FsoTsYGJ355ed1af0Ro,52011
|
|
28
|
+
unaiverse/networking/p2p/golibp2p.py,sha256=ibVCLERzM2JgPP_A5FTooCoxYW5Zm2HBbzX28aQIFzo,2450
|
|
29
|
+
unaiverse/networking/p2p/golibp2p.pyi,sha256=BwPF8GnMdWy3IwCEhV3hxrvxRK4bSYZObmCCtjpx81s,3912
|
|
30
|
+
unaiverse/networking/p2p/lib.go,sha256=ud105hkf42I9TV4S8BmrVZTri6MWceV8lJX3DfPXPG0,108967
|
|
31
|
+
unaiverse/networking/p2p/lib_types.py,sha256=cHcwbQmLG67UvdXwbQzITQPq7oQGVKgM1rA7OIr2GNI,13759
|
|
32
|
+
unaiverse/networking/p2p/message_pb2.py,sha256=ZhLiyLJOIhbIFDAoVTtZBlCPt-zOmGBULwSVXKM02Yc,4172
|
|
33
|
+
unaiverse/networking/p2p/messages.py,sha256=QIZilzGHB_MSXsab91vjZ3qbyvJnS40AxMH7V7QgTqs,16565
|
|
34
|
+
unaiverse/networking/p2p/mylogger.py,sha256=cgT24kD6zy4iEJyi2eY4cdHEc6Dc9BrjFETUDI2Hl2Y,4774
|
|
35
|
+
unaiverse/networking/p2p/p2p.py,sha256=minbjoQIT8oIhXp-_sZaCN92mVMxClR072ZpeoEbgD4,42076
|
|
36
|
+
unaiverse/networking/p2p/proto-go/message.pb.go,sha256=9XVZ85zGoGlg6qaS0rfhNoKZKZU64bOswzrqHgY79ho,23830
|
|
37
|
+
unaiverse/streamlib/__init__.py,sha256=VpsL7-gwML7nbrMQumtEDpuEH4g7iNqQaCzd-zX49cQ,2447
|
|
38
|
+
unaiverse/streamlib/streamlib.py,sha256=yz6G8eez3VnF_fvA9G3KS-WCoLvPYlk0IdqdB9dDzOI,10366
|
|
39
|
+
unaiverse/utils/__init__.py,sha256=_iomQ_GviAS5c4ZVBrm1h_rLYWH-f-T9SI-b0697gn0,2464
|
|
40
|
+
unaiverse/utils/lone_wolf.json,sha256=c7Qkqm41NUDSomI3SP8aK8tFdrF44p4s_aP1v-qOPps,897
|
|
41
|
+
unaiverse/utils/misc.py,sha256=29bdbrqewn4maflkE1C9yfiIvaASqM8bjdWCDFuJ9vE,18241
|
|
42
|
+
unaiverse/utils/sandbox.py,sha256=SPLXmdRF3sIBy3FZeoIHMsdXnNXK_q_qZ2nilsWFNjw,14395
|
|
43
|
+
unaiverse-0.1.12.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
|
|
44
|
+
unaiverse-0.1.12.dist-info/METADATA,sha256=0nDgYn9sJ3C8IoNa0n_nOjJlP3MfzX83q-V2Fuz_zjg,18537
|
|
45
|
+
unaiverse-0.1.12.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
46
|
+
unaiverse-0.1.12.dist-info/top_level.txt,sha256=0rP09tH9hv17TDQs66OHbJaRSnADpZsDsODy6JVsTtw,10
|
|
47
|
+
unaiverse-0.1.12.dist-info/RECORD,,
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
unaiverse
|