cycls 0.0.2.22__py3-none-any.whl → 0.0.2.24__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.
cycls/cycls.py
CHANGED
|
@@ -10,7 +10,7 @@ import inspect
|
|
|
10
10
|
import logging
|
|
11
11
|
logging.basicConfig(level=logging.ERROR)
|
|
12
12
|
|
|
13
|
-
O = lambda x,y: print(f"✦/✧ {str(x).ljust(
|
|
13
|
+
O = lambda x,y: print(f"✦/✧ {str(x).ljust(12)} | {y}")
|
|
14
14
|
|
|
15
15
|
import os
|
|
16
16
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -32,6 +32,7 @@ def find_available_port(start_port):
|
|
|
32
32
|
port += 1
|
|
33
33
|
|
|
34
34
|
import asyncssh, asyncio
|
|
35
|
+
# ssh -q -i tuns -o StrictHostKeyChecking=no -R 80:localhost:9000 tuns.sh
|
|
35
36
|
async def create_ssh_tunnel(x,y,z='tuns.sh'):
|
|
36
37
|
try:
|
|
37
38
|
async with asyncssh.connect(z,client_keys=[key_path],known_hosts=None) as conn:
|
|
@@ -42,30 +43,32 @@ async def create_ssh_tunnel(x,y,z='tuns.sh'):
|
|
|
42
43
|
except (OSError, asyncssh.Error) as e:
|
|
43
44
|
O("tunnel",f"disconnected ({e})")
|
|
44
45
|
|
|
45
|
-
def register(handles, net,
|
|
46
|
+
def register(handles, net, api_key):
|
|
46
47
|
try:
|
|
47
48
|
with httpx.Client() as client:
|
|
48
|
-
response = client.post(f"{net}/register", json={"handles":handles, "
|
|
49
|
+
response = client.post(f"{net}/register", json={"handles":handles, "net":net, "api_key":api_key})
|
|
50
|
+
data = response.json()
|
|
49
51
|
if response.status_code==200:
|
|
50
|
-
data = (response.json()).get("content")
|
|
51
52
|
for i in data:
|
|
52
|
-
O(i[
|
|
53
|
+
O(f"{i['status']}/{i['mode']}", f"{net}/{i['handle']}" if i["status"] != "taken" else "")
|
|
54
|
+
return True
|
|
53
55
|
else:
|
|
54
|
-
|
|
56
|
+
O("failed", data.get("error"))
|
|
57
|
+
return False
|
|
55
58
|
except Exception as e:
|
|
56
|
-
|
|
59
|
+
O("error",e)
|
|
60
|
+
return False
|
|
57
61
|
|
|
58
62
|
class Cycls:
|
|
59
|
-
def __init__(self, url="", net="https://cycls.com", port=find_available_port(8001),
|
|
63
|
+
def __init__(self, url="", net="https://cycls.com", port=find_available_port(8001), api_key=None):
|
|
60
64
|
import uuid
|
|
61
|
-
self.subdomain = str(uuid.uuid4())[:8]
|
|
65
|
+
self.subdomain = str(uuid.uuid4())[:8] #!
|
|
62
66
|
self.server = FastAPI()
|
|
63
67
|
self.net = net
|
|
64
68
|
self.port = port
|
|
65
69
|
self.url = url
|
|
66
70
|
self.apps = {}
|
|
67
|
-
self.
|
|
68
|
-
self.email = email
|
|
71
|
+
self.api_key = api_key
|
|
69
72
|
|
|
70
73
|
def __call__(self, handle):
|
|
71
74
|
def decorator(func):
|
|
@@ -76,13 +79,7 @@ class Cycls:
|
|
|
76
79
|
def sync_wrapper(*args, **kwargs):
|
|
77
80
|
return StreamingResponse(func(*args, **kwargs))
|
|
78
81
|
wrapper = async_wrapper if inspect.iscoroutinefunction(func) else sync_wrapper
|
|
79
|
-
|
|
80
|
-
if self.url != "": self.prod=True #!
|
|
81
|
-
if not self.prod:
|
|
82
|
-
self.apps[handle + "-dev"] = wrapper
|
|
83
|
-
else:
|
|
84
|
-
self.apps[handle] = wrapper
|
|
85
|
-
|
|
82
|
+
self.apps[handle] = wrapper
|
|
86
83
|
return wrapper
|
|
87
84
|
return decorator
|
|
88
85
|
|
|
@@ -96,29 +93,24 @@ class Cycls:
|
|
|
96
93
|
return {"error": "Handle not found"}
|
|
97
94
|
|
|
98
95
|
def push(self):
|
|
99
|
-
if self.email:
|
|
100
|
-
O("email",self.email)
|
|
101
96
|
O("port",self.port)
|
|
102
|
-
if self.
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
if self.url=="":
|
|
98
|
+
# self.url = f"https://{self.subdomain}-cycls.tuns.sh"
|
|
99
|
+
self.url = f"https://cycls-{self.subdomain}.tuns.sh"
|
|
100
|
+
mode = "dev"
|
|
105
101
|
else:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
try:
|
|
119
|
-
uvicorn.run(self.server, host="127.0.0.1", port=self.port, log_level="error")
|
|
120
|
-
except KeyboardInterrupt:
|
|
121
|
-
print(" ");O("exit","done")
|
|
102
|
+
mode = "prod"
|
|
103
|
+
config = [{"handle": handle, "url": self.url+"/gateway", "mode":mode} for handle in list(self.apps.keys())]
|
|
104
|
+
if on := register(config, self.net, self.api_key):
|
|
105
|
+
self.server.post("/gateway")(self.gateway)
|
|
106
|
+
@self.server.on_event("startup")
|
|
107
|
+
def startup_event():
|
|
108
|
+
# asyncio.create_task(create_ssh_tunnel(f"{self.subdomain}-cycls", self.port))
|
|
109
|
+
asyncio.create_task(create_ssh_tunnel(f"{self.subdomain}", self.port))
|
|
110
|
+
try:
|
|
111
|
+
uvicorn.run(self.server, host="127.0.0.1", port=self.port, log_level="error")
|
|
112
|
+
except KeyboardInterrupt:
|
|
113
|
+
print(" ");O("exit","done")
|
|
122
114
|
|
|
123
115
|
async def call(self, handle, content):
|
|
124
116
|
data = {"handle":handle, "content":content, "session":{}, "agent":"yes"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cycls
|
|
3
|
+
Version: 0.0.2.24
|
|
4
|
+
Summary: Cycls SDK
|
|
5
|
+
Author: Mohammed Jamal
|
|
6
|
+
Author-email: mj@cycls.com
|
|
7
|
+
Requires-Python: >=3.8,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: asyncssh (>=2.14.2,<3.0.0)
|
|
15
|
+
Requires-Dist: fastapi (>=0.111.0,<0.112.0)
|
|
16
|
+
Requires-Dist: httpx (>=0.27.0,<0.28.0)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="https://github.com/user-attachments/assets/96bd304d-8116-4bce-8b8f-b08980875ad7" width="800px" alt="Cycls Banner">
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<h3 align="center">
|
|
24
|
+
Generate live apps from code in minutes with built-in memory, <br/>rich hypermedia content, and cross-platform support
|
|
25
|
+
</h3>
|
|
26
|
+
|
|
27
|
+
<h4 align="center">
|
|
28
|
+
<a href="https://cycls.com">Website</a> |
|
|
29
|
+
<a href="https://docs.cycls.com">Docs</a> |
|
|
30
|
+
<a href="https://docs.cycls.com">Blog</a>
|
|
31
|
+
</h4>
|
|
32
|
+
|
|
33
|
+
<h4 align="center">
|
|
34
|
+
<a href="https://pypi.python.org/pypi/cycls"><img src="https://img.shields.io/pypi/v/cycls.svg?label=cycls+pypi&color=blueviolet" alt="cycls Python package on PyPi" /></a>
|
|
35
|
+
<a href="https://blog.cycls.com"><img src="https://img.shields.io/badge/newsletter-blueviolet.svg?logo=substack&label=cycls" alt="Cycls newsletter" /></a>
|
|
36
|
+
<a href="https://x.com/cycls_">
|
|
37
|
+
<img src="https://img.shields.io/twitter/follow/cycls_" alt="Cycls Twitter" />
|
|
38
|
+
</a>
|
|
39
|
+
</h4>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Cycls: The AI App Generator
|
|
43
|
+
Cycls[^1] streamlines AI application development by generating apps from high-level descriptions. It eliminates boilerplate, ensures cross-platform compatibility, and manages memory - all from a single codebase.
|
|
44
|
+
|
|
45
|
+
With Cycls, you can quickly prototype ideas and then turn them into production apps, while focusing on AI logic and user interactions rather than wrestling with implementation details.
|
|
46
|
+
|
|
47
|
+
## ✨ Core Features
|
|
48
|
+
- **Fast App Generation**: Create live web apps from code in minutes
|
|
49
|
+
- **Built-in Memory Management**: Integrated state and session management
|
|
50
|
+
- **Rich Hypermedia Content**: Support for various media types (text, images, audio, video, interactive elements)
|
|
51
|
+
- **Framework Agnostic**: Compatible with a wide range of AI frameworks and models
|
|
52
|
+
|
|
53
|
+
## 🚀 Quickstart
|
|
54
|
+
### Installation
|
|
55
|
+
```
|
|
56
|
+
pip install cycls
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Basic usage
|
|
60
|
+
```py
|
|
61
|
+
from cycls import Cycls
|
|
62
|
+
|
|
63
|
+
cycls = Cycls()
|
|
64
|
+
|
|
65
|
+
@cycls("@my-app")
|
|
66
|
+
def app():
|
|
67
|
+
return "Hello World!"
|
|
68
|
+
|
|
69
|
+
cycls.push()
|
|
70
|
+
```
|
|
71
|
+
This creates an app named "@my-app" that responds with "Hello World!".
|
|
72
|
+
|
|
73
|
+
The `@cycls("@my-app")` decorator registers your app, and `cycls.push()` streams it to Cycls platform.
|
|
74
|
+
|
|
75
|
+
To see a live example, visit https://cycls.com/@spark.
|
|
76
|
+
|
|
77
|
+
> [!IMPORTANT]
|
|
78
|
+
> Use a unique name for your app (like "@my-app"). This is your app's identifier on Cycls.
|
|
79
|
+
|
|
80
|
+
> [!NOTE]
|
|
81
|
+
> Your apps run on your infrastructure and are streamed in real-time to Cycls.
|
|
82
|
+
|
|
83
|
+
## 📖 Documentation
|
|
84
|
+
For more detailes and instructions, visit our documentation at [docs.cycls.com](https://docs.cycls.com/).
|
|
85
|
+
|
|
86
|
+
## 🗺️ Roadmap
|
|
87
|
+
- **iOS and Android apps**
|
|
88
|
+
- **User management**
|
|
89
|
+
- **JavaScript SDK**
|
|
90
|
+
- **Public API**
|
|
91
|
+
- **Cross-app communication**
|
|
92
|
+
|
|
93
|
+
## 🙌 Support
|
|
94
|
+
Join our Discord community for support and discussions. You can reach us on:
|
|
95
|
+
|
|
96
|
+
- [Join our Discord](https://discord.gg/XbxcTFBf7J)
|
|
97
|
+
- [Join our newsletter](https://blog.cycls.com)
|
|
98
|
+
- [Follow us on Twitter](https://x.com/cycls_)
|
|
99
|
+
- [Email us](mailto:hi@cycls.com)
|
|
100
|
+
|
|
101
|
+
[^1]: The name "Cycls" is a play on "cycles," referring to the continuous exchange between AI prompts (generators) and their responses (generated).
|
|
102
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
cycls/__init__.py,sha256=HPPQikt_Trbc4s8XyEOeOjB_JRWXlXIkJuh762nUM_g,24
|
|
2
|
+
cycls/cycls.py,sha256=_vCiIUeyDJhC3ANSh5aOSkHw38-k8cuwuYCCmx_yOEg,4731
|
|
3
|
+
cycls/tuns,sha256=CT8olxDKOM0cY6r_bbSGtnWyEmEYFVDVHj9ug3gbYHk,1843
|
|
4
|
+
cycls-0.0.2.24.dist-info/METADATA,sha256=UsbfVWCgu2-uk_3R4tGui1GxP2Q3WstfSNumcWVezHM,3672
|
|
5
|
+
cycls-0.0.2.24.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
+
cycls-0.0.2.24.dist-info/RECORD,,
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: cycls
|
|
3
|
-
Version: 0.0.2.22
|
|
4
|
-
Summary: Cycls SDK
|
|
5
|
-
Author: Mohammed Jamal
|
|
6
|
-
Author-email: mj@cycls.com
|
|
7
|
-
Requires-Python: >=3.8,<4.0
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Requires-Dist: asyncssh (>=2.14.2,<3.0.0)
|
|
15
|
-
Requires-Dist: fastapi (>=0.111.0,<0.112.0)
|
|
16
|
-
Requires-Dist: httpx (>=0.27.0,<0.28.0)
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
|
|
19
|
-
</br></br>
|
|
20
|
-
<p align="center">
|
|
21
|
-
<picture>
|
|
22
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://cycls.com/static/assets/logo-gold.svg">
|
|
23
|
-
<source media="(prefers-color-scheme: light)" srcset="https://cycls.com/static/assets/logo.svg">
|
|
24
|
-
<img alt="Cycls" src="https://cycls.com/static/assets/logo.svg" width="150">
|
|
25
|
-
</picture>
|
|
26
|
-
</p>
|
|
27
|
-
</br></br>
|
|
28
|
-
|
|
29
|
-
<div align="center">
|
|
30
|
-
<a href="https://pypi.org/project/cycls/" target="_blank" rel="noopener noreferrer">
|
|
31
|
-
<img loading="lazy" src="https://img.shields.io/pypi/v/cycls.svg" alt="PyPI" class="img_ev3q" style="display: inline;">
|
|
32
|
-
</a>
|
|
33
|
-
<a href="https://discord.gg/BMnaMatDC7" target="_blank" rel="noopener noreferrer">
|
|
34
|
-
<img loading="lazy" src="https://img.shields.io/discord/1175782747164389466" alt="Discord" class="img_ev3q" style="display: inline;">
|
|
35
|
-
</a>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
</br>
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
pip install cycls
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
# Apps ✦
|
|
45
|
-
Instantly publish and share AI apps
|
|
46
|
-
|
|
47
|
-
```py
|
|
48
|
-
from cycls import Cycls
|
|
49
|
-
|
|
50
|
-
cycls = Cycls()
|
|
51
|
-
|
|
52
|
-
@cycls("@spark")
|
|
53
|
-
def app(x):
|
|
54
|
-
return x.content + "from spark"
|
|
55
|
-
|
|
56
|
-
cycls.push()
|
|
57
|
-
```
|
|
58
|
-
`cycls.push()` will then publish the app `@spark` on [cycls.com/@spark](https://cycls.com/@spark)
|
|
59
|
-
## Async Apps
|
|
60
|
-
For performance, make the function asynchronous. The following is an async app with message `history` and session `id`
|
|
61
|
-
```py
|
|
62
|
-
from cycls import Cycls
|
|
63
|
-
|
|
64
|
-
cycls = Cycls()
|
|
65
|
-
|
|
66
|
-
@cycls("@spark")
|
|
67
|
-
async def app(x):
|
|
68
|
-
print(x.history, x.id)
|
|
69
|
-
return x.content + "from spark"
|
|
70
|
-
|
|
71
|
-
cycls.push()
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
# Agents ✧
|
|
75
|
-
Call any public app as an agent, see [explore](https://explore.cycls.com)
|
|
76
|
-
```py
|
|
77
|
-
from cycls import Cycls
|
|
78
|
-
|
|
79
|
-
cycls = Cycls()
|
|
80
|
-
|
|
81
|
-
@cycls("@spark")
|
|
82
|
-
async def app(x):
|
|
83
|
-
return cycls.call("@groq",
|
|
84
|
-
x.content)
|
|
85
|
-
|
|
86
|
-
cycls.push()
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Try it live
|
|
90
|
-
- [cycls.com/@groq](https://cycls.com/@groq) | [groq.py](https://github.com/Cycls/examples/blob/main/groq.py)
|
|
91
|
-
- [cycls.com/@openai](https://cycls.com/@openai) | [openai.py](https://github.com/Cycls/examples/blob/main/openai.py)
|
|
92
|
-
|
cycls-0.0.2.22.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
cycls/__init__.py,sha256=HPPQikt_Trbc4s8XyEOeOjB_JRWXlXIkJuh762nUM_g,24
|
|
2
|
-
cycls/cycls.py,sha256=GVC6IJ9AhKjNY5KA_osP2mbWjlDdymkWNNQuyQ6a8jA,4794
|
|
3
|
-
cycls/tuns,sha256=CT8olxDKOM0cY6r_bbSGtnWyEmEYFVDVHj9ug3gbYHk,1843
|
|
4
|
-
cycls-0.0.2.22.dist-info/METADATA,sha256=rWDwf1rez9xYZnLOh3o5C8osTajOrC3CIvyyyT2IliU,2593
|
|
5
|
-
cycls-0.0.2.22.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
-
cycls-0.0.2.22.dist-info/RECORD,,
|
|
File without changes
|