beamlit 0.0.34rc74__py3-none-any.whl → 0.0.34rc76__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.
- beamlit/agents/__init__.py +2 -1
- beamlit/agents/thread.py +14 -0
- beamlit/functions/decorator.py +78 -78
- {beamlit-0.0.34rc74.dist-info → beamlit-0.0.34rc76.dist-info}/METADATA +2 -1
- {beamlit-0.0.34rc74.dist-info → beamlit-0.0.34rc76.dist-info}/RECORD +6 -5
- {beamlit-0.0.34rc74.dist-info → beamlit-0.0.34rc76.dist-info}/WHEEL +0 -0
beamlit/agents/__init__.py
CHANGED
beamlit/agents/thread.py
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
import jwt
|
3
|
+
from fastapi import Request
|
4
|
+
|
5
|
+
|
6
|
+
def get_default_thread(request: Request) -> str:
|
7
|
+
if request.headers.get("X-Beamlit-Sub"):
|
8
|
+
return request.headers.get("X-Beamlit-Sub")
|
9
|
+
authorization = request.headers.get("Authorization", request.headers.get("X-Beamlit-Authorization"))
|
10
|
+
if authorization and len(authorization.split("Bearer ")) > 1:
|
11
|
+
token = authorization.split(" ")[1]
|
12
|
+
decoded = jwt.decode(token, options={"verify_signature": False})
|
13
|
+
return decoded["sub"]
|
14
|
+
return ""
|
beamlit/functions/decorator.py
CHANGED
@@ -48,87 +48,87 @@ def get_functions(
|
|
48
48
|
if not os.path.exists(dir):
|
49
49
|
if remote_functions_empty and warning:
|
50
50
|
logger.warn(f"Functions directory {dir} not found")
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
if isinstance(decorator, ast.Call):
|
74
|
-
decorator_name = decorator.func.id
|
75
|
-
if isinstance(decorator, ast.Name):
|
76
|
-
decorator_name = decorator.id
|
77
|
-
if decorator_name == from_decorator:
|
78
|
-
# Get the function name and decorator name
|
79
|
-
func_name = node.name
|
80
|
-
|
81
|
-
# Import the module to get the actual function
|
82
|
-
spec = importlib.util.spec_from_file_location(func_name, file_path)
|
83
|
-
module = importlib.util.module_from_spec(spec)
|
84
|
-
spec.loader.exec_module(module)
|
85
|
-
# Check if kit=True in the decorator arguments
|
86
|
-
is_kit = False
|
51
|
+
if os.path.exists(dir):
|
52
|
+
for root, _, files in os.walk(dir):
|
53
|
+
for file in files:
|
54
|
+
if file.endswith(".py"):
|
55
|
+
file_path = os.path.join(root, file)
|
56
|
+
# Read and compile the file content
|
57
|
+
with open(file_path) as f:
|
58
|
+
try:
|
59
|
+
file_content = f.read()
|
60
|
+
# Parse the file content to find decorated functions
|
61
|
+
tree = ast.parse(file_content)
|
62
|
+
|
63
|
+
# Look for function definitions with decorators
|
64
|
+
for node in ast.walk(tree):
|
65
|
+
if (
|
66
|
+
not isinstance(node, ast.FunctionDef)
|
67
|
+
and not isinstance(node, ast.AsyncFunctionDef)
|
68
|
+
) or len(node.decorator_list) == 0:
|
69
|
+
continue
|
70
|
+
decorator = node.decorator_list[0]
|
71
|
+
|
72
|
+
decorator_name = ""
|
87
73
|
if isinstance(decorator, ast.Call):
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
74
|
+
decorator_name = decorator.func.id
|
75
|
+
if isinstance(decorator, ast.Name):
|
76
|
+
decorator_name = decorator.id
|
77
|
+
if decorator_name == from_decorator:
|
78
|
+
# Get the function name and decorator name
|
79
|
+
func_name = node.name
|
80
|
+
|
81
|
+
# Import the module to get the actual function
|
82
|
+
spec = importlib.util.spec_from_file_location(func_name, file_path)
|
83
|
+
module = importlib.util.module_from_spec(spec)
|
84
|
+
spec.loader.exec_module(module)
|
85
|
+
# Check if kit=True in the decorator arguments
|
86
|
+
is_kit = False
|
87
|
+
if isinstance(decorator, ast.Call):
|
88
|
+
for keyword in decorator.keywords:
|
89
|
+
if keyword.arg == "kit" and isinstance(
|
90
|
+
keyword.value, ast.Constant
|
91
|
+
):
|
92
|
+
is_kit = keyword.value.value
|
93
|
+
if is_kit and not settings.remote:
|
94
|
+
kit_functions = get_functions(
|
95
|
+
client=client,
|
96
|
+
dir=os.path.join(root),
|
97
|
+
remote_functions_empty=remote_functions_empty,
|
98
|
+
from_decorator="kit",
|
99
|
+
)
|
100
|
+
functions.extend(kit_functions)
|
101
|
+
|
102
|
+
# Get the decorated function
|
103
|
+
if not is_kit and hasattr(module, func_name):
|
104
|
+
func = getattr(module, func_name)
|
105
|
+
if settings.remote:
|
106
|
+
toolkit = RemoteToolkit(client, slugify(func.__name__))
|
107
|
+
toolkit.initialize()
|
108
|
+
functions.extend(toolkit.get_tools())
|
120
109
|
else:
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
110
|
+
if asyncio.iscoroutinefunction(func):
|
111
|
+
functions.append(
|
112
|
+
StructuredTool(
|
113
|
+
name=func.__name__,
|
114
|
+
description=func.__doc__,
|
115
|
+
func=func,
|
116
|
+
coroutine=func,
|
117
|
+
args_schema=create_schema_from_function(func.__name__, func)
|
118
|
+
)
|
119
|
+
)
|
120
|
+
else:
|
121
|
+
|
122
|
+
functions.append(
|
123
|
+
StructuredTool(
|
124
|
+
name=func.__name__,
|
125
|
+
description=func.__doc__,
|
126
|
+
func=func,
|
127
|
+
args_schema=create_schema_from_function(func.__name__, func)
|
128
|
+
)
|
128
129
|
)
|
129
|
-
|
130
|
-
|
131
|
-
logger.warning(f"Error processing {file_path}: {e!s}")
|
130
|
+
except Exception as e:
|
131
|
+
logger.warning(f"Error processing {file_path}: {e!s}")
|
132
132
|
|
133
133
|
if mcp_hub:
|
134
134
|
for server in mcp_hub:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: beamlit
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.34rc76
|
4
4
|
Summary: Add your description here
|
5
5
|
Author-email: cploujoux <ch.ploujoux@gmail.com>
|
6
6
|
Requires-Python: >=3.12
|
@@ -21,6 +21,7 @@ Requires-Dist: opentelemetry-instrumentation-system-metrics>=0.50b0
|
|
21
21
|
Requires-Dist: opentelemetry-sdk>=1.28.2
|
22
22
|
Requires-Dist: pydantic-settings<2.7.0,>=2.6.1
|
23
23
|
Requires-Dist: pydantic<2.11.0,>=2.10.3
|
24
|
+
Requires-Dist: pyjwt>=2.10.1
|
24
25
|
Requires-Dist: python-dateutil>=2.8.0
|
25
26
|
Requires-Dist: pyyaml<6.1.0,>=6.0.2
|
26
27
|
Requires-Dist: requests<2.33.0,>=2.32.3
|
@@ -4,10 +4,11 @@ beamlit/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
|
4
4
|
beamlit/py.typed,sha256=8ZJUsxZiuOy1oJeVhsTWQhTG_6pTVHVXk5hJL79ebTk,25
|
5
5
|
beamlit/run.py,sha256=HtDYDjD7oVfQ8r3T5_t4qN5UDJOJfsQILi45Z21ArAg,1446
|
6
6
|
beamlit/types.py,sha256=E1hhDh_zXfsSQ0NCt9-uw90_Mr5iIlsdfnfvxv5HarU,1005
|
7
|
-
beamlit/agents/__init__.py,sha256=
|
7
|
+
beamlit/agents/__init__.py,sha256=4aXI1Sp8NuKJ8yVw9qUFRmFhSrWdT5b0bniqRKzZ42U,162
|
8
8
|
beamlit/agents/chain.py,sha256=vfCjiFHuu02uTTGicxMlFzjyICQkIjpXrBGs-7uJEsg,2826
|
9
9
|
beamlit/agents/chat.py,sha256=6PE2f_tf6l4_-9mZ---ZHvxN52pmLkHkgh1ebPoG1BY,4052
|
10
10
|
beamlit/agents/decorator.py,sha256=_N5uYircuULo2EZ1B0vaD1Rsc64534DtojmUVAJGUAw,5921
|
11
|
+
beamlit/agents/thread.py,sha256=LN5Ss-uOf5_hdB0WV1dqpn-N-pDJB3C2hUvlCzdqtdk,519
|
11
12
|
beamlit/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
12
13
|
beamlit/api/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
14
|
beamlit/api/agents/create_agent.py,sha256=t5Pr62My2EhQlcIY71MrI73-0_q5Djr3a_Ybt9MIiQQ,3587
|
@@ -141,7 +142,7 @@ beamlit/deploy/deploy.py,sha256=gGUEyl3Bddgx1Khvk8X9LFPCbHD74ouqTvr917cyzHU,1026
|
|
141
142
|
beamlit/deploy/format.py,sha256=U6UZEFAYLnGJJ7O2YmSdlUUFhnWNGAv6NZ-DW4KTgvI,2049
|
142
143
|
beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
|
143
144
|
beamlit/functions/__init__.py,sha256=NcQPZZNfWhAJ1T1F6Xn21LFPMbZ7aMR2Sve3uZOkBCQ,170
|
144
|
-
beamlit/functions/decorator.py,sha256=
|
145
|
+
beamlit/functions/decorator.py,sha256=HFy-b9cj9kkF2qcP5eTCf94LGeoHgAwZ4xXXh3S9N24,9024
|
145
146
|
beamlit/functions/github/__init__.py,sha256=gYnUkeegukOfbymdabuuJkScvH-_ZJygX05BoqkPn0o,49
|
146
147
|
beamlit/functions/github/github.py,sha256=FajzLCNkpXcwfgnC0l9rOGT2eSPLCz8-qrMzK9N_ZNc,598
|
147
148
|
beamlit/functions/github/kit/__init__.py,sha256=jBwPqZv6C23_utukohxqXZwrlicNlI7PYPUj0Den7Cw,136
|
@@ -283,6 +284,6 @@ beamlit/serve/app.py,sha256=_aG2UVQ3Y85rUW3ehu9TlzLnowkfh54IIz558ftqOMw,3638
|
|
283
284
|
beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
|
284
285
|
beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
|
285
286
|
beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
|
286
|
-
beamlit-0.0.
|
287
|
-
beamlit-0.0.
|
288
|
-
beamlit-0.0.
|
287
|
+
beamlit-0.0.34rc76.dist-info/METADATA,sha256=77omHFS8WtoUYRjsIY1HKk37nu_Krqaag5MTaLnydqA,2441
|
288
|
+
beamlit-0.0.34rc76.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
289
|
+
beamlit-0.0.34rc76.dist-info/RECORD,,
|
File without changes
|