beamlit 0.0.30rc36__py3-none-any.whl → 0.0.31__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- beamlit/agents/chain.py +5 -5
- beamlit/agents/decorator.py +4 -3
- beamlit/api/service_accounts/create_workspace_service_account.py +3 -1
- beamlit/api/service_accounts/delete_workspace_service_account.py +3 -1
- beamlit/api/service_accounts/get_workspace_service_accounts.py +3 -1
- beamlit/api/service_accounts/update_workspace_service_account.py +3 -1
- beamlit/authentication/authentication.py +8 -4
- beamlit/common/instrumentation.py +53 -31
- beamlit/common/logger.py +1 -1
- beamlit/common/settings.py +11 -6
- beamlit/deploy/deploy.py +23 -10
- beamlit/deploy/format.py +2 -0
- beamlit/functions/decorator.py +10 -3
- beamlit/functions/mcp/mcp.py +3 -2
- beamlit/functions/remote/remote.py +3 -2
- beamlit/models/__init__.py +9 -3
- beamlit/models/resource_environment_metrics.py +3 -1
- beamlit/run.py +1 -0
- beamlit/serve/app.py +18 -12
- {beamlit-0.0.30rc36.dist-info → beamlit-0.0.31.dist-info}/METADATA +1 -1
- {beamlit-0.0.30rc36.dist-info → beamlit-0.0.31.dist-info}/RECORD +22 -22
- {beamlit-0.0.30rc36.dist-info → beamlit-0.0.31.dist-info}/WHEEL +0 -0
beamlit/agents/chain.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
import asyncio
|
2
|
-
from dataclasses import dataclass
|
3
2
|
import warnings
|
4
|
-
from
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from typing import Callable
|
5
5
|
|
6
6
|
import pydantic
|
7
7
|
import typing_extensions as t
|
8
|
+
from langchain_core.tools.base import BaseTool, ToolException
|
9
|
+
|
8
10
|
from beamlit.api.agents import list_agents
|
9
11
|
from beamlit.authentication.authentication import AuthenticatedClient
|
12
|
+
from beamlit.common.settings import get_settings
|
10
13
|
from beamlit.models import Agent, AgentChain
|
11
14
|
from beamlit.run import RunClient
|
12
|
-
from beamlit.common.settings import get_settings
|
13
|
-
from langchain_core.tools.base import BaseTool, ToolException
|
14
|
-
|
15
15
|
|
16
16
|
|
17
17
|
class ChainTool(BaseTool):
|
beamlit/agents/decorator.py
CHANGED
@@ -6,6 +6,10 @@ import importlib
|
|
6
6
|
import os
|
7
7
|
from logging import getLogger
|
8
8
|
|
9
|
+
from langchain_core.tools import Tool
|
10
|
+
from langgraph.checkpoint.memory import MemorySaver
|
11
|
+
from langgraph.prebuilt import create_react_agent
|
12
|
+
|
9
13
|
from beamlit.api.models import get_model
|
10
14
|
from beamlit.authentication import new_client
|
11
15
|
from beamlit.common.settings import init
|
@@ -13,9 +17,6 @@ from beamlit.errors import UnexpectedStatus
|
|
13
17
|
from beamlit.functions.mcp.mcp import MCPClient, MCPToolkit
|
14
18
|
from beamlit.functions.remote.remote import RemoteToolkit
|
15
19
|
from beamlit.models import Agent, AgentMetadata, AgentSpec
|
16
|
-
from langchain_core.tools import Tool
|
17
|
-
from langgraph.checkpoint.memory import MemorySaver
|
18
|
-
from langgraph.prebuilt import create_react_agent
|
19
20
|
|
20
21
|
from .chain import ChainToolkit
|
21
22
|
from .chat import get_chat_model
|
@@ -6,7 +6,9 @@ import httpx
|
|
6
6
|
from ... import errors
|
7
7
|
from ...client import AuthenticatedClient, Client
|
8
8
|
from ...models.create_workspace_service_account_body import CreateWorkspaceServiceAccountBody
|
9
|
-
from ...models.create_workspace_service_account_response_200 import
|
9
|
+
from ...models.create_workspace_service_account_response_200 import (
|
10
|
+
CreateWorkspaceServiceAccountResponse200,
|
11
|
+
)
|
10
12
|
from ...types import Response
|
11
13
|
|
12
14
|
|
@@ -5,7 +5,9 @@ import httpx
|
|
5
5
|
|
6
6
|
from ... import errors
|
7
7
|
from ...client import AuthenticatedClient, Client
|
8
|
-
from ...models.delete_workspace_service_account_response_200 import
|
8
|
+
from ...models.delete_workspace_service_account_response_200 import (
|
9
|
+
DeleteWorkspaceServiceAccountResponse200,
|
10
|
+
)
|
9
11
|
from ...types import Response
|
10
12
|
|
11
13
|
|
@@ -5,7 +5,9 @@ import httpx
|
|
5
5
|
|
6
6
|
from ... import errors
|
7
7
|
from ...client import AuthenticatedClient, Client
|
8
|
-
from ...models.get_workspace_service_accounts_response_200_item import
|
8
|
+
from ...models.get_workspace_service_accounts_response_200_item import (
|
9
|
+
GetWorkspaceServiceAccountsResponse200Item,
|
10
|
+
)
|
9
11
|
from ...types import Response
|
10
12
|
|
11
13
|
|
@@ -6,7 +6,9 @@ import httpx
|
|
6
6
|
from ... import errors
|
7
7
|
from ...client import AuthenticatedClient, Client
|
8
8
|
from ...models.update_workspace_service_account_body import UpdateWorkspaceServiceAccountBody
|
9
|
-
from ...models.update_workspace_service_account_response_200 import
|
9
|
+
from ...models.update_workspace_service_account_response_200 import (
|
10
|
+
UpdateWorkspaceServiceAccountResponse200,
|
11
|
+
)
|
10
12
|
from ...types import Response
|
11
13
|
|
12
14
|
|
@@ -1,15 +1,19 @@
|
|
1
|
-
import os
|
2
1
|
from dataclasses import dataclass
|
3
2
|
from typing import Dict, Generator
|
4
3
|
|
5
|
-
from beamlit.common.settings import Settings, get_settings
|
6
4
|
from httpx import Auth, Request, Response
|
7
5
|
|
6
|
+
from beamlit.common.settings import Settings, get_settings
|
7
|
+
|
8
8
|
from ..client import AuthenticatedClient
|
9
9
|
from .apikey import ApiKeyProvider
|
10
10
|
from .clientcredentials import ClientCredentials
|
11
|
-
from .credentials import (
|
12
|
-
|
11
|
+
from .credentials import (
|
12
|
+
Credentials,
|
13
|
+
current_context,
|
14
|
+
load_credentials,
|
15
|
+
load_credentials_from_settings,
|
16
|
+
)
|
13
17
|
from .device_mode import BearerToken
|
14
18
|
|
15
19
|
|
@@ -8,22 +8,16 @@ from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import (
|
|
8
8
|
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
|
9
9
|
OTLPSpanExporter,
|
10
10
|
)
|
11
|
-
from opentelemetry.instrumentation.fastapi import
|
12
|
-
|
13
|
-
|
14
|
-
from opentelemetry.
|
15
|
-
HTTPXClientInstrumentor,
|
16
|
-
)
|
17
|
-
from opentelemetry.instrumentation.logging import ( # type: ignore
|
18
|
-
LoggingInstrumentor,
|
19
|
-
)
|
11
|
+
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
|
12
|
+
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
|
13
|
+
from opentelemetry.instrumentation.logging import LoggingInstrumentor
|
14
|
+
from opentelemetry.metrics import NoOpMeterProvider
|
20
15
|
from opentelemetry.sdk.metrics import MeterProvider
|
21
|
-
from opentelemetry.sdk.metrics.export import
|
22
|
-
PeriodicExportingMetricReader,
|
23
|
-
)
|
16
|
+
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
|
24
17
|
from opentelemetry.sdk.resources import Resource
|
25
18
|
from opentelemetry.sdk.trace import TracerProvider
|
26
19
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
20
|
+
from opentelemetry.trace import NoOpTracerProvider
|
27
21
|
from typing_extensions import Dict
|
28
22
|
|
29
23
|
from .settings import get_settings
|
@@ -57,11 +51,20 @@ def get_resource_attributes() -> Dict[str, Any]:
|
|
57
51
|
return resources_dict
|
58
52
|
|
59
53
|
|
60
|
-
def get_metrics_exporter() -> OTLPMetricExporter:
|
54
|
+
def get_metrics_exporter() -> OTLPMetricExporter | None:
|
55
|
+
settings = get_settings()
|
56
|
+
if settings is None:
|
57
|
+
raise Exception("Settings are not initialized")
|
58
|
+
if not settings.enable_opentelemetry:
|
59
|
+
# Return None or a NoOpExporter equivalent
|
60
|
+
return None
|
61
61
|
return OTLPMetricExporter()
|
62
62
|
|
63
63
|
|
64
|
-
def get_span_exporter() -> OTLPSpanExporter:
|
64
|
+
def get_span_exporter() -> OTLPSpanExporter | None:
|
65
|
+
settings = get_settings()
|
66
|
+
if not settings.enable_opentelemetry:
|
67
|
+
return None
|
65
68
|
return OTLPSpanExporter()
|
66
69
|
|
67
70
|
|
@@ -71,6 +74,16 @@ def instrument_app(app: FastAPI):
|
|
71
74
|
settings = get_settings()
|
72
75
|
if settings is None:
|
73
76
|
raise Exception("Settings are not initialized")
|
77
|
+
|
78
|
+
if not settings.enable_opentelemetry:
|
79
|
+
# Use NoOp implementations to stub tracing and metrics
|
80
|
+
trace.set_tracer_provider(NoOpTracerProvider())
|
81
|
+
tracer = trace.get_tracer(__name__)
|
82
|
+
|
83
|
+
metrics.set_meter_provider(NoOpMeterProvider())
|
84
|
+
meter = metrics.get_meter(__name__)
|
85
|
+
return
|
86
|
+
|
74
87
|
resource = Resource.create(
|
75
88
|
{
|
76
89
|
"service.name": settings.name,
|
@@ -78,24 +91,33 @@ def instrument_app(app: FastAPI):
|
|
78
91
|
"service.workspace": settings.workspace,
|
79
92
|
}
|
80
93
|
)
|
81
|
-
# Set up the TracerProvider
|
82
|
-
trace_provider = TracerProvider(resource=resource)
|
83
|
-
span_processor = BatchSpanProcessor(get_span_exporter())
|
84
|
-
trace_provider.add_span_processor(span_processor)
|
85
|
-
trace.set_tracer_provider(trace_provider)
|
86
|
-
tracer = trace_provider.get_tracer(__name__)
|
87
|
-
|
88
|
-
metrics_exporter = PeriodicExportingMetricReader(get_metrics_exporter())
|
89
|
-
meter_provider = MeterProvider(
|
90
|
-
resource=resource, metric_readers=[metrics_exporter]
|
91
|
-
)
|
92
|
-
metrics.set_meter_provider(meter_provider)
|
93
|
-
meter = meter_provider.get_meter(__name__)
|
94
94
|
|
95
|
-
|
96
|
-
|
95
|
+
# Set up the TracerProvider if not already set
|
96
|
+
if not isinstance(trace.get_tracer_provider(), TracerProvider):
|
97
|
+
trace_provider = TracerProvider(resource=resource)
|
98
|
+
span_processor = BatchSpanProcessor(get_span_exporter())
|
99
|
+
trace_provider.add_span_processor(span_processor)
|
100
|
+
trace.set_tracer_provider(trace_provider)
|
101
|
+
tracer = trace_provider.get_tracer(__name__)
|
102
|
+
else:
|
103
|
+
tracer = trace.get_tracer(__name__)
|
104
|
+
|
105
|
+
# Set up the MeterProvider if not already set
|
106
|
+
if not isinstance(metrics.get_meter_provider(), MeterProvider):
|
107
|
+
metrics_exporter = PeriodicExportingMetricReader(get_metrics_exporter())
|
108
|
+
meter_provider = MeterProvider(
|
109
|
+
resource=resource, metric_readers=[metrics_exporter]
|
110
|
+
)
|
111
|
+
metrics.set_meter_provider(meter_provider)
|
112
|
+
meter = meter_provider.get_meter(__name__)
|
113
|
+
else:
|
114
|
+
meter = metrics.get_meter(__name__)
|
115
|
+
|
116
|
+
# Only instrument the app when OpenTelemetry is enabled
|
117
|
+
FastAPIInstrumentor.instrument_app(
|
118
|
+
app=app, tracer_provider=trace.get_tracer_provider(), meter_provider=metrics.get_meter_provider()
|
97
119
|
)
|
98
|
-
HTTPXClientInstrumentor().instrument(meter_provider=
|
99
|
-
LoggingInstrumentor(tracer_provider=
|
120
|
+
HTTPXClientInstrumentor().instrument(meter_provider=metrics.get_meter_provider())
|
121
|
+
LoggingInstrumentor(tracer_provider=trace.get_tracer_provider()).instrument(
|
100
122
|
set_logging_format=True
|
101
123
|
)
|
beamlit/common/logger.py
CHANGED
@@ -27,5 +27,5 @@ def init(log_level: str):
|
|
27
27
|
logging.getLogger("httpx").propagate = False
|
28
28
|
|
29
29
|
handler = logging.StreamHandler()
|
30
|
-
handler.setFormatter(ColoredFormatter(
|
30
|
+
handler.setFormatter(ColoredFormatter("%(levelname)s %(name)s - %(message)s"))
|
31
31
|
logging.basicConfig(level=log_level, handlers=[handler])
|
beamlit/common/settings.py
CHANGED
@@ -2,6 +2,16 @@ import os
|
|
2
2
|
from logging import getLogger
|
3
3
|
from typing import Tuple, Type, Union
|
4
4
|
|
5
|
+
from langchain_core.language_models.chat_models import BaseChatModel
|
6
|
+
from langgraph.graph.graph import CompiledGraph
|
7
|
+
from pydantic import Field
|
8
|
+
from pydantic_settings import (
|
9
|
+
BaseSettings,
|
10
|
+
PydanticBaseSettingsSource,
|
11
|
+
SettingsConfigDict,
|
12
|
+
YamlConfigSettingsSource,
|
13
|
+
)
|
14
|
+
|
5
15
|
from beamlit.api.agents import get_agent
|
6
16
|
from beamlit.api.functions import get_function
|
7
17
|
from beamlit.api.models import get_model
|
@@ -9,11 +19,6 @@ from beamlit.client import AuthenticatedClient
|
|
9
19
|
from beamlit.common.logger import init as init_logger
|
10
20
|
from beamlit.models import Agent, Function, Model
|
11
21
|
from beamlit.types import UNSET, Unset
|
12
|
-
from langchain_core.language_models.chat_models import BaseChatModel
|
13
|
-
from langgraph.graph.graph import CompiledGraph
|
14
|
-
from pydantic import Field
|
15
|
-
from pydantic_settings import (BaseSettings, PydanticBaseSettingsSource,
|
16
|
-
SettingsConfigDict, YamlConfigSettingsSource)
|
17
22
|
|
18
23
|
global SETTINGS
|
19
24
|
SETTINGS = None
|
@@ -62,6 +67,7 @@ class Settings(BaseSettings):
|
|
62
67
|
mcp_hub_url: str = Field(default="https://mcp-hub-server.beamlit.workers.com")
|
63
68
|
registry_url: str = Field(default="https://us.registry.beamlit.com")
|
64
69
|
log_level: str = Field(default="INFO")
|
70
|
+
enable_opentelemetry: bool = Field(default=False)
|
65
71
|
agent: SettingsAgent = SettingsAgent()
|
66
72
|
server: SettingsServer = SettingsServer()
|
67
73
|
authentication: SettingsAuthentication = SettingsAuthentication()
|
@@ -99,7 +105,6 @@ def init_agent(
|
|
99
105
|
client: AuthenticatedClient,
|
100
106
|
destination: str = f"{os.getcwd()}/src/beamlit_generated.py",
|
101
107
|
):
|
102
|
-
from beamlit.api.agents import get_agent_deployment
|
103
108
|
from beamlit.common.generate import generate
|
104
109
|
|
105
110
|
logger = getLogger(__name__)
|
beamlit/deploy/deploy.py
CHANGED
@@ -2,12 +2,20 @@ import ast
|
|
2
2
|
import json
|
3
3
|
import os
|
4
4
|
import sys
|
5
|
+
import uuid
|
5
6
|
from logging import getLogger
|
6
7
|
from typing import Literal
|
7
8
|
|
8
9
|
from beamlit.common.settings import Settings, get_settings, init
|
9
|
-
from beamlit.models import (
|
10
|
-
|
10
|
+
from beamlit.models import (
|
11
|
+
Agent,
|
12
|
+
AgentSpec,
|
13
|
+
EnvironmentMetadata,
|
14
|
+
Flavor,
|
15
|
+
Function,
|
16
|
+
FunctionSpec,
|
17
|
+
Runtime,
|
18
|
+
)
|
11
19
|
|
12
20
|
from .format import arg_to_dict, format_agent_chain, format_parameters
|
13
21
|
from .parser import Resource, get_description, get_parameters, get_resources
|
@@ -15,11 +23,16 @@ from .parser import Resource, get_description, get_parameters, get_resources
|
|
15
23
|
sys.path.insert(0, os.getcwd())
|
16
24
|
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
17
25
|
|
26
|
+
random_id = str(uuid.uuid4())[:8]
|
27
|
+
def slugify(name: str) -> str:
|
28
|
+
return name.lower().replace(" ", "-").replace("_", "-")
|
18
29
|
|
19
30
|
def get_runtime_image(type: str, name: str) -> str:
|
20
31
|
settings = get_settings()
|
21
32
|
registry_url = settings.registry_url.replace("https://", "").replace("http://", "")
|
22
33
|
image = f"{registry_url}/{settings.workspace}/{type}s/{name}"
|
34
|
+
# Generate a random ID to ensure unique image tags
|
35
|
+
image = f"{image}:{random_id}"
|
23
36
|
return image
|
24
37
|
|
25
38
|
|
@@ -110,7 +123,7 @@ def get_agent_yaml(
|
|
110
123
|
apiVersion: beamlit.com/v1alpha1
|
111
124
|
kind: Agent
|
112
125
|
metadata:
|
113
|
-
name: {agent.metadata.name}
|
126
|
+
name: {slugify(agent.metadata.name)}
|
114
127
|
displayName: {agent.metadata.display_name or agent.metadata.name}
|
115
128
|
environment: {settings.environment}
|
116
129
|
workspace: {settings.workspace}
|
@@ -144,7 +157,7 @@ def get_function_yaml(function: Function, settings: Settings) -> str:
|
|
144
157
|
apiVersion: beamlit.com/v1alpha1
|
145
158
|
kind: Function
|
146
159
|
metadata:
|
147
|
-
name: {function.metadata.name}
|
160
|
+
name: {slugify(function.metadata.name)}
|
148
161
|
displayName: {function.metadata.display_name or function.metadata.name}
|
149
162
|
environment: {settings.environment}
|
150
163
|
spec:
|
@@ -244,29 +257,29 @@ def generate_beamlit_deployment(directory: str):
|
|
244
257
|
# write deployment file
|
245
258
|
agent_dir = os.path.join(agents_dir, agent.metadata.name)
|
246
259
|
os.makedirs(agent_dir, exist_ok=True)
|
247
|
-
with open(os.path.join(agent_dir,
|
260
|
+
with open(os.path.join(agent_dir, "agent.yaml"), "w") as f:
|
248
261
|
content = get_agent_yaml(agent, functions, settings)
|
249
262
|
f.write(content)
|
250
263
|
# write dockerfile for build
|
251
|
-
with open(os.path.join(agent_dir,
|
264
|
+
with open(os.path.join(agent_dir, "Dockerfile"), "w") as f:
|
252
265
|
content = dockerfile("agent", resource, agent)
|
253
266
|
f.write(content)
|
254
267
|
# write destination docker
|
255
|
-
with open(os.path.join(agent_dir,
|
268
|
+
with open(os.path.join(agent_dir, "destination.txt"), "w") as f:
|
256
269
|
content = agent.spec.runtime.image
|
257
270
|
f.write(content)
|
258
271
|
for resource, function in functions:
|
259
272
|
# write deployment file
|
260
273
|
function_dir = os.path.join(functions_dir, function.metadata.name)
|
261
274
|
os.makedirs(function_dir, exist_ok=True)
|
262
|
-
with open(os.path.join(function_dir,
|
275
|
+
with open(os.path.join(function_dir, "function.yaml"), "w") as f:
|
263
276
|
content = get_function_yaml(function, settings)
|
264
277
|
f.write(content)
|
265
278
|
# write dockerfile for build
|
266
|
-
with open(os.path.join(function_dir,
|
279
|
+
with open(os.path.join(function_dir, "Dockerfile"), "w") as f:
|
267
280
|
content = dockerfile("function", resource, function)
|
268
281
|
f.write(content)
|
269
282
|
# write destination docker
|
270
|
-
with open(os.path.join(function_dir,
|
283
|
+
with open(os.path.join(function_dir, "destination.txt"), "w") as f:
|
271
284
|
content = function.spec.runtime.image
|
272
285
|
f.write(content)
|
beamlit/deploy/format.py
CHANGED
beamlit/functions/decorator.py
CHANGED
@@ -4,11 +4,12 @@ import json
|
|
4
4
|
from collections.abc import Callable
|
5
5
|
from logging import getLogger
|
6
6
|
|
7
|
+
from langchain_core.tools import create_schema_from_function
|
8
|
+
|
7
9
|
from beamlit.authentication import new_client
|
8
10
|
from beamlit.common.settings import get_settings
|
9
11
|
from beamlit.models import Function, FunctionKit
|
10
12
|
from beamlit.run import RunClient
|
11
|
-
from langchain_core.tools import create_schema_from_function
|
12
13
|
|
13
14
|
logger = getLogger(__name__)
|
14
15
|
|
@@ -67,10 +68,16 @@ def kit(bl_kit: FunctionKit = None, **kwargs: dict) -> Callable:
|
|
67
68
|
return wrapper
|
68
69
|
|
69
70
|
|
70
|
-
def function(*args, function: Function = None, kit=False, **kwargs: dict) -> Callable:
|
71
|
+
def function(*args, function: Function | dict = None, kit=False, **kwargs: dict) -> Callable:
|
71
72
|
"""Create function tools with Beamlit and LangChain integration."""
|
72
73
|
settings = get_settings()
|
73
|
-
|
74
|
+
if function is not None and not isinstance(function, dict):
|
75
|
+
raise Exception(
|
76
|
+
'function must be a dictionary, example: @function(function={"metadata": {"name": "my_function"}})'
|
77
|
+
)
|
78
|
+
if isinstance(function, dict):
|
79
|
+
function = Function(**function)
|
80
|
+
|
74
81
|
def wrapper(func: Callable) -> Callable:
|
75
82
|
if function and not func.__doc__ and function.spec and function.spec.description:
|
76
83
|
func.__doc__ = function.spec.description
|
beamlit/functions/mcp/mcp.py
CHANGED
@@ -7,11 +7,12 @@ import pydantic
|
|
7
7
|
import pydantic_core
|
8
8
|
import requests
|
9
9
|
import typing_extensions as t
|
10
|
-
from beamlit.authentication.authentication import AuthenticatedClient
|
11
|
-
from beamlit.common.settings import get_settings
|
12
10
|
from langchain_core.tools.base import BaseTool, BaseToolkit, ToolException
|
13
11
|
from mcp import ListToolsResult
|
14
12
|
|
13
|
+
from beamlit.authentication.authentication import AuthenticatedClient
|
14
|
+
from beamlit.common.settings import get_settings
|
15
|
+
|
15
16
|
settings = get_settings()
|
16
17
|
|
17
18
|
def create_dynamic_schema(name: str, schema: dict[str, t.Any]) -> type[pydantic.BaseModel]:
|
@@ -1,16 +1,17 @@
|
|
1
1
|
import asyncio
|
2
2
|
import warnings
|
3
3
|
from dataclasses import dataclass
|
4
|
-
from typing import Callable
|
4
|
+
from typing import Callable
|
5
5
|
|
6
6
|
import pydantic
|
7
7
|
import typing_extensions as t
|
8
|
+
from langchain_core.tools.base import BaseTool, ToolException
|
9
|
+
|
8
10
|
from beamlit.api.functions import get_function
|
9
11
|
from beamlit.authentication.authentication import AuthenticatedClient
|
10
12
|
from beamlit.common.settings import get_settings
|
11
13
|
from beamlit.models import Function, StoreFunctionParameter
|
12
14
|
from beamlit.run import RunClient
|
13
|
-
from langchain_core.tools.base import BaseTool, ToolException
|
14
15
|
|
15
16
|
|
16
17
|
def create_dynamic_schema(name: str, parameters: list[StoreFunctionParameter]) -> type[pydantic.BaseModel]:
|
beamlit/models/__init__.py
CHANGED
@@ -32,7 +32,9 @@ from .function_spec import FunctionSpec
|
|
32
32
|
from .get_trace_ids_response_200 import GetTraceIdsResponse200
|
33
33
|
from .get_trace_logs_response_200 import GetTraceLogsResponse200
|
34
34
|
from .get_trace_response_200 import GetTraceResponse200
|
35
|
-
from .get_workspace_service_accounts_response_200_item import
|
35
|
+
from .get_workspace_service_accounts_response_200_item import (
|
36
|
+
GetWorkspaceServiceAccountsResponse200Item,
|
37
|
+
)
|
36
38
|
from .increase_and_rate_metric import IncreaseAndRateMetric
|
37
39
|
from .integration_config import IntegrationConfig
|
38
40
|
from .integration_connection import IntegrationConnection
|
@@ -75,8 +77,12 @@ from .resource_deployment_metrics_query_per_second_per_region_per_code import (
|
|
75
77
|
ResourceDeploymentMetricsQueryPerSecondPerRegionPerCode,
|
76
78
|
)
|
77
79
|
from .resource_environment_metrics import ResourceEnvironmentMetrics
|
78
|
-
from .resource_environment_metrics_inference_per_region import
|
79
|
-
|
80
|
+
from .resource_environment_metrics_inference_per_region import (
|
81
|
+
ResourceEnvironmentMetricsInferencePerRegion,
|
82
|
+
)
|
83
|
+
from .resource_environment_metrics_query_per_region_per_code import (
|
84
|
+
ResourceEnvironmentMetricsQueryPerRegionPerCode,
|
85
|
+
)
|
80
86
|
from .resource_log import ResourceLog
|
81
87
|
from .resource_metrics import ResourceMetrics
|
82
88
|
from .runtime import Runtime
|
@@ -8,7 +8,9 @@ from ..types import UNSET, Unset
|
|
8
8
|
if TYPE_CHECKING:
|
9
9
|
from ..models.metric import Metric
|
10
10
|
from ..models.qps import QPS
|
11
|
-
from ..models.resource_environment_metrics_inference_per_region import
|
11
|
+
from ..models.resource_environment_metrics_inference_per_region import (
|
12
|
+
ResourceEnvironmentMetricsInferencePerRegion,
|
13
|
+
)
|
12
14
|
from ..models.resource_environment_metrics_query_per_region_per_code import (
|
13
15
|
ResourceEnvironmentMetricsQueryPerRegionPerCode,
|
14
16
|
)
|
beamlit/run.py
CHANGED
beamlit/serve/app.py
CHANGED
@@ -7,14 +7,18 @@ from logging import getLogger
|
|
7
7
|
from uuid import uuid4
|
8
8
|
|
9
9
|
from asgi_correlation_id import CorrelationIdMiddleware
|
10
|
-
from beamlit.common import HTTPError, get_settings, init
|
11
|
-
from beamlit.common.instrumentation import (get_metrics_exporter,
|
12
|
-
get_resource_attributes,
|
13
|
-
get_span_exporter, instrument_app)
|
14
10
|
from fastapi import FastAPI, Request, Response
|
15
11
|
from fastapi.responses import JSONResponse
|
16
12
|
from traceloop.sdk import Traceloop
|
17
13
|
|
14
|
+
from beamlit.common import HTTPError, get_settings, init
|
15
|
+
from beamlit.common.instrumentation import (
|
16
|
+
get_metrics_exporter,
|
17
|
+
get_resource_attributes,
|
18
|
+
get_span_exporter,
|
19
|
+
instrument_app,
|
20
|
+
)
|
21
|
+
|
18
22
|
from .middlewares import AccessLogMiddleware, AddProcessTimeHeader
|
19
23
|
|
20
24
|
sys.path.insert(0, os.getcwd())
|
@@ -37,13 +41,14 @@ logger.info(
|
|
37
41
|
f" on {settings.server.host}:{settings.server.port}"
|
38
42
|
)
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
)
|
44
|
+
if settings.enable_opentelemetry:
|
45
|
+
Traceloop.init(
|
46
|
+
app_name=settings.name,
|
47
|
+
exporter=get_span_exporter(),
|
48
|
+
metrics_exporter=get_metrics_exporter(),
|
49
|
+
resource_attributes=get_resource_attributes(),
|
50
|
+
should_enrich_metrics=os.getenv("ENRICHED_METRICS", "false") == "true",
|
51
|
+
)
|
47
52
|
|
48
53
|
app = FastAPI(docs_url=None, redoc_url=None)
|
49
54
|
app.add_middleware(
|
@@ -55,6 +60,7 @@ app.add_middleware(AddProcessTimeHeader)
|
|
55
60
|
app.add_middleware(AccessLogMiddleware)
|
56
61
|
instrument_app(app)
|
57
62
|
|
63
|
+
|
58
64
|
@app.get("/health")
|
59
65
|
async def health():
|
60
66
|
return {"status": "ok"}
|
@@ -67,7 +73,7 @@ async def root(request: Request):
|
|
67
73
|
try:
|
68
74
|
body = await request.json()
|
69
75
|
|
70
|
-
original_func = getattr(func,
|
76
|
+
original_func = getattr(func, "__wrapped__", func)
|
71
77
|
if asyncio.iscoroutinefunction(func) or asyncio.iscoroutinefunction(original_func):
|
72
78
|
response = await func(body)
|
73
79
|
else:
|
@@ -2,12 +2,12 @@ beamlit/__init__.py,sha256=545gFC-wLLwUktWcOAjUWe_Glha40tBetRTOYSfHnbI,164
|
|
2
2
|
beamlit/client.py,sha256=PnR6ybZk5dLIJPnDKAf2epHOeQC_7yL0fG4muvphHjA,12695
|
3
3
|
beamlit/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
4
4
|
beamlit/py.typed,sha256=8ZJUsxZiuOy1oJeVhsTWQhTG_6pTVHVXk5hJL79ebTk,25
|
5
|
-
beamlit/run.py,sha256=
|
5
|
+
beamlit/run.py,sha256=HtDYDjD7oVfQ8r3T5_t4qN5UDJOJfsQILi45Z21ArAg,1446
|
6
6
|
beamlit/types.py,sha256=E1hhDh_zXfsSQ0NCt9-uw90_Mr5iIlsdfnfvxv5HarU,1005
|
7
7
|
beamlit/agents/__init__.py,sha256=nf1iwQwGtCG6nDqyVhxfWoqR6dv6X3bvSpCeqkTCFaM,101
|
8
|
-
beamlit/agents/chain.py,sha256=
|
8
|
+
beamlit/agents/chain.py,sha256=vfCjiFHuu02uTTGicxMlFzjyICQkIjpXrBGs-7uJEsg,2826
|
9
9
|
beamlit/agents/chat.py,sha256=gVyv4FGBdQTDhdutX8l64OUNa6Fdqaw4eCfEDRH0IPQ,3558
|
10
|
-
beamlit/agents/decorator.py,sha256=
|
10
|
+
beamlit/agents/decorator.py,sha256=RAhe7wHKJnjMpmU7KWKcM6EZjdm3pgUBhQQUP2T6GZY,9716
|
11
11
|
beamlit/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
12
12
|
beamlit/api/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
beamlit/api/agents/create_agent.py,sha256=t5Pr62My2EhQlcIY71MrI73-0_q5Djr3a_Ybt9MIiQQ,3587
|
@@ -98,12 +98,12 @@ beamlit/api/privateclusters/update_private_cluster.py,sha256=Urb5GGuVcSwQy2WBlru
|
|
98
98
|
beamlit/api/privateclusters/update_private_cluster_health.py,sha256=PxCyl5ZEIqpQ_PKIr9ErqjZcoTSKlTZS1YgTT1JwhCg,2572
|
99
99
|
beamlit/api/service_accounts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
100
100
|
beamlit/api/service_accounts/create_api_key_for_service_account.py,sha256=Ee9CXzYqVh9OTJeai8bKaclznuWpJiPd74aPHZYZdeQ,4525
|
101
|
-
beamlit/api/service_accounts/create_workspace_service_account.py,sha256=
|
101
|
+
beamlit/api/service_accounts/create_workspace_service_account.py,sha256=D3NkGoPZyMi6ibj29F7xbJd5aLI2jw2vLSl1qDRGhW4,4648
|
102
102
|
beamlit/api/service_accounts/delete_api_key_for_service_account.py,sha256=bS2OWtO7Dn8FU2uaTe9h7VCxiobti8Ka2NtTUKBd31Q,2621
|
103
|
-
beamlit/api/service_accounts/delete_workspace_service_account.py,sha256=
|
104
|
-
beamlit/api/service_accounts/get_workspace_service_accounts.py,sha256=
|
103
|
+
beamlit/api/service_accounts/delete_workspace_service_account.py,sha256=XEz6-DkWZTmuaTOMooaywKvBsGilBYR-xG32RsXP5Mw,4136
|
104
|
+
beamlit/api/service_accounts/get_workspace_service_accounts.py,sha256=6c7T_WsXCuotQomm4zkAkAkhdLEcgVyvon9aYHPiEiI,4151
|
105
105
|
beamlit/api/service_accounts/list_api_keys_for_service_account.py,sha256=skp0PmjxfW7EGAyRcVAye_SKfryKjvsTuhSRxeIaXDo,4066
|
106
|
-
beamlit/api/service_accounts/update_workspace_service_account.py,sha256=
|
106
|
+
beamlit/api/service_accounts/update_workspace_service_account.py,sha256=Y4rQL8Yx8yRZSzTJz5-ESP5zQ0juVhuoX6xwpg5ZM00,4912
|
107
107
|
beamlit/api/store/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
108
108
|
beamlit/api/store/get_store_agent.py,sha256=UjvsRXyFsXZLf4utQjpiOiPM7KxlRj4C-x_ac5EXoLk,3624
|
109
109
|
beamlit/api/store/get_store_function.py,sha256=kEbg91jJh0XAXmipjzwg931mxkMCZ820PxiJ89zYbso,3756
|
@@ -124,35 +124,35 @@ beamlit/api/workspaces/update_workspace.py,sha256=qa5DV2UJSUYuB_ibALb4E9ghKpT1Ha
|
|
124
124
|
beamlit/api/workspaces/update_workspace_user_role.py,sha256=Yn9iuJ4tKtauzBiJyU4-wYUMS9g98X2Om8zs7UkzrY8,4917
|
125
125
|
beamlit/authentication/__init__.py,sha256=wiXqRbc7E-ulrH_ueA9duOGFvXeo7-RvhSD1XbFogMo,1020
|
126
126
|
beamlit/authentication/apikey.py,sha256=KNBTgdi0VBzBAAmSwU2X1QoB58vRbg8wkXb8-GTZCQo,657
|
127
|
-
beamlit/authentication/authentication.py,sha256=
|
127
|
+
beamlit/authentication/authentication.py,sha256=ODQCc00RvCOZNaiGG5ctylNnE-JVCugePyJedJ0NYsM,3361
|
128
128
|
beamlit/authentication/clientcredentials.py,sha256=cxZPPu--CgizwqX0pdfFQ91gJt1EFKwyy-aBB_dXX7I,3990
|
129
129
|
beamlit/authentication/credentials.py,sha256=p_1xenabCbQuRz7BiFk7oTK4uCxAt_zoyku5o-jcKGE,5343
|
130
130
|
beamlit/authentication/device_mode.py,sha256=tmr22gllKOZwBRub_QjF5pYa425x-nE8tQNpZ_EGR6g,3644
|
131
131
|
beamlit/common/__init__.py,sha256=vj4_boIBVitMsaQR8BqBqE2eupOIh6MWBAYlYyCCH98,341
|
132
132
|
beamlit/common/error.py,sha256=f9oJDFxhoHK-vpjxBgEp0NwWIk0N_THPemUI7uQxVzU,270
|
133
133
|
beamlit/common/generate.py,sha256=LtdCju_QayRS4lZrrb_0VHqWWvTcv4Mbf-iV1TB_Qko,7522
|
134
|
-
beamlit/common/instrumentation.py,sha256=
|
135
|
-
beamlit/common/logger.py,sha256=
|
134
|
+
beamlit/common/instrumentation.py,sha256=GVYeat7qCcqzDoKSYig3s8ZCC172R9JiQIr3Evv3kik,4293
|
135
|
+
beamlit/common/logger.py,sha256=nN_dSOl4bs13QU3Rod-w3e3jYOnlSrHx3_bs-ACY6Aw,1115
|
136
136
|
beamlit/common/secrets.py,sha256=sid81bOe3LflkMKDHwBsBs9nIju8bp5-v9qU9gkyNMc,212
|
137
|
-
beamlit/common/settings.py,sha256=
|
137
|
+
beamlit/common/settings.py,sha256=_4oCVrJZOMaTZoK2Zzo2DWqtUyBsspuOH3iAJ_nU0tw,5923
|
138
138
|
beamlit/common/utils.py,sha256=jouz5igBvT37Xn_e94-foCHyQczVim-UzVcoIF6RWJ4,657
|
139
139
|
beamlit/deploy/__init__.py,sha256=GS7l7Jtm2yKs7iNLKcfjYO-rAhUzggQ3xiYSf3oxLBY,91
|
140
|
-
beamlit/deploy/deploy.py,sha256=
|
141
|
-
beamlit/deploy/format.py,sha256=
|
140
|
+
beamlit/deploy/deploy.py,sha256=xo2fAdF6jR1cG75sXMzpqsJlG_qGAKVnMwjuDa_8sk8,9936
|
141
|
+
beamlit/deploy/format.py,sha256=PJ8kU7Y1pwiS3tqqyvFaag9LO3jju-4ua574163VPk4,1820
|
142
142
|
beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
|
143
143
|
beamlit/functions/__init__.py,sha256=_RPG1Bfg54JGdIPnViAU6n9zD7E1cDNsdXi8oYGskzE,138
|
144
|
-
beamlit/functions/decorator.py,sha256=
|
144
|
+
beamlit/functions/decorator.py,sha256=YNNU8MZXV2C6gIjxaYhp-FSWGLc9I_XLsIE24zQ3fr8,3541
|
145
145
|
beamlit/functions/github/__init__.py,sha256=gYnUkeegukOfbymdabuuJkScvH-_ZJygX05BoqkPn0o,49
|
146
146
|
beamlit/functions/github/github.py,sha256=FajzLCNkpXcwfgnC0l9rOGT2eSPLCz8-qrMzK9N_ZNc,598
|
147
147
|
beamlit/functions/github/kit/__init__.py,sha256=jBwPqZv6C23_utukohxqXZwrlicNlI7PYPUj0Den7Cw,136
|
148
148
|
beamlit/functions/github/kit/pull_request.py,sha256=wQVeRBakiqu-2ouflO8p1z7D5u07KNsitwyNRrp0KjM,1357
|
149
149
|
beamlit/functions/math/__init__.py,sha256=wie4WME8jT-WpFRrtu-lDlHW31Mg6K2cwstjkUdLF3o,43
|
150
150
|
beamlit/functions/math/math.py,sha256=CpoLJGwuvwCPGnVC8k9GYuIyvfUYPDQHKlZg3cx-z-A,1049
|
151
|
-
beamlit/functions/mcp/mcp.py,sha256
|
152
|
-
beamlit/functions/remote/remote.py,sha256=
|
151
|
+
beamlit/functions/mcp/mcp.py,sha256=-LL7O35vTlcYfF1MSlEY83rBKKShJTaHB-y9MRPAEiU,4349
|
152
|
+
beamlit/functions/remote/remote.py,sha256=AL8WhD7yXZ18h3iU4vE9E4JtJt0n_i-ZwlbBDoolnEs,3767
|
153
153
|
beamlit/functions/search/__init__.py,sha256=5NAthQ9PBwrkNg1FpLRx4flauvv0HyWuwaVS589c1Pw,49
|
154
154
|
beamlit/functions/search/search.py,sha256=8s9ECltq7YE17j6rTxb12uY2EQY4_eTLHmwlIMThI0w,515
|
155
|
-
beamlit/models/__init__.py,sha256=
|
155
|
+
beamlit/models/__init__.py,sha256=CfMLR86qnFW6mz2fp6t2f91Vr62HmjY7qgTuvZT79Is,7830
|
156
156
|
beamlit/models/acl.py,sha256=tH67gsl_BMaviSbTaaIkO1g9cWZgJ6VgAnYVjQSzGZY,3952
|
157
157
|
beamlit/models/agent.py,sha256=oGZBwd2Hy-i6q_up4WQ0IvOmxqouR5I1Gk8vXvfLKvc,3384
|
158
158
|
beamlit/models/agent_chain.py,sha256=8PN8wVSayS-LoBN2nahZsOmr6r3t62H_LPDK_8fnkM8,2255
|
@@ -223,7 +223,7 @@ beamlit/models/qps.py,sha256=Us3PQTfeM5KN-QwLXkJ2XESJDIyTvD1tSJR9taClIog,1684
|
|
223
223
|
beamlit/models/resource_deployment_metrics.py,sha256=TaV4-xbI79FCfzFcgDQ-A3EjJTByMKA42xgvS7pcT10,8875
|
224
224
|
beamlit/models/resource_deployment_metrics_inference_per_second_per_region.py,sha256=phgZ9vJ3s7pYIYo14mgyav6ZrJnY3IS7y5T6To1IDjE,2624
|
225
225
|
beamlit/models/resource_deployment_metrics_query_per_second_per_region_per_code.py,sha256=uCzjEHEy3j3j3Jcdul097N6hiKAHBhM8laQ-TxDs65c,2381
|
226
|
-
beamlit/models/resource_environment_metrics.py,sha256=
|
226
|
+
beamlit/models/resource_environment_metrics.py,sha256=tVbEvRXdNgcu_c6bVQAkVDYiYqK3N-TsTWMWdSB3q28,7550
|
227
227
|
beamlit/models/resource_environment_metrics_inference_per_region.py,sha256=pIc14XdNeKq50WGWU0FnmNqtFU5S8y_q3gomLA-dOgM,2580
|
228
228
|
beamlit/models/resource_environment_metrics_inference_per_second_per_region.py,sha256=CmJx_tjhsfHS1hMHOwOkuVPypbG3xyZ_GCG3A2uPhr4,2629
|
229
229
|
beamlit/models/resource_environment_metrics_query_per_region_per_code.py,sha256=G2qxM4jRKavyC96K9CO6AlF_7_K6aHtV4dMqT4n4vcA,2307
|
@@ -252,10 +252,10 @@ beamlit/models/websocket_channel.py,sha256=jg3vN7yS_oOIwGtndtIUr1LsyEA58RXLXahqS
|
|
252
252
|
beamlit/models/workspace.py,sha256=l__bIpbA4oJvxXo7UbEoCcqkvu9MiNt5aXXpZ3bgwHg,4309
|
253
253
|
beamlit/models/workspace_labels.py,sha256=WbnUY6eCTkUNdY7hhhSF-KQCl8fWFfkCf7hzCTiNp4A,1246
|
254
254
|
beamlit/models/workspace_user.py,sha256=70CcifQWYbeWG7TDui4pblTzUe5sVK0AS19vNCzKE8g,3423
|
255
|
-
beamlit/serve/app.py,sha256=
|
255
|
+
beamlit/serve/app.py,sha256=QzReZZjGFQWhNA1XBDq81rsn9zpEihtLZLrfZi9ThT0,3554
|
256
256
|
beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
|
257
257
|
beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
|
258
258
|
beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
|
259
|
-
beamlit-0.0.
|
260
|
-
beamlit-0.0.
|
261
|
-
beamlit-0.0.
|
259
|
+
beamlit-0.0.31.dist-info/METADATA,sha256=AiAjQ4okR_M97rDaam6B7Bw5tax6IW3MZ19lRHzqKmw,2401
|
260
|
+
beamlit-0.0.31.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
261
|
+
beamlit-0.0.31.dist-info/RECORD,,
|
File without changes
|