beamlit 0.0.21__py3-none-any.whl → 0.0.22__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- beamlit/agents/chat.py +2 -1
- beamlit/agents/decorator.py +7 -2
- beamlit/authentication/authentication.py +0 -1
- beamlit/authentication/credentials.py +24 -20
- beamlit/client.py +0 -1
- beamlit/common/settings.py +7 -2
- beamlit/functions/decorator.py +4 -5
- beamlit/serve/app.py +0 -1
- {beamlit-0.0.21.dist-info → beamlit-0.0.22.dist-info}/METADATA +1 -1
- {beamlit-0.0.21.dist-info → beamlit-0.0.22.dist-info}/RECORD +11 -11
- {beamlit-0.0.21.dist-info → beamlit-0.0.22.dist-info}/WHEEL +0 -0
beamlit/agents/chat.py
CHANGED
@@ -37,12 +37,13 @@ def get_chat_model(agent_model: AgentDeployment):
|
|
37
37
|
headers = get_authentication_headers(settings)
|
38
38
|
headers["X-Beamlit-Environment"] = agent_model.environment
|
39
39
|
|
40
|
-
jwt = headers.
|
40
|
+
jwt = headers.get("X-Beamlit-Authorization", "").replace("Bearer ", "")
|
41
41
|
params = {"environment": agent_model.environment}
|
42
42
|
chat_classes = {
|
43
43
|
"openai": {
|
44
44
|
"func": get_openai_chat_model,
|
45
45
|
"kwargs": {
|
46
|
+
"http_async_client": client.get_async_httpx_client(),
|
46
47
|
"http_client": client.get_httpx_client(),
|
47
48
|
},
|
48
49
|
},
|
beamlit/agents/decorator.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Import necessary modules
|
2
2
|
import ast
|
3
|
+
import asyncio
|
3
4
|
import importlib
|
4
5
|
import os
|
5
6
|
from logging import getLogger
|
6
7
|
|
8
|
+
from langchain_core.tools import Tool
|
7
9
|
from langgraph.checkpoint.memory import MemorySaver
|
8
10
|
from langgraph.prebuilt import create_react_agent
|
9
11
|
|
@@ -35,7 +37,7 @@ def get_functions(dir="src/functions", from_decorator="function"):
|
|
35
37
|
# Look for function definitions with decorators
|
36
38
|
for node in ast.walk(tree):
|
37
39
|
if (
|
38
|
-
not isinstance(node, ast.FunctionDef)
|
40
|
+
(not isinstance(node, ast.FunctionDef) and not isinstance(node, ast.AsyncFunctionDef))
|
39
41
|
or len(node.decorator_list) == 0
|
40
42
|
):
|
41
43
|
continue
|
@@ -73,7 +75,10 @@ def get_functions(dir="src/functions", from_decorator="function"):
|
|
73
75
|
# Get the decorated function
|
74
76
|
if not is_kit and hasattr(module, func_name):
|
75
77
|
func = getattr(module, func_name)
|
76
|
-
|
78
|
+
if asyncio.iscoroutinefunction(func):
|
79
|
+
functions.append(Tool(name=func.__name__, description=func.__doc__, func=func, coroutine=func))
|
80
|
+
else:
|
81
|
+
functions.append(Tool(name=func.__name__, description=func.__doc__, func=func))
|
77
82
|
except Exception as e:
|
78
83
|
logger.warning(f"Error processing {file_path}: {e!s}")
|
79
84
|
return functions
|
@@ -43,6 +43,28 @@ class Config:
|
|
43
43
|
if self.context is None:
|
44
44
|
self.context = ContextConfig()
|
45
45
|
|
46
|
+
def to_json(self) -> dict:
|
47
|
+
return {
|
48
|
+
"workspaces": [
|
49
|
+
{
|
50
|
+
"name": ws.name,
|
51
|
+
"credentials": {
|
52
|
+
"api_key": ws.credentials.api_key,
|
53
|
+
"access_token": ws.credentials.access_token,
|
54
|
+
"refresh_token": ws.credentials.refresh_token,
|
55
|
+
"expires_in": ws.credentials.expires_in,
|
56
|
+
"device_code": ws.credentials.device_code,
|
57
|
+
"client_credentials": ws.credentials.client_credentials,
|
58
|
+
},
|
59
|
+
}
|
60
|
+
for ws in self.workspaces
|
61
|
+
],
|
62
|
+
"context": {
|
63
|
+
"workspace": self.context.workspace,
|
64
|
+
"environment": self.context.environment,
|
65
|
+
},
|
66
|
+
}
|
67
|
+
|
46
68
|
|
47
69
|
def load_config() -> Config:
|
48
70
|
config = Config()
|
@@ -68,23 +90,6 @@ def load_config() -> Config:
|
|
68
90
|
|
69
91
|
|
70
92
|
def save_config(config: Config):
|
71
|
-
data = {
|
72
|
-
"workspaces": [
|
73
|
-
{
|
74
|
-
"name": ws.name,
|
75
|
-
"credentials": {
|
76
|
-
"access_token": ws.credentials.access_token,
|
77
|
-
"api_key": ws.credentials.api_key,
|
78
|
-
},
|
79
|
-
}
|
80
|
-
for ws in config.workspaces
|
81
|
-
],
|
82
|
-
"context": {
|
83
|
-
"workspace": config.context.workspace,
|
84
|
-
"environment": config.context.environment,
|
85
|
-
},
|
86
|
-
}
|
87
|
-
|
88
93
|
home_dir = Path.home()
|
89
94
|
if not home_dir:
|
90
95
|
raise RuntimeError("Could not determine home directory")
|
@@ -93,9 +98,8 @@ def save_config(config: Config):
|
|
93
98
|
config_file = config_dir / "config.yaml"
|
94
99
|
|
95
100
|
config_dir.mkdir(mode=0o700, parents=True, exist_ok=True)
|
96
|
-
|
97
101
|
with open(config_file, "w", encoding="utf-8") as f:
|
98
|
-
yaml.dump(
|
102
|
+
yaml.dump(config.to_json(), f)
|
99
103
|
|
100
104
|
|
101
105
|
def list_workspaces() -> List[str]:
|
@@ -126,7 +130,7 @@ def load_credentials(workspace_name: str) -> Credentials:
|
|
126
130
|
def load_credentials_from_settings(settings: Settings) -> Credentials:
|
127
131
|
return Credentials(
|
128
132
|
api_key=settings.authentication.api_key,
|
129
|
-
client_credentials=settings.authentication.
|
133
|
+
client_credentials=settings.authentication.client.credentials,
|
130
134
|
)
|
131
135
|
|
132
136
|
|
beamlit/client.py
CHANGED
@@ -248,7 +248,6 @@ class AuthenticatedClient:
|
|
248
248
|
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
249
249
|
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
250
250
|
if self._async_client is None:
|
251
|
-
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
252
251
|
self._async_client = httpx.AsyncClient(
|
253
252
|
base_url=self._base_url,
|
254
253
|
cookies=self._cookies,
|
beamlit/common/settings.py
CHANGED
@@ -39,10 +39,14 @@ class SettingsAgent(BaseSettings):
|
|
39
39
|
module: str = Field(default="main.main")
|
40
40
|
|
41
41
|
|
42
|
+
class SettingsAuthenticationClient(BaseSettings):
|
43
|
+
credentials: Union[None, str] = None
|
44
|
+
|
45
|
+
|
42
46
|
class SettingsAuthentication(BaseSettings):
|
43
47
|
api_key: Union[None, str] = None
|
44
48
|
jwt: Union[None, str] = None
|
45
|
-
|
49
|
+
client: SettingsAuthenticationClient = SettingsAuthenticationClient()
|
46
50
|
|
47
51
|
|
48
52
|
class SettingsServer(BaseSettings):
|
@@ -56,10 +60,11 @@ class Settings(BaseSettings):
|
|
56
60
|
yaml_file="beamlit.yaml",
|
57
61
|
env_prefix="bl_",
|
58
62
|
env_nested_delimiter="_",
|
63
|
+
extra="ignore",
|
59
64
|
)
|
60
65
|
|
61
66
|
workspace: str
|
62
|
-
environment: str
|
67
|
+
environment: str = Field(default="production")
|
63
68
|
type: str = Field(default="agent")
|
64
69
|
name: str = Field(default="beamlit-agent")
|
65
70
|
base_url: str = Field(default="https://api.beamlit.dev/v0")
|
beamlit/functions/decorator.py
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
from collections.abc import Callable
|
4
4
|
from logging import getLogger
|
5
5
|
|
6
|
-
from langchain_core.tools import create_schema_from_function
|
6
|
+
from langchain_core.tools import create_schema_from_function
|
7
7
|
|
8
8
|
from beamlit.authentication import new_client
|
9
9
|
from beamlit.common.settings import get_settings
|
@@ -58,7 +58,7 @@ def kit(bl_kit: FunctionKit = None, **kwargs: dict) -> Callable:
|
|
58
58
|
def wrapper(func: Callable) -> Callable:
|
59
59
|
if bl_kit and not func.__doc__ and bl_kit.description:
|
60
60
|
func.__doc__ = bl_kit.description
|
61
|
-
return
|
61
|
+
return func
|
62
62
|
|
63
63
|
return wrapper
|
64
64
|
|
@@ -83,8 +83,7 @@ def function(
|
|
83
83
|
func,
|
84
84
|
parse_docstring=func.__doc__,
|
85
85
|
)
|
86
|
-
return
|
87
|
-
return
|
86
|
+
return remote_func
|
87
|
+
return func
|
88
88
|
|
89
89
|
return wrapper
|
90
|
-
return wrapper
|
beamlit/serve/app.py
CHANGED
@@ -16,7 +16,6 @@ from .middlewares import AccessLogMiddleware, AddProcessTimeHeader
|
|
16
16
|
sys.path.insert(0, os.getcwd())
|
17
17
|
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
18
18
|
|
19
|
-
|
20
19
|
def import_module():
|
21
20
|
settings = get_settings()
|
22
21
|
main_module = importlib.import_module(".".join(settings.server.module.split(".")[0:-1]))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
beamlit/__init__.py,sha256=545gFC-wLLwUktWcOAjUWe_Glha40tBetRTOYSfHnbI,164
|
2
|
-
beamlit/client.py,sha256=
|
2
|
+
beamlit/client.py,sha256=OdRbs5VVHF32HUd5RMcnkhe8YxamnAmgGlxO6pm1Xac,12431
|
3
3
|
beamlit/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
4
4
|
beamlit/py.typed,sha256=8ZJUsxZiuOy1oJeVhsTWQhTG_6pTVHVXk5hJL79ebTk,25
|
5
5
|
beamlit/run.py,sha256=y61iDBaR0917ihj5q-cJ_r3BFW1Rn5K_kDAISw5O6aU,1339
|
6
6
|
beamlit/types.py,sha256=E1hhDh_zXfsSQ0NCt9-uw90_Mr5iIlsdfnfvxv5HarU,1005
|
7
7
|
beamlit/agents/__init__.py,sha256=nf1iwQwGtCG6nDqyVhxfWoqR6dv6X3bvSpCeqkTCFaM,101
|
8
|
-
beamlit/agents/chat.py,sha256=
|
9
|
-
beamlit/agents/decorator.py,sha256=
|
8
|
+
beamlit/agents/chat.py,sha256=aI7pObyywRyg3dBpubzHAUWTbTk1nwtxvpY7iIP1RLY,2704
|
9
|
+
beamlit/agents/decorator.py,sha256=sN-JsLaPwiL-zzH5eZak76y3ObluIy8NFC3xpHFcDWc,6469
|
10
10
|
beamlit/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
11
11
|
beamlit/api/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
beamlit/api/agents/create_agent.py,sha256=HFExosu02JZqZz7I6U6WjN81TERz6p2i8CzQCyiRYXo,4112
|
@@ -130,18 +130,18 @@ beamlit/api/workspaces/update_workspace.py,sha256=qa5DV2UJSUYuB_ibALb4E9ghKpT1Ha
|
|
130
130
|
beamlit/api/workspaces/update_workspace_user_role.py,sha256=Yn9iuJ4tKtauzBiJyU4-wYUMS9g98X2Om8zs7UkzrY8,4917
|
131
131
|
beamlit/authentication/__init__.py,sha256=wiXqRbc7E-ulrH_ueA9duOGFvXeo7-RvhSD1XbFogMo,1020
|
132
132
|
beamlit/authentication/apikey.py,sha256=jnz1FMRauI5qAInqeeDER8aCONx4O8ZPZGedvi3Ap_o,659
|
133
|
-
beamlit/authentication/authentication.py,sha256=
|
133
|
+
beamlit/authentication/authentication.py,sha256=tZu8GoVueKDuq1RLXMvtHcV95XLikmQ19PCxLWBn2Ek,3120
|
134
134
|
beamlit/authentication/clientcredentials.py,sha256=6kbfTjwUkXUArJX8XZLe9ZzbEicQc19tSXBvsTpiXMk,3954
|
135
|
-
beamlit/authentication/credentials.py,sha256=
|
135
|
+
beamlit/authentication/credentials.py,sha256=DlfiF_FfOosPVsRoa39JSR3XoICmhBqTlHXc6b4zWtE,5349
|
136
136
|
beamlit/authentication/device_mode.py,sha256=oQVBCDsq-pdeXF31WSTAAEdaX6eACV7SYcOSyf3ea_Q,3728
|
137
137
|
beamlit/common/__init__.py,sha256=yDoMJDKj-xjTGl7U1YI59KpWxiOV65HSiUulgO8xdTA,277
|
138
138
|
beamlit/common/generate.py,sha256=VJ_MiRDulXdQdnlKdM4_Bod6CO6DOGlFiosGXOLuLGs,7227
|
139
139
|
beamlit/common/logger.py,sha256=ayabnsoHS8ncXm8EpBS01FkvSe0XRcaNdQjKVuPI5z4,1025
|
140
140
|
beamlit/common/secrets.py,sha256=sid81bOe3LflkMKDHwBsBs9nIju8bp5-v9qU9gkyNMc,212
|
141
|
-
beamlit/common/settings.py,sha256=
|
141
|
+
beamlit/common/settings.py,sha256=6iLf_7SZ8LV72ZU88ACfac0EcgtEf79rox1jOY7RmQE,5395
|
142
142
|
beamlit/common/utils.py,sha256=jouz5igBvT37Xn_e94-foCHyQczVim-UzVcoIF6RWJ4,657
|
143
143
|
beamlit/functions/__init__.py,sha256=_RPG1Bfg54JGdIPnViAU6n9zD7E1cDNsdXi8oYGskzE,138
|
144
|
-
beamlit/functions/decorator.py,sha256
|
144
|
+
beamlit/functions/decorator.py,sha256=qThFujZ3RSSQ2g9kSjrVtPs9SVbgp_jB3w5XaQOvFvk,3095
|
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
|
@@ -292,10 +292,10 @@ beamlit/models/websocket_channel.py,sha256=tyNtsVR0cOwd6BK--ehBCH8bIjxtyPhiAkrxY
|
|
292
292
|
beamlit/models/workspace.py,sha256=s7wS6ibswosB0FdUb3ry3BnlLa325axBdYPLI3ipe0Q,3986
|
293
293
|
beamlit/models/workspace_labels.py,sha256=WbnUY6eCTkUNdY7hhhSF-KQCl8fWFfkCf7hzCTiNp4A,1246
|
294
294
|
beamlit/models/workspace_user.py,sha256=70CcifQWYbeWG7TDui4pblTzUe5sVK0AS19vNCzKE8g,3423
|
295
|
-
beamlit/serve/app.py,sha256
|
295
|
+
beamlit/serve/app.py,sha256=_0ZesKcczd1sYm8vs3ulbXO1M1boO_5DhFf3jSmjM4g,2398
|
296
296
|
beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
|
297
297
|
beamlit/serve/middlewares/accesslog.py,sha256=wM52-hcwtO-_hdM1pnsEJzerzJf1MzEyN5m85BdDccE,609
|
298
298
|
beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
|
299
|
-
beamlit-0.0.
|
300
|
-
beamlit-0.0.
|
301
|
-
beamlit-0.0.
|
299
|
+
beamlit-0.0.22.dist-info/METADATA,sha256=5rjMq-UV1Mj14WmjhAfGw4jmzuACjWv2ykSDg3mKJiI,2023
|
300
|
+
beamlit-0.0.22.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
301
|
+
beamlit-0.0.22.dist-info/RECORD,,
|
File without changes
|