blaxel 0.1.9rc35__py3-none-any.whl → 0.1.9rc36__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.
Files changed (59) hide show
  1. blaxel/agents/__init__.py +1 -1
  2. blaxel/authentication/__init__.py +3 -4
  3. blaxel/client/api/compute/__init__.py +0 -0
  4. blaxel/client/api/compute/create_sandbox.py +166 -0
  5. blaxel/client/api/compute/delete_sandbox.py +154 -0
  6. blaxel/client/api/compute/get_sandbox.py +154 -0
  7. blaxel/client/api/compute/list_sandboxes.py +135 -0
  8. blaxel/client/api/compute/start_sandbox.py +157 -0
  9. blaxel/client/api/compute/stop_sandbox.py +157 -0
  10. blaxel/client/api/compute/update_sandbox.py +179 -0
  11. blaxel/client/api/default/list_sandbox_hub_definitions.py +123 -0
  12. blaxel/client/api/functions/list_function_revisions.py +16 -11
  13. blaxel/client/api/knowledgebases/list_knowledgebase_revisions.py +16 -11
  14. blaxel/client/api/models/list_model_revisions.py +16 -11
  15. blaxel/client/api/templates/list_templates.py +16 -11
  16. blaxel/client/models/__init__.py +32 -2
  17. blaxel/client/models/agent_spec.py +25 -69
  18. blaxel/client/models/core_spec.py +1 -45
  19. blaxel/client/models/function_spec.py +1 -45
  20. blaxel/client/models/last_n_requests_metric.py +18 -0
  21. blaxel/client/models/metrics.py +20 -0
  22. blaxel/client/models/model_spec.py +1 -45
  23. blaxel/client/models/{agent_chain.py → port.py} +23 -32
  24. blaxel/client/models/request_total_metric.py +12 -1
  25. blaxel/client/models/request_total_response_data.py +97 -0
  26. blaxel/client/models/resource_log.py +9 -0
  27. blaxel/client/models/resource_metrics.py +144 -0
  28. blaxel/client/models/resource_metrics_request_total_per_code_previous.py +45 -0
  29. blaxel/client/models/resource_metrics_rps_per_code_previous.py +45 -0
  30. blaxel/client/models/runtime.py +83 -7
  31. blaxel/client/models/runtime_configuration.py +45 -0
  32. blaxel/client/models/sandbox.py +129 -0
  33. blaxel/client/models/sandbox_definition.py +181 -0
  34. blaxel/client/models/sandbox_spec.py +208 -0
  35. blaxel/client/models/sandboxes.py +129 -0
  36. blaxel/client/models/serverless_config.py +29 -1
  37. blaxel/client/models/serverless_config_configuration.py +45 -0
  38. blaxel/client/models/start_sandbox.py +94 -0
  39. blaxel/client/models/stop_sandbox.py +94 -0
  40. blaxel/client/models/trigger.py +98 -0
  41. blaxel/client/models/trigger_configuration.py +45 -0
  42. blaxel/client/models/workspace.py +20 -0
  43. blaxel/client/models/workspace_runtime.py +61 -0
  44. blaxel/common/autoload.py +0 -1
  45. blaxel/instrumentation/exporters.py +3 -6
  46. blaxel/instrumentation/manager.py +5 -3
  47. blaxel/mcp/client.py +1 -3
  48. blaxel/mcp/server.py +2 -3
  49. blaxel/models/__init__.py +2 -1
  50. blaxel/models/custom/langchain/gemini.py +41 -18
  51. blaxel/models/custom/llamaindex/cohere.py +25 -16
  52. blaxel/models/custom/pydantic/gemini.py +0 -1
  53. blaxel/models/livekit.py +1 -1
  54. blaxel/tools/__init__.py +1 -1
  55. blaxel/tools/langchain.py +1 -2
  56. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/METADATA +1 -4
  57. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/RECORD +59 -36
  58. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/WHEEL +0 -0
  59. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/licenses/LICENSE +0 -0
blaxel/agents/__init__.py CHANGED
@@ -98,5 +98,5 @@ async def get_agent_metadata(name):
98
98
  return Agent.from_dict(cache_data)
99
99
  try:
100
100
  return await get_agent.asyncio(client=client, agent_name=name)
101
- except Exception as e:
101
+ except Exception:
102
102
  return None
@@ -4,7 +4,6 @@ from pathlib import Path
4
4
  from typing import Optional
5
5
 
6
6
  import yaml
7
- from httpx import Auth
8
7
 
9
8
  from .apikey import ApiKey
10
9
  from .clientcredentials import ClientCredentials
@@ -73,15 +72,15 @@ def auth(env: str, base_url: str) -> BlaxelAuth:
73
72
  return None
74
73
 
75
74
  if credentials.api_key:
76
- logger.debug(f"Using API key for authentication")
75
+ logger.debug("Using API key for authentication")
77
76
  return ApiKey(credentials, credentials.workspace, base_url)
78
77
 
79
78
  if credentials.client_credentials:
80
- logger.debug(f"Using client credentials for authentication")
79
+ logger.debug("Using client credentials for authentication")
81
80
  return ClientCredentials(credentials, credentials.workspace, base_url)
82
81
 
83
82
  if credentials.device_code:
84
- logger.debug(f"Using device code for authentication")
83
+ logger.debug("Using device code for authentication")
85
84
  return DeviceMode(credentials, credentials.workspace, base_url)
86
85
 
87
86
  return BlaxelAuth(credentials, credentials.workspace, base_url)
File without changes
@@ -0,0 +1,166 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import Client
8
+ from ...models.sandbox import Sandbox
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ *,
14
+ body: Sandbox,
15
+ ) -> dict[str, Any]:
16
+ headers: dict[str, Any] = {}
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "post",
20
+ "url": "/sandboxes",
21
+ }
22
+
23
+ if type(body) == dict:
24
+ _body = body
25
+ else:
26
+ _body = body.to_dict()
27
+
28
+ _kwargs["json"] = _body
29
+ headers["Content-Type"] = "application/json"
30
+
31
+ _kwargs["headers"] = headers
32
+ return _kwargs
33
+
34
+
35
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Sandbox]:
36
+ if response.status_code == 200:
37
+ response_200 = Sandbox.from_dict(response.json())
38
+
39
+ return response_200
40
+ if client.raise_on_unexpected_status:
41
+ raise errors.UnexpectedStatus(response.status_code, response.content)
42
+ else:
43
+ return None
44
+
45
+
46
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Sandbox]:
47
+ return Response(
48
+ status_code=HTTPStatus(response.status_code),
49
+ content=response.content,
50
+ headers=response.headers,
51
+ parsed=_parse_response(client=client, response=response),
52
+ )
53
+
54
+
55
+ def sync_detailed(
56
+ *,
57
+ client: Union[Client],
58
+ body: Sandbox,
59
+ ) -> Response[Sandbox]:
60
+ """Create Sandbox
61
+
62
+ Creates a Sandbox.
63
+
64
+ Args:
65
+ body (Sandbox): Micro VM for running agentic tasks
66
+
67
+ Raises:
68
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
69
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
70
+
71
+ Returns:
72
+ Response[Sandbox]
73
+ """
74
+
75
+ kwargs = _get_kwargs(
76
+ body=body,
77
+ )
78
+
79
+ response = client.get_httpx_client().request(
80
+ **kwargs,
81
+ )
82
+
83
+ return _build_response(client=client, response=response)
84
+
85
+
86
+ def sync(
87
+ *,
88
+ client: Union[Client],
89
+ body: Sandbox,
90
+ ) -> Optional[Sandbox]:
91
+ """Create Sandbox
92
+
93
+ Creates a Sandbox.
94
+
95
+ Args:
96
+ body (Sandbox): Micro VM for running agentic tasks
97
+
98
+ Raises:
99
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
100
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
101
+
102
+ Returns:
103
+ Sandbox
104
+ """
105
+
106
+ return sync_detailed(
107
+ client=client,
108
+ body=body,
109
+ ).parsed
110
+
111
+
112
+ async def asyncio_detailed(
113
+ *,
114
+ client: Union[Client],
115
+ body: Sandbox,
116
+ ) -> Response[Sandbox]:
117
+ """Create Sandbox
118
+
119
+ Creates a Sandbox.
120
+
121
+ Args:
122
+ body (Sandbox): Micro VM for running agentic tasks
123
+
124
+ Raises:
125
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
126
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
127
+
128
+ Returns:
129
+ Response[Sandbox]
130
+ """
131
+
132
+ kwargs = _get_kwargs(
133
+ body=body,
134
+ )
135
+
136
+ response = await client.get_async_httpx_client().request(**kwargs)
137
+
138
+ return _build_response(client=client, response=response)
139
+
140
+
141
+ async def asyncio(
142
+ *,
143
+ client: Union[Client],
144
+ body: Sandbox,
145
+ ) -> Optional[Sandbox]:
146
+ """Create Sandbox
147
+
148
+ Creates a Sandbox.
149
+
150
+ Args:
151
+ body (Sandbox): Micro VM for running agentic tasks
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ Sandbox
159
+ """
160
+
161
+ return (
162
+ await asyncio_detailed(
163
+ client=client,
164
+ body=body,
165
+ )
166
+ ).parsed
@@ -0,0 +1,154 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import Client
8
+ from ...models.sandbox import Sandbox
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ sandbox_name: str,
14
+ ) -> dict[str, Any]:
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "delete",
17
+ "url": f"/sandboxes/{sandbox_name}",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Sandbox]:
24
+ if response.status_code == 200:
25
+ response_200 = Sandbox.from_dict(response.json())
26
+
27
+ return response_200
28
+ if client.raise_on_unexpected_status:
29
+ raise errors.UnexpectedStatus(response.status_code, response.content)
30
+ else:
31
+ return None
32
+
33
+
34
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Sandbox]:
35
+ return Response(
36
+ status_code=HTTPStatus(response.status_code),
37
+ content=response.content,
38
+ headers=response.headers,
39
+ parsed=_parse_response(client=client, response=response),
40
+ )
41
+
42
+
43
+ def sync_detailed(
44
+ sandbox_name: str,
45
+ *,
46
+ client: Union[Client],
47
+ ) -> Response[Sandbox]:
48
+ """Delete Sandbox
49
+
50
+ Deletes a Sandbox by name.
51
+
52
+ Args:
53
+ sandbox_name (str):
54
+
55
+ Raises:
56
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
57
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
58
+
59
+ Returns:
60
+ Response[Sandbox]
61
+ """
62
+
63
+ kwargs = _get_kwargs(
64
+ sandbox_name=sandbox_name,
65
+ )
66
+
67
+ response = client.get_httpx_client().request(
68
+ **kwargs,
69
+ )
70
+
71
+ return _build_response(client=client, response=response)
72
+
73
+
74
+ def sync(
75
+ sandbox_name: str,
76
+ *,
77
+ client: Union[Client],
78
+ ) -> Optional[Sandbox]:
79
+ """Delete Sandbox
80
+
81
+ Deletes a Sandbox by name.
82
+
83
+ Args:
84
+ sandbox_name (str):
85
+
86
+ Raises:
87
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
88
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
89
+
90
+ Returns:
91
+ Sandbox
92
+ """
93
+
94
+ return sync_detailed(
95
+ sandbox_name=sandbox_name,
96
+ client=client,
97
+ ).parsed
98
+
99
+
100
+ async def asyncio_detailed(
101
+ sandbox_name: str,
102
+ *,
103
+ client: Union[Client],
104
+ ) -> Response[Sandbox]:
105
+ """Delete Sandbox
106
+
107
+ Deletes a Sandbox by name.
108
+
109
+ Args:
110
+ sandbox_name (str):
111
+
112
+ Raises:
113
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
114
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
115
+
116
+ Returns:
117
+ Response[Sandbox]
118
+ """
119
+
120
+ kwargs = _get_kwargs(
121
+ sandbox_name=sandbox_name,
122
+ )
123
+
124
+ response = await client.get_async_httpx_client().request(**kwargs)
125
+
126
+ return _build_response(client=client, response=response)
127
+
128
+
129
+ async def asyncio(
130
+ sandbox_name: str,
131
+ *,
132
+ client: Union[Client],
133
+ ) -> Optional[Sandbox]:
134
+ """Delete Sandbox
135
+
136
+ Deletes a Sandbox by name.
137
+
138
+ Args:
139
+ sandbox_name (str):
140
+
141
+ Raises:
142
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
143
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
144
+
145
+ Returns:
146
+ Sandbox
147
+ """
148
+
149
+ return (
150
+ await asyncio_detailed(
151
+ sandbox_name=sandbox_name,
152
+ client=client,
153
+ )
154
+ ).parsed
@@ -0,0 +1,154 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import Client
8
+ from ...models.sandbox import Sandbox
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ sandbox_name: str,
14
+ ) -> dict[str, Any]:
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": f"/sandboxes/{sandbox_name}",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Sandbox]:
24
+ if response.status_code == 200:
25
+ response_200 = Sandbox.from_dict(response.json())
26
+
27
+ return response_200
28
+ if client.raise_on_unexpected_status:
29
+ raise errors.UnexpectedStatus(response.status_code, response.content)
30
+ else:
31
+ return None
32
+
33
+
34
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Sandbox]:
35
+ return Response(
36
+ status_code=HTTPStatus(response.status_code),
37
+ content=response.content,
38
+ headers=response.headers,
39
+ parsed=_parse_response(client=client, response=response),
40
+ )
41
+
42
+
43
+ def sync_detailed(
44
+ sandbox_name: str,
45
+ *,
46
+ client: Union[Client],
47
+ ) -> Response[Sandbox]:
48
+ """Get Sandbox
49
+
50
+ Returns a Sandbox by name.
51
+
52
+ Args:
53
+ sandbox_name (str):
54
+
55
+ Raises:
56
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
57
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
58
+
59
+ Returns:
60
+ Response[Sandbox]
61
+ """
62
+
63
+ kwargs = _get_kwargs(
64
+ sandbox_name=sandbox_name,
65
+ )
66
+
67
+ response = client.get_httpx_client().request(
68
+ **kwargs,
69
+ )
70
+
71
+ return _build_response(client=client, response=response)
72
+
73
+
74
+ def sync(
75
+ sandbox_name: str,
76
+ *,
77
+ client: Union[Client],
78
+ ) -> Optional[Sandbox]:
79
+ """Get Sandbox
80
+
81
+ Returns a Sandbox by name.
82
+
83
+ Args:
84
+ sandbox_name (str):
85
+
86
+ Raises:
87
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
88
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
89
+
90
+ Returns:
91
+ Sandbox
92
+ """
93
+
94
+ return sync_detailed(
95
+ sandbox_name=sandbox_name,
96
+ client=client,
97
+ ).parsed
98
+
99
+
100
+ async def asyncio_detailed(
101
+ sandbox_name: str,
102
+ *,
103
+ client: Union[Client],
104
+ ) -> Response[Sandbox]:
105
+ """Get Sandbox
106
+
107
+ Returns a Sandbox by name.
108
+
109
+ Args:
110
+ sandbox_name (str):
111
+
112
+ Raises:
113
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
114
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
115
+
116
+ Returns:
117
+ Response[Sandbox]
118
+ """
119
+
120
+ kwargs = _get_kwargs(
121
+ sandbox_name=sandbox_name,
122
+ )
123
+
124
+ response = await client.get_async_httpx_client().request(**kwargs)
125
+
126
+ return _build_response(client=client, response=response)
127
+
128
+
129
+ async def asyncio(
130
+ sandbox_name: str,
131
+ *,
132
+ client: Union[Client],
133
+ ) -> Optional[Sandbox]:
134
+ """Get Sandbox
135
+
136
+ Returns a Sandbox by name.
137
+
138
+ Args:
139
+ sandbox_name (str):
140
+
141
+ Raises:
142
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
143
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
144
+
145
+ Returns:
146
+ Sandbox
147
+ """
148
+
149
+ return (
150
+ await asyncio_detailed(
151
+ sandbox_name=sandbox_name,
152
+ client=client,
153
+ )
154
+ ).parsed
@@ -0,0 +1,135 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import Client
8
+ from ...models.sandbox import Sandbox
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs() -> dict[str, Any]:
13
+ _kwargs: dict[str, Any] = {
14
+ "method": "get",
15
+ "url": "/sandboxes",
16
+ }
17
+
18
+ return _kwargs
19
+
20
+
21
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[list["Sandbox"]]:
22
+ if response.status_code == 200:
23
+ response_200 = []
24
+ _response_200 = response.json()
25
+ for response_200_item_data in _response_200:
26
+ response_200_item = Sandbox.from_dict(response_200_item_data)
27
+
28
+ response_200.append(response_200_item)
29
+
30
+ return response_200
31
+ if client.raise_on_unexpected_status:
32
+ raise errors.UnexpectedStatus(response.status_code, response.content)
33
+ else:
34
+ return None
35
+
36
+
37
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[list["Sandbox"]]:
38
+ return Response(
39
+ status_code=HTTPStatus(response.status_code),
40
+ content=response.content,
41
+ headers=response.headers,
42
+ parsed=_parse_response(client=client, response=response),
43
+ )
44
+
45
+
46
+ def sync_detailed(
47
+ *,
48
+ client: Union[Client],
49
+ ) -> Response[list["Sandbox"]]:
50
+ """List Sandboxes
51
+
52
+ Returns a list of all Sandboxes in the workspace.
53
+
54
+ Raises:
55
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
56
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
57
+
58
+ Returns:
59
+ Response[list['Sandbox']]
60
+ """
61
+
62
+ kwargs = _get_kwargs()
63
+
64
+ response = client.get_httpx_client().request(
65
+ **kwargs,
66
+ )
67
+
68
+ return _build_response(client=client, response=response)
69
+
70
+
71
+ def sync(
72
+ *,
73
+ client: Union[Client],
74
+ ) -> Optional[list["Sandbox"]]:
75
+ """List Sandboxes
76
+
77
+ Returns a list of all Sandboxes in the workspace.
78
+
79
+ Raises:
80
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
81
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
82
+
83
+ Returns:
84
+ list['Sandbox']
85
+ """
86
+
87
+ return sync_detailed(
88
+ client=client,
89
+ ).parsed
90
+
91
+
92
+ async def asyncio_detailed(
93
+ *,
94
+ client: Union[Client],
95
+ ) -> Response[list["Sandbox"]]:
96
+ """List Sandboxes
97
+
98
+ Returns a list of all Sandboxes in the workspace.
99
+
100
+ Raises:
101
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
102
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
103
+
104
+ Returns:
105
+ Response[list['Sandbox']]
106
+ """
107
+
108
+ kwargs = _get_kwargs()
109
+
110
+ response = await client.get_async_httpx_client().request(**kwargs)
111
+
112
+ return _build_response(client=client, response=response)
113
+
114
+
115
+ async def asyncio(
116
+ *,
117
+ client: Union[Client],
118
+ ) -> Optional[list["Sandbox"]]:
119
+ """List Sandboxes
120
+
121
+ Returns a list of all Sandboxes in the workspace.
122
+
123
+ Raises:
124
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
125
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
126
+
127
+ Returns:
128
+ list['Sandbox']
129
+ """
130
+
131
+ return (
132
+ await asyncio_detailed(
133
+ client=client,
134
+ )
135
+ ).parsed