cycls 0.0.2.101__py3-none-any.whl → 0.0.2.103__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/app.py +2 -4
- cycls/function.py +3 -0
- cycls/themes/default/assets/FileSaver.min-BN40akLc.js +1 -0
- cycls/themes/default/assets/index-3AQCbjkB.js +29 -0
- cycls/themes/default/assets/{index-CoyOzdkL.js → index-qcHL6SRo.js} +209 -152
- cycls/themes/default/assets/{index.es-DMEUqx7I.js → index.es-BmxgotDY.js} +1 -1
- cycls/themes/default/assets/{jspdf.es.min-eVFWSv5x.js → jspdf.es.min-CvOy4co6.js} +8 -8
- cycls/themes/default/index.html +1 -1
- cycls/web.py +26 -21
- {cycls-0.0.2.101.dist-info → cycls-0.0.2.103.dist-info}/METADATA +3 -3
- cycls-0.0.2.103.dist-info/RECORD +20 -0
- cycls/state.py +0 -6
- cycls/themes/default/assets/html-to-docx.esm-DbAOvYyE.js +0 -554
- cycls-0.0.2.101.dist-info/RECORD +0 -20
- {cycls-0.0.2.101.dist-info → cycls-0.0.2.103.dist-info}/WHEEL +0 -0
- {cycls-0.0.2.101.dist-info → cycls-0.0.2.103.dist-info}/entry_points.txt +0 -0
cycls/themes/default/index.html
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
rel="stylesheet"
|
|
18
18
|
href="https://esm.sh/katex@0.16.8/dist/katex.min.css"
|
|
19
19
|
/>
|
|
20
|
-
<script type="module" crossorigin src="/assets/index-
|
|
20
|
+
<script type="module" crossorigin src="/assets/index-qcHL6SRo.js"></script>
|
|
21
21
|
<link rel="stylesheet" crossorigin href="/assets/index-CjN0qc53.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body style="overflow-x: hidden">
|
cycls/web.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json, inspect
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from pydantic import BaseModel
|
|
4
|
-
from typing import Optional,
|
|
4
|
+
from typing import Optional, Any
|
|
5
5
|
from .auth import PK_LIVE, PK_TEST, JWKS_PROD, JWKS_TEST
|
|
6
6
|
|
|
7
7
|
class Config(BaseModel):
|
|
@@ -16,7 +16,6 @@ class Config(BaseModel):
|
|
|
16
16
|
org: Optional[str] = None
|
|
17
17
|
pk: Optional[str] = None
|
|
18
18
|
jwks: Optional[str] = None
|
|
19
|
-
state: Union[bool, str] = False
|
|
20
19
|
|
|
21
20
|
def set_prod(self, prod: bool):
|
|
22
21
|
self.prod = prod
|
|
@@ -66,8 +65,8 @@ class Messages(list):
|
|
|
66
65
|
return self._raw
|
|
67
66
|
|
|
68
67
|
def web(func, config):
|
|
69
|
-
from fastapi import FastAPI, Request, HTTPException, status, Depends
|
|
70
|
-
from fastapi.responses import StreamingResponse
|
|
68
|
+
from fastapi import FastAPI, Request, HTTPException, status, Depends, UploadFile, File
|
|
69
|
+
from fastapi.responses import StreamingResponse, FileResponse
|
|
71
70
|
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
|
72
71
|
import jwt
|
|
73
72
|
from jwt import PyJWKClient
|
|
@@ -90,7 +89,6 @@ def web(func, config):
|
|
|
90
89
|
class Context(BaseModel):
|
|
91
90
|
messages: Any
|
|
92
91
|
user: Optional[User] = None
|
|
93
|
-
state: Optional[Any] = None
|
|
94
92
|
|
|
95
93
|
model_config = {"arbitrary_types_allowed": True}
|
|
96
94
|
|
|
@@ -100,14 +98,6 @@ def web(func, config):
|
|
|
100
98
|
return self.messages[-1].get("content", "")
|
|
101
99
|
return ""
|
|
102
100
|
|
|
103
|
-
@property
|
|
104
|
-
def kv(self):
|
|
105
|
-
return self.state.kv if self.state else None
|
|
106
|
-
|
|
107
|
-
@property
|
|
108
|
-
def fs(self):
|
|
109
|
-
return self.state.fs if self.state else None
|
|
110
|
-
|
|
111
101
|
app = FastAPI()
|
|
112
102
|
bearer_scheme = HTTPBearer()
|
|
113
103
|
|
|
@@ -134,14 +124,7 @@ def web(func, config):
|
|
|
134
124
|
user_data = jwt.get("user") if jwt else None
|
|
135
125
|
user = User(**user_data) if user_data else None
|
|
136
126
|
|
|
137
|
-
|
|
138
|
-
state_instance = None
|
|
139
|
-
if config.state:
|
|
140
|
-
from .state import create_state
|
|
141
|
-
user_id = user.id if user else "anonymous"
|
|
142
|
-
state_instance = await create_state(user_id)
|
|
143
|
-
|
|
144
|
-
context = Context(messages=Messages(messages), user=user, state=state_instance)
|
|
127
|
+
context = Context(messages=Messages(messages), user=user)
|
|
145
128
|
stream = await func(context) if inspect.iscoroutinefunction(func) else func(context)
|
|
146
129
|
|
|
147
130
|
if request.url.path == "/chat/completions":
|
|
@@ -154,6 +137,28 @@ def web(func, config):
|
|
|
154
137
|
async def get_config():
|
|
155
138
|
return config
|
|
156
139
|
|
|
140
|
+
@app.post("/files")
|
|
141
|
+
async def upload_file(file: UploadFile = File(...), jwt: dict = Depends(validate)):
|
|
142
|
+
user_id = jwt["user"]["id"]
|
|
143
|
+
user_dir = Path(f"/workspace/{user_id}/files")
|
|
144
|
+
user_dir.mkdir(parents=True, exist_ok=True)
|
|
145
|
+
|
|
146
|
+
file_path = user_dir / file.filename
|
|
147
|
+
with open(file_path, "wb") as f:
|
|
148
|
+
f.write(await file.read())
|
|
149
|
+
|
|
150
|
+
return {"url": f"/files/{file.filename}"}
|
|
151
|
+
|
|
152
|
+
@app.get("/files/{filename}")
|
|
153
|
+
async def get_file(filename: str, jwt: dict = Depends(validate)):
|
|
154
|
+
user_id = jwt["user"]["id"]
|
|
155
|
+
file_path = Path(f"/workspace/{user_id}/files") / filename
|
|
156
|
+
|
|
157
|
+
if not file_path.exists():
|
|
158
|
+
raise HTTPException(status_code=404, detail="File not found")
|
|
159
|
+
|
|
160
|
+
return FileResponse(file_path)
|
|
161
|
+
|
|
157
162
|
if Path("public").is_dir():
|
|
158
163
|
app.mount("/public", StaticFiles(directory="public", html=True))
|
|
159
164
|
app.mount("/", StaticFiles(directory=config.public_path, html=True))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cycls
|
|
3
|
-
Version: 0.0.2.
|
|
3
|
+
Version: 0.0.2.103
|
|
4
4
|
Summary: Distribute Intelligence
|
|
5
5
|
Author-email: "Mohammed J. AlRujayi" <mj@cycls.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -10,10 +10,10 @@ Requires-Dist: email-validator>=2.0.0
|
|
|
10
10
|
Requires-Dist: fastapi>=0.111.0
|
|
11
11
|
Requires-Dist: httpx>=0.27.0
|
|
12
12
|
Requires-Dist: pyjwt>=2.8.0
|
|
13
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
14
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
13
15
|
Requires-Dist: uvicorn>=0.30.0
|
|
14
16
|
Requires-Dist: watchfiles>=1.0.0
|
|
15
|
-
Provides-Extra: state
|
|
16
|
-
Requires-Dist: agentfs-sdk==0.4.0; extra == 'state'
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
19
19
|
<h3 align="center">
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
cycls/__init__.py,sha256=XnLv709ktYzCVON0PwwFZFe6_m54pXfXZH9-niTxYxU,121
|
|
2
|
+
cycls/app.py,sha256=g3AfEvzClhF7ZQzKc2n07gY4LWCG14UZfOB3g6N6UD8,3227
|
|
3
|
+
cycls/auth.py,sha256=xkndHZyCfnlertMMEKerCJjf23N3fVcTRVTTSXTTuzg,247
|
|
4
|
+
cycls/cli.py,sha256=cVbIkTDnVofohvByyYUrXF_RYDQZVQECJqo7cPBPJfs,4781
|
|
5
|
+
cycls/function.py,sha256=JiJZ1xDoGIsfDe4_o6DvCb5tIbZ5VGbDEP1ttsCpcm4,16347
|
|
6
|
+
cycls/web.py,sha256=44uOJDpqno1YPW0ze6NIsynt5H0QhOlxM-wshfp0xPQ,6444
|
|
7
|
+
cycls/themes/default/index.html,sha256=ePrbrWb9va_TQfXxZeNxrCOlZwqz6a3Pc2UTlwOg73g,1082
|
|
8
|
+
cycls/themes/default/assets/FileSaver.min-BN40akLc.js,sha256=QuWu6mg8FZb1ixAqfHu2TbS9tHC0MZu29NIU55-i7pM,3035
|
|
9
|
+
cycls/themes/default/assets/html2canvas.esm-QH1iLAAe.js,sha256=BhwI5QwNxXuNXmUx8LgjelKmiyMyYNSasvLCkGrREsQ,202379
|
|
10
|
+
cycls/themes/default/assets/index-3AQCbjkB.js,sha256=FzjtM-hp-Q9sk4IWd5wXtCrTO55FU3I6wssltQp8YnM,395816
|
|
11
|
+
cycls/themes/default/assets/index-CjN0qc53.css,sha256=coBc8b1ydstimADUYP9fJrGC7JpOjTKZFy_7HpUZAx4,8485
|
|
12
|
+
cycls/themes/default/assets/index-qcHL6SRo.js,sha256=Xjfx0KJsTpoBUWE-Q5DYvVgpQl-DjJfcIDevcI6WChs,1812610
|
|
13
|
+
cycls/themes/default/assets/index.es-BmxgotDY.js,sha256=O6aHp2_kmX_EekHikHl9hM4qVVUDYe0Gk3gHNggRjBE,159424
|
|
14
|
+
cycls/themes/default/assets/jspdf.es.min-CvOy4co6.js,sha256=RKNLtAaszG0vgMlyDVsTwbCYCOXcNUTUqDVN0e41VYQ,388319
|
|
15
|
+
cycls/themes/default/assets/purify.es-B9ZVCkUG.js,sha256=j5lP7czBWW-_UT-iJC8cboa3pTAxBhTf5bOyjWN99G4,22636
|
|
16
|
+
cycls/themes/dev/index.html,sha256=QJBHkdNuMMiwQU7o8dN8__8YQeQB45D37D-NCXIWB2Q,11585
|
|
17
|
+
cycls-0.0.2.103.dist-info/METADATA,sha256=pEcDjknIyda5RGlSMdb9uu852ZoFzRYhinT2Q_x2ypY,8871
|
|
18
|
+
cycls-0.0.2.103.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
19
|
+
cycls-0.0.2.103.dist-info/entry_points.txt,sha256=CktT5eNvW_Qxomf7L_Ez_GdUbL6qAfx_Utm6_HtUJwE,41
|
|
20
|
+
cycls-0.0.2.103.dist-info/RECORD,,
|