beamlit 0.0.34rc75__py3-none-any.whl → 0.0.34rc77__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/common/instrumentation.py +3 -3
- beamlit/functions/decorator.py +78 -78
- {beamlit-0.0.34rc75.dist-info → beamlit-0.0.34rc77.dist-info}/METADATA +1 -1
- {beamlit-0.0.34rc75.dist-info → beamlit-0.0.34rc77.dist-info}/RECORD +5 -5
- {beamlit-0.0.34rc75.dist-info → beamlit-0.0.34rc77.dist-info}/WHEEL +0 -0
@@ -4,13 +4,13 @@ from typing import Any
|
|
4
4
|
from fastapi import FastAPI
|
5
5
|
from opentelemetry import _logs, metrics, trace
|
6
6
|
from opentelemetry._logs import set_logger_provider
|
7
|
-
from opentelemetry.exporter.otlp.proto.
|
7
|
+
from opentelemetry.exporter.otlp.proto.http._log_exporter import (
|
8
8
|
OTLPLogExporter,
|
9
9
|
)
|
10
|
-
from opentelemetry.exporter.otlp.proto.
|
10
|
+
from opentelemetry.exporter.otlp.proto.http.metric_exporter import (
|
11
11
|
OTLPMetricExporter,
|
12
12
|
)
|
13
|
-
from opentelemetry.exporter.otlp.proto.
|
13
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
|
14
14
|
OTLPSpanExporter,
|
15
15
|
)
|
16
16
|
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
|
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:
|
@@ -131,7 +131,7 @@ beamlit/authentication/credentials.py,sha256=p_1xenabCbQuRz7BiFk7oTK4uCxAt_zoyku
|
|
131
131
|
beamlit/authentication/device_mode.py,sha256=LNHjoKe3u4TWApLKO34cJjN92UsVkHSYSbXr6eKxo64,3721
|
132
132
|
beamlit/common/__init__.py,sha256=saX5X3hRCJ9erSlXuSkZ2VGgquvpgdcofAU_9sM4bCE,354
|
133
133
|
beamlit/common/error.py,sha256=f9oJDFxhoHK-vpjxBgEp0NwWIk0N_THPemUI7uQxVzU,270
|
134
|
-
beamlit/common/instrumentation.py,sha256=
|
134
|
+
beamlit/common/instrumentation.py,sha256=u-eZjv1hWMAlYQ3b6YPmOPHBJCCgPebLuLO5DhDRgAA,5351
|
135
135
|
beamlit/common/logger.py,sha256=nN_dSOl4bs13QU3Rod-w3e3jYOnlSrHx3_bs-ACY6Aw,1115
|
136
136
|
beamlit/common/secrets.py,sha256=sid81bOe3LflkMKDHwBsBs9nIju8bp5-v9qU9gkyNMc,212
|
137
137
|
beamlit/common/settings.py,sha256=OL1pZLB3BgN7QPCz9VR7gjYb-LoYpelilS7rU7FubCE,3962
|
@@ -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.34rc77.dist-info/METADATA,sha256=Mgp2S8Sv2jxEy9FIY_IatNrhYvDRgprsZIToyhbHogE,2441
|
288
|
+
beamlit-0.0.34rc77.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
289
|
+
beamlit-0.0.34rc77.dist-info/RECORD,,
|
File without changes
|