beamlit 0.0.34rc75__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/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:
|
@@ -142,7 +142,7 @@ beamlit/deploy/deploy.py,sha256=gGUEyl3Bddgx1Khvk8X9LFPCbHD74ouqTvr917cyzHU,1026
|
|
142
142
|
beamlit/deploy/format.py,sha256=U6UZEFAYLnGJJ7O2YmSdlUUFhnWNGAv6NZ-DW4KTgvI,2049
|
143
143
|
beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
|
144
144
|
beamlit/functions/__init__.py,sha256=NcQPZZNfWhAJ1T1F6Xn21LFPMbZ7aMR2Sve3uZOkBCQ,170
|
145
|
-
beamlit/functions/decorator.py,sha256=
|
145
|
+
beamlit/functions/decorator.py,sha256=HFy-b9cj9kkF2qcP5eTCf94LGeoHgAwZ4xXXh3S9N24,9024
|
146
146
|
beamlit/functions/github/__init__.py,sha256=gYnUkeegukOfbymdabuuJkScvH-_ZJygX05BoqkPn0o,49
|
147
147
|
beamlit/functions/github/github.py,sha256=FajzLCNkpXcwfgnC0l9rOGT2eSPLCz8-qrMzK9N_ZNc,598
|
148
148
|
beamlit/functions/github/kit/__init__.py,sha256=jBwPqZv6C23_utukohxqXZwrlicNlI7PYPUj0Den7Cw,136
|
@@ -284,6 +284,6 @@ beamlit/serve/app.py,sha256=_aG2UVQ3Y85rUW3ehu9TlzLnowkfh54IIz558ftqOMw,3638
|
|
284
284
|
beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
|
285
285
|
beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
|
286
286
|
beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
|
287
|
-
beamlit-0.0.
|
288
|
-
beamlit-0.0.
|
289
|
-
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
|