beamlit 0.0.38rc83__py3-none-any.whl → 0.0.40rc84__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/decorator.py +3 -4
- beamlit/common/settings.py +3 -9
- beamlit/functions/decorator.py +0 -12
- beamlit/functions/mcp/mcp.py +4 -8
- beamlit/functions/remote/remote.py +9 -2
- {beamlit-0.0.38rc83.dist-info → beamlit-0.0.40rc84.dist-info}/METADATA +1 -1
- {beamlit-0.0.38rc83.dist-info → beamlit-0.0.40rc84.dist-info}/RECORD +8 -8
- {beamlit-0.0.38rc83.dist-info → beamlit-0.0.40rc84.dist-info}/WHEEL +0 -0
beamlit/agents/decorator.py
CHANGED
@@ -3,14 +3,15 @@ import functools
|
|
3
3
|
import inspect
|
4
4
|
from logging import getLogger
|
5
5
|
|
6
|
+
from langgraph.checkpoint.memory import MemorySaver
|
7
|
+
from langgraph.prebuilt import create_react_agent
|
8
|
+
|
6
9
|
from beamlit.api.models import get_model, list_models
|
7
10
|
from beamlit.authentication import new_client
|
8
11
|
from beamlit.common.settings import init
|
9
12
|
from beamlit.errors import UnexpectedStatus
|
10
13
|
from beamlit.functions import get_functions
|
11
14
|
from beamlit.models import Agent, AgentMetadata, AgentSpec
|
12
|
-
from langgraph.checkpoint.memory import MemorySaver
|
13
|
-
from langgraph.prebuilt import create_react_agent
|
14
15
|
|
15
16
|
from .chat import get_chat_model_full
|
16
17
|
|
@@ -20,7 +21,6 @@ def agent(
|
|
20
21
|
override_model=None,
|
21
22
|
override_agent=None,
|
22
23
|
override_functions=None,
|
23
|
-
mcp_hub=None,
|
24
24
|
remote_functions=None,
|
25
25
|
):
|
26
26
|
logger = getLogger(__name__)
|
@@ -95,7 +95,6 @@ def agent(
|
|
95
95
|
functions = get_functions(
|
96
96
|
client=client,
|
97
97
|
dir=settings.agent.functions_directory,
|
98
|
-
mcp_hub=mcp_hub,
|
99
98
|
remote_functions=remote_functions,
|
100
99
|
chain=agent.spec.agent_chain,
|
101
100
|
remote_functions_empty=not remote_functions,
|
beamlit/common/settings.py
CHANGED
@@ -4,12 +4,8 @@ from typing import Tuple, Type, Union
|
|
4
4
|
from langchain_core.language_models.chat_models import BaseChatModel
|
5
5
|
from langgraph.graph.graph import CompiledGraph
|
6
6
|
from pydantic import Field
|
7
|
-
from pydantic_settings import (
|
8
|
-
|
9
|
-
PydanticBaseSettingsSource,
|
10
|
-
SettingsConfigDict,
|
11
|
-
YamlConfigSettingsSource,
|
12
|
-
)
|
7
|
+
from pydantic_settings import (BaseSettings, PydanticBaseSettingsSource,
|
8
|
+
SettingsConfigDict, YamlConfigSettingsSource)
|
13
9
|
|
14
10
|
from beamlit.common.logger import init as init_logger
|
15
11
|
from beamlit.models import Agent, Function, Model
|
@@ -59,7 +55,6 @@ class Settings(BaseSettings):
|
|
59
55
|
base_url: str = Field(default="https://api.beamlit.com/v0")
|
60
56
|
app_url: str = Field(default="https://app.beamlit.com")
|
61
57
|
run_url: str = Field(default="https://run.beamlit.com")
|
62
|
-
mcp_hub_url: str = Field(default="https://mcp-hub-server.beamlit.workers.com")
|
63
58
|
registry_url: str = Field(default="https://us.registry.beamlit.com")
|
64
59
|
log_level: str = Field(default="INFO")
|
65
60
|
enable_opentelemetry: bool = Field(default=False)
|
@@ -72,10 +67,9 @@ class Settings(BaseSettings):
|
|
72
67
|
if os.getenv('BL_ENV') == 'dev':
|
73
68
|
self.base_url = os.getenv('BL_BASE_URL') or "https://api.beamlit.dev/v0"
|
74
69
|
self.run_url = os.getenv('BL_RUN_URL') or "https://run.beamlit.dev"
|
75
|
-
self.mcp_hub_url = os.getenv('BL_MCP_HUB_URL') or "https://mcp-hub-server.beamlit.workers.dev"
|
76
70
|
self.registry_url = os.getenv('BL_REGISTRY_URL') or "https://eu.registry.beamlit.dev"
|
77
71
|
self.app_url = os.getenv('BL_APP_URL') or "https://app.beamlit.dev"
|
78
|
-
|
72
|
+
|
79
73
|
@classmethod
|
80
74
|
def settings_customise_sources(
|
81
75
|
cls,
|
beamlit/functions/decorator.py
CHANGED
@@ -16,14 +16,12 @@ from beamlit.authentication import new_client
|
|
16
16
|
from beamlit.client import AuthenticatedClient
|
17
17
|
from beamlit.common import slugify
|
18
18
|
from beamlit.common.settings import get_settings
|
19
|
-
from beamlit.functions.mcp.mcp import MCPClient, MCPToolkit
|
20
19
|
from beamlit.functions.remote.remote import RemoteToolkit
|
21
20
|
from beamlit.models import AgentChain, Function, FunctionKit
|
22
21
|
|
23
22
|
logger = getLogger(__name__)
|
24
23
|
|
25
24
|
def get_functions(
|
26
|
-
mcp_hub:Union[list[str], None]=None,
|
27
25
|
remote_functions:Union[list[str], None]=None,
|
28
26
|
client:Union[AuthenticatedClient, None]=None,
|
29
27
|
dir:Union[str, None]=None,
|
@@ -130,16 +128,6 @@ def get_functions(
|
|
130
128
|
except Exception as e:
|
131
129
|
logger.warning(f"Error processing {file_path}: {e!s}")
|
132
130
|
|
133
|
-
if mcp_hub:
|
134
|
-
for server in mcp_hub:
|
135
|
-
try:
|
136
|
-
mcp_client = MCPClient(client, server)
|
137
|
-
toolkit = MCPToolkit(client=mcp_client)
|
138
|
-
toolkit.initialize()
|
139
|
-
functions.extend(toolkit.get_tools())
|
140
|
-
except Exception as e:
|
141
|
-
logger.warn(f"Failed to initialize MCP server {server}: {e!s}")
|
142
|
-
|
143
131
|
if remote_functions:
|
144
132
|
for function in remote_functions:
|
145
133
|
try:
|
beamlit/functions/mcp/mcp.py
CHANGED
@@ -44,26 +44,22 @@ def create_dynamic_schema(name: str, schema: dict[str, t.Any]) -> type[pydantic.
|
|
44
44
|
|
45
45
|
|
46
46
|
class MCPClient:
|
47
|
-
def __init__(self, client: AuthenticatedClient,
|
47
|
+
def __init__(self, client: AuthenticatedClient, url: str):
|
48
48
|
self.client = client
|
49
|
-
self.
|
50
|
-
self.headers = {"Api-Key": "1234567890"}
|
49
|
+
self.url = url
|
51
50
|
|
52
51
|
def list_tools(self) -> requests.Response:
|
53
52
|
client = self.client.get_httpx_client()
|
54
|
-
|
55
|
-
response = client.request("GET", url, headers=self.headers)
|
53
|
+
response = client.request("GET", f"{self.url}/tools/list")
|
56
54
|
response.raise_for_status()
|
57
55
|
return response
|
58
56
|
|
59
57
|
def call_tool(self, tool_name: str, arguments: dict[str, Any] = None) -> requests.Response:
|
60
58
|
client = self.client.get_httpx_client()
|
61
|
-
url = urllib.parse.urljoin(settings.mcp_hub_url, f"{self.server_name}/tools/call")
|
62
59
|
response = client.request(
|
63
60
|
"POST",
|
64
|
-
url,
|
61
|
+
f"{self.url}/tools/call",
|
65
62
|
json={"name": tool_name, "arguments": arguments},
|
66
|
-
headers=self.headers,
|
67
63
|
)
|
68
64
|
response.raise_for_status()
|
69
65
|
return response
|
@@ -10,6 +10,7 @@ from langchain_core.tools.base import BaseTool, ToolException
|
|
10
10
|
from beamlit.api.functions import get_function
|
11
11
|
from beamlit.authentication.authentication import AuthenticatedClient
|
12
12
|
from beamlit.common.settings import get_settings
|
13
|
+
from beamlit.functions.mcp.mcp import MCPClient, MCPToolkit
|
13
14
|
from beamlit.models import Function, StoreFunctionParameter
|
14
15
|
from beamlit.run import RunClient
|
15
16
|
|
@@ -79,11 +80,9 @@ class RemoteToolkit:
|
|
79
80
|
"""
|
80
81
|
Remote toolkit
|
81
82
|
"""
|
82
|
-
|
83
83
|
client: AuthenticatedClient
|
84
84
|
function: str
|
85
85
|
_function: Function | None = None
|
86
|
-
|
87
86
|
model_config = pydantic.ConfigDict(arbitrary_types_allowed=True)
|
88
87
|
|
89
88
|
def initialize(self) -> None:
|
@@ -93,9 +92,17 @@ class RemoteToolkit:
|
|
93
92
|
|
94
93
|
@t.override
|
95
94
|
def get_tools(self) -> list[BaseTool]:
|
95
|
+
settings = get_settings()
|
96
96
|
if self._function is None:
|
97
97
|
raise RuntimeError("Must initialize the toolkit first")
|
98
98
|
|
99
|
+
if self._function.spec.integration_connections:
|
100
|
+
url = f"{settings.run_url}/{settings.workspace}/functions/{self._function.metadata.name}"
|
101
|
+
mcp_client = MCPClient(self.client, url)
|
102
|
+
mcp_toolkit = MCPToolkit(client=mcp_client)
|
103
|
+
mcp_toolkit.initialize()
|
104
|
+
return mcp_toolkit.get_tools()
|
105
|
+
|
99
106
|
if self._function.spec.kit:
|
100
107
|
return [
|
101
108
|
RemoteTool(
|
@@ -7,7 +7,7 @@ beamlit/types.py,sha256=E1hhDh_zXfsSQ0NCt9-uw90_Mr5iIlsdfnfvxv5HarU,1005
|
|
7
7
|
beamlit/agents/__init__.py,sha256=bWsFaXUbAps3IsL3Prti89m1s714vICXodbQi77h3vY,206
|
8
8
|
beamlit/agents/chain.py,sha256=vfCjiFHuu02uTTGicxMlFzjyICQkIjpXrBGs-7uJEsg,2826
|
9
9
|
beamlit/agents/chat.py,sha256=5iv6dM7Xlg2oP2cGgAlpFreJl4P8GZAiN8MM3v0YVYs,4714
|
10
|
-
beamlit/agents/decorator.py,sha256=
|
10
|
+
beamlit/agents/decorator.py,sha256=R5evLoproCgYjKXmH-Vq31r6G2lzZvUitXD1NoTflcA,6014
|
11
11
|
beamlit/agents/thread.py,sha256=LN5Ss-uOf5_hdB0WV1dqpn-N-pDJB3C2hUvlCzdqtdk,519
|
12
12
|
beamlit/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
13
13
|
beamlit/api/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -135,7 +135,7 @@ beamlit/common/error.py,sha256=f9oJDFxhoHK-vpjxBgEp0NwWIk0N_THPemUI7uQxVzU,270
|
|
135
135
|
beamlit/common/instrumentation.py,sha256=L4Y6Xu7rQwIHngfp-d0LtWxReaPte6rIzykvkDaIyzE,9288
|
136
136
|
beamlit/common/logger.py,sha256=nN_dSOl4bs13QU3Rod-w3e3jYOnlSrHx3_bs-ACY6Aw,1115
|
137
137
|
beamlit/common/secrets.py,sha256=sid81bOe3LflkMKDHwBsBs9nIju8bp5-v9qU9gkyNMc,212
|
138
|
-
beamlit/common/settings.py,sha256=
|
138
|
+
beamlit/common/settings.py,sha256=TOHmf9haMq_VUEcbeaWeuS8zRVjLtVdcA0aGhNg32iA,3772
|
139
139
|
beamlit/common/slugify.py,sha256=nR29r37IdWS2i44ZC6ZsXRgqKPYmvMGtFQ7BuIQUTlc,90
|
140
140
|
beamlit/common/utils.py,sha256=jouz5igBvT37Xn_e94-foCHyQczVim-UzVcoIF6RWJ4,657
|
141
141
|
beamlit/deploy/__init__.py,sha256=GS7l7Jtm2yKs7iNLKcfjYO-rAhUzggQ3xiYSf3oxLBY,91
|
@@ -143,15 +143,15 @@ beamlit/deploy/deploy.py,sha256=J5VvXWeyIyz6CWy2ctld28T7sVfas-kiJZ1nx6Zw7t0,1037
|
|
143
143
|
beamlit/deploy/format.py,sha256=U6UZEFAYLnGJJ7O2YmSdlUUFhnWNGAv6NZ-DW4KTgvI,2049
|
144
144
|
beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
|
145
145
|
beamlit/functions/__init__.py,sha256=NcQPZZNfWhAJ1T1F6Xn21LFPMbZ7aMR2Sve3uZOkBCQ,170
|
146
|
-
beamlit/functions/decorator.py,sha256=
|
146
|
+
beamlit/functions/decorator.py,sha256=99oHbss0RZ6Km7Gf62otun1az9waZM0GPaOJvvwbmOI,8541
|
147
147
|
beamlit/functions/github/__init__.py,sha256=gYnUkeegukOfbymdabuuJkScvH-_ZJygX05BoqkPn0o,49
|
148
148
|
beamlit/functions/github/github.py,sha256=RfzWMT9nwPjsCOJr_-emN7eJHCIt2WsvkT9tq8-HfeA,568
|
149
149
|
beamlit/functions/github/kit/__init__.py,sha256=jBwPqZv6C23_utukohxqXZwrlicNlI7PYPUj0Den7Cw,136
|
150
150
|
beamlit/functions/github/kit/pull_request.py,sha256=wQVeRBakiqu-2ouflO8p1z7D5u07KNsitwyNRrp0KjM,1357
|
151
151
|
beamlit/functions/math/__init__.py,sha256=wie4WME8jT-WpFRrtu-lDlHW31Mg6K2cwstjkUdLF3o,43
|
152
152
|
beamlit/functions/math/math.py,sha256=CpoLJGwuvwCPGnVC8k9GYuIyvfUYPDQHKlZg3cx-z-A,1049
|
153
|
-
beamlit/functions/mcp/mcp.py,sha256
|
154
|
-
beamlit/functions/remote/remote.py,sha256=
|
153
|
+
beamlit/functions/mcp/mcp.py,sha256=c7OpmC_zIx1fc2lwoPiyJk_yMyRxWiwCpy9hvRV_C0Y,4080
|
154
|
+
beamlit/functions/remote/remote.py,sha256=NldBFEostIX7yLw8ZE12MgVqhVpvKB4Z6FiQUBhPFsc,4207
|
155
155
|
beamlit/functions/search/__init__.py,sha256=5NAthQ9PBwrkNg1FpLRx4flauvv0HyWuwaVS589c1Pw,49
|
156
156
|
beamlit/functions/search/search.py,sha256=8s9ECltq7YE17j6rTxb12uY2EQY4_eTLHmwlIMThI0w,515
|
157
157
|
beamlit/models/__init__.py,sha256=DB2EBTVX5lTO7CzXvZaqiPtgc9n8SMPu59zGD5_Vvno,9652
|
@@ -285,6 +285,6 @@ beamlit/serve/app.py,sha256=ROS_tb9cO4GvOQKCwloyAzpYraTdIb3oG6sChXikeNw,3285
|
|
285
285
|
beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
|
286
286
|
beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
|
287
287
|
beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
|
288
|
-
beamlit-0.0.
|
289
|
-
beamlit-0.0.
|
290
|
-
beamlit-0.0.
|
288
|
+
beamlit-0.0.40rc84.dist-info/METADATA,sha256=IIgQeS831MisY-EbiNZqA54a05M-Cb3h_2LT3dxqT7o,3715
|
289
|
+
beamlit-0.0.40rc84.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
290
|
+
beamlit-0.0.40rc84.dist-info/RECORD,,
|
File without changes
|