cycls 0.0.2.39__py3-none-any.whl → 0.0.2.41__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/theme/index.html CHANGED
@@ -15,7 +15,7 @@
15
15
  const PROD = {{ prod | tojson }};
16
16
  const PUBLISHABLE_KEY = "{{ pk_live if prod else pk_test }}";
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-D0-uI8sw.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-CtrsaaFE.js"></script>
19
19
  </head>
20
20
  <body>
21
21
  <div id="root"></div>
cycls/web.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import json, inspect
2
2
 
3
- async def openai_encoder(stream): # clean up the meta data / new API?
3
+ async def async_openai_encoder(stream): # clean up the meta data / new API?
4
4
  async for message in stream:
5
5
  payload = {"id": "chatcmpl-123",
6
6
  "object": "chat.completion.chunk",
@@ -12,6 +12,18 @@ async def openai_encoder(stream): # clean up the meta data / new API?
12
12
  yield f"data: {json.dumps(payload)}\n\n"
13
13
  yield "data: [DONE]\n\n"
14
14
 
15
+ def openai_encoder(stream):
16
+ for message in stream:
17
+ payload = {"id": "chatcmpl-123",
18
+ "object": "chat.completion.chunk",
19
+ "created": 1728083325,
20
+ "model": "model-1-2025-01-01",
21
+ "system_fingerprint": "fp_123456",
22
+ "choices": [{"delta": {"content": message}}]}
23
+ if message:
24
+ yield f"data: {json.dumps(payload)}\n\n"
25
+ yield "data: [DONE]\n\n"
26
+
15
27
  test_auth_public_key = """
16
28
  -----BEGIN PUBLIC KEY-----
17
29
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyDudrDtQ5irw6hPWf2rw
@@ -43,7 +55,6 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
43
55
  import jwt
44
56
  from pydantic import BaseModel, EmailStr
45
57
  from typing import List, Optional
46
- from fastapi.templating import Jinja2Templates
47
58
  from fastapi.staticfiles import StaticFiles
48
59
 
49
60
  class User(BaseModel):
@@ -53,6 +64,15 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
53
64
  org: Optional[str] = None
54
65
  plans: List[str] = []
55
66
 
67
+ class Metadata(BaseModel):
68
+ header: str
69
+ intro: str
70
+ prod: bool
71
+ auth: bool
72
+ org: Optional[str]
73
+ pk_live: str
74
+ pk_test: str
75
+
56
76
  class Context(BaseModel):
57
77
  messages: List[dict]
58
78
  user: Optional[User] = None
@@ -81,15 +101,21 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
81
101
  context = Context(messages = messages, user = User(**user_data) if user_data else None)
82
102
  stream = await func(context) if inspect.iscoroutinefunction(func) else func(context)
83
103
  if request.url.path == "/chat/completions":
84
- stream = openai_encoder(stream)
104
+ # stream = openai_encoder(stream)
105
+ stream = async_openai_encoder(stream) if inspect.isasyncgen(stream) else openai_encoder(stream)
85
106
  return StreamingResponse(stream, media_type="text/event-stream")
86
107
 
87
- templates = Jinja2Templates(directory=front_end_path)
88
- @app.get("/", response_class=HTMLResponse)
89
- async def front(request: Request):
90
- return templates.TemplateResponse("index.html", {
91
- "request": request, "header": header, "intro": intro, "prod": prod, "auth": auth, "org": org,
92
- "pk_live": "pk_live_Y2xlcmsuY3ljbHMuY29tJA", "pk_test": "pk_test_c2VsZWN0LXNsb3RoLTU4LmNsZXJrLmFjY291bnRzLmRldiQ"
93
- })
94
- app.mount("/", StaticFiles(directory=front_end_path, html=False))
108
+ @app.get("/metadata")
109
+ async def metadata():
110
+ return Metadata(
111
+ header=header,
112
+ intro=intro,
113
+ prod=prod,
114
+ auth=auth,
115
+ org=org,
116
+ pk_live="pk_live_Y2xlcmsuY3ljbHMuY29tJA",
117
+ pk_test="pk_test_c2VsZWN0LXNsb3RoLTU4LmNsZXJrLmFjY291bnRzLmRldiQ"
118
+ )
119
+
120
+ app.mount("/", StaticFiles(directory=front_end_path, html=True))
95
121
  return app
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycls
3
- Version: 0.0.2.39
3
+ Version: 0.0.2.41
4
4
  Summary: Cycls SDK
5
5
  Author: Mohammed J. AlRujayi
6
6
  Author-email: mj@cycls.com
@@ -53,8 +53,8 @@ This philosophy has a powerful side-effect: it makes development genuinely itera
53
53
  ## Key Features
54
54
 
55
55
  * ✨ **Zero-Config Deployment:** No YAML or Dockerfiles. `cycls` infers your dependencies, and APIs directly from your Python code.
56
- * 🚀 **One-Command Push to Cloud:** Go from local code to a globally scalable, serverless application with a single `agent.push()`.
57
- * 💻 **Instant Local Testing:** Run `agent.run()` to spin up a local server with hot-reloading for rapid iteration and debugging.
56
+ * 🚀 **One-Command Push to Cloud:** Go from local code to a globally scalable, serverless application with a single `agent.deploy()`.
57
+ * 💻 **Instant Local Testing:** Run `agent.local()` to spin up a local server with hot-reloading for rapid iteration and debugging.
58
58
  * 🤖 **OpenAI-Compatible API:** Automatically serves a streaming `/chat/completions` endpoint.
59
59
  * 🌐 **Automatic Web UI:** Get a clean, interactive front-end for your agent out of the box, with no front-end code required.
60
60
  * 🔐 **Built-in Authentication:** Secure your agent for production with a simple `auth=True` flag that enables JWT-based authentication.
@@ -83,7 +83,7 @@ agent = cycls.Agent()
83
83
  async def hello(context):
84
84
  yield "hi"
85
85
 
86
- agent.run()
86
+ agent.local()
87
87
  ```
88
88
 
89
89
  Run it from your terminal:
@@ -133,7 +133,7 @@ async def cake_agent(context):
133
133
  return await llm(context.messages)
134
134
 
135
135
  # Deploy the agent to the cloud
136
- agent.push(prod=True)
136
+ agent.deploy(prod=True)
137
137
  ```
138
138
 
139
139
  Run the deployment command from your terminal:
@@ -145,4 +145,3 @@ After a few moments, your agent will be live and accessible at a public URL like
145
145
 
146
146
  ### License
147
147
  This project is licensed under the MIT License.
148
-
@@ -0,0 +1,9 @@
1
+ cycls/__init__.py,sha256=bVT0dYTXLdSC3ZURgtm-DEOj-VO6RUM6zGsJB0zuj6Y,61
2
+ cycls/runtime.py,sha256=GoRfyPn2uKTIMb4FSowjfo02DsL0VrunDuybdeZxsvM,18221
3
+ cycls/sdk.py,sha256=lqYE52hSZ8kfda-M46zPcrU-dVFztf-qlHa5ozS4Xbs,5132
4
+ cycls/theme/assets/index-CtrsaaFE.js,sha256=btDvr0124sxirYbKpdKWbRRS3RfmXpSLhA8qt0bY9tM,1085004
5
+ cycls/theme/index.html,sha256=cWg4aHCNu7WviItMLVE2O5sHpTkQXQjI7RzExKNsPsU,895
6
+ cycls/web.py,sha256=Yoot83871KjSkfkvkZSBeJQ5MnY620tAvT291ybUNQE,4848
7
+ cycls-0.0.2.41.dist-info/METADATA,sha256=NPp-I1DEj39x1h4DNxd901V6H-bRmyg3uYb3BJl0E-Y,5673
8
+ cycls-0.0.2.41.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
9
+ cycls-0.0.2.41.dist-info/RECORD,,