cycls 0.0.2.43__tar.gz → 0.0.2.44__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycls
3
- Version: 0.0.2.43
3
+ Version: 0.0.2.44
4
4
  Summary: Cycls SDK
5
5
  Author: Mohammed J. AlRujayi
6
6
  Author-email: mj@cycls.com
@@ -18,19 +18,19 @@ def function(python_version=None, pip=None, apt=None, run_commands=None, copy=No
18
18
  return decorator
19
19
 
20
20
  class Agent:
21
- def __init__(self, theme=theme_path, org=None, api_token=None, pip=[], apt=[], copy=[], keys=["",""], api_key=None):
21
+ def __init__(self, theme=theme_path, org=None, api_token=None, pip=[], apt=[], copy=[], copy_public=[], keys=["",""], api_key=None):
22
22
  self.org, self.api_token = org, api_token
23
23
  self.theme = theme
24
- self.keys, self.pip, self.apt, self.copy = keys, pip, apt, copy
24
+ self.keys, self.pip, self.apt, self.copy, self.copy_public = keys, pip, apt, copy, copy_public
25
25
  self.api_key = api_key
26
26
 
27
27
  self.registered_functions = []
28
28
 
29
- def __call__(self, name=None, header="", intro="", domain=None, auth=False):
29
+ def __call__(self, name=None, header="", intro="", title="", domain=None, auth=False):
30
30
  def decorator(f):
31
31
  self.registered_functions.append({
32
32
  "func": f,
33
- "config": ["public", False, self.org, self.api_token, header, intro, auth],
33
+ "config": ["public", False, self.org, self.api_token, header, intro, title, auth],
34
34
  # "name": name,
35
35
  "name": name or (f.__name__).replace('_', '-'),
36
36
  "domain": domain or f"{name}.cycls.ai",
@@ -47,7 +47,6 @@ class Agent:
47
47
  if len(self.registered_functions) > 1:
48
48
  print(f"⚠️ Warning: Multiple agents found. Running '{i['name']}'.")
49
49
  print(f"🚀 Starting local server at localhost:{port}")
50
- # i["config"][0], i["config"][6] = self.theme, False
51
50
  i["config"][0] = self.theme
52
51
  uvicorn.run(web(i["func"], *i["config"]), host="0.0.0.0", port=port)
53
52
  return
@@ -64,10 +63,11 @@ class Agent:
64
63
  if len(self.registered_functions) > 1:
65
64
  print(f"⚠️ Warning: Multiple agents found. Running '{i['name']}'.")
66
65
 
67
- # i["config"][6] = False
66
+ i["config"][1] = False
68
67
 
69
68
  copy={str(self.theme):"public", str(cycls_path)+"/web.py":"web.py"}
70
69
  copy.update({i:i for i in self.copy})
70
+ copy.update({i:f"a/{i}" for i in self.copy_public})
71
71
 
72
72
  new = Runtime(
73
73
  func=lambda port: __import__("uvicorn").run(__import__("web").web(i["func"], *i["config"]), host="0.0.0.0", port=port),
@@ -1,4 +1,5 @@
1
1
  import json, inspect
2
+ from pathlib import Path
2
3
 
3
4
  async def async_openai_encoder(stream): # clean up the meta data / new API?
4
5
  async for message in stream:
@@ -48,7 +49,7 @@ XwIDAQAB
48
49
  -----END PUBLIC KEY-----
49
50
  """
50
51
 
51
- def web(func, front_end_path="", prod=False, org=None, api_token=None, header="", intro="", auth=True): # API auth
52
+ def web(func, public_path="", prod=False, org=None, api_token=None, header="", intro="", title="", auth=True): # API auth
52
53
  from fastapi import FastAPI, Request, HTTPException, status, Depends
53
54
  from fastapi.responses import StreamingResponse , HTMLResponse
54
55
  from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
@@ -67,6 +68,7 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
67
68
  class Metadata(BaseModel):
68
69
  header: str
69
70
  intro: str
71
+ title: str
70
72
  prod: bool
71
73
  auth: bool
72
74
  org: Optional[str]
@@ -101,7 +103,6 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
101
103
  context = Context(messages = messages, user = User(**user_data) if user_data else None)
102
104
  stream = await func(context) if inspect.iscoroutinefunction(func) else func(context)
103
105
  if request.url.path == "/chat/completions":
104
- # stream = openai_encoder(stream)
105
106
  stream = async_openai_encoder(stream) if inspect.isasyncgen(stream) else openai_encoder(stream)
106
107
  return StreamingResponse(stream, media_type="text/event-stream")
107
108
 
@@ -110,6 +111,7 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
110
111
  return Metadata(
111
112
  header=header,
112
113
  intro=intro,
114
+ title=title,
113
115
  prod=prod,
114
116
  auth=auth,
115
117
  org=org,
@@ -117,5 +119,8 @@ def web(func, front_end_path="", prod=False, org=None, api_token=None, header=""
117
119
  pk_test="pk_test_c2VsZWN0LXNsb3RoLTU4LmNsZXJrLmFjY291bnRzLmRldiQ"
118
120
  )
119
121
 
120
- app.mount("/", StaticFiles(directory=front_end_path, html=True))
122
+ if Path("a").is_dir():
123
+ app.mount("/a", StaticFiles(directory="a", html=True))
124
+ app.mount("/", StaticFiles(directory=public_path, html=True))
125
+
121
126
  return app
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cycls"
3
- version = "0.0.2.43"
3
+ version = "0.0.2.44"
4
4
 
5
5
  packages = [{ include = "cycls" }]
6
6
  include = ["cycls/theme/**/*"]
File without changes
File without changes
File without changes