blaxel 0.1.9rc35__py3-none-any.whl → 0.1.9rc37__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 (61) hide show
  1. blaxel/agents/__init__.py +53 -16
  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 -4
  45. blaxel/common/internal.py +75 -0
  46. blaxel/common/settings.py +6 -1
  47. blaxel/instrumentation/exporters.py +3 -6
  48. blaxel/instrumentation/manager.py +5 -3
  49. blaxel/mcp/client.py +1 -3
  50. blaxel/mcp/server.py +4 -4
  51. blaxel/models/__init__.py +2 -1
  52. blaxel/models/custom/langchain/gemini.py +41 -18
  53. blaxel/models/custom/llamaindex/cohere.py +25 -16
  54. blaxel/models/custom/pydantic/gemini.py +0 -1
  55. blaxel/models/livekit.py +1 -1
  56. blaxel/tools/__init__.py +63 -22
  57. blaxel/tools/langchain.py +1 -2
  58. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/METADATA +1 -4
  59. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/RECORD +61 -37
  60. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/WHEEL +0 -0
  61. {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/licenses/LICENSE +0 -0
@@ -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
@@ -0,0 +1,157 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union, cast
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import Client
8
+ from ...models.start_sandbox import StartSandbox
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": "put",
17
+ "url": f"/sandboxes/{sandbox_name}/start",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, StartSandbox]]:
24
+ if response.status_code == 200:
25
+ response_200 = StartSandbox.from_dict(response.json())
26
+
27
+ return response_200
28
+ if response.status_code == 409:
29
+ response_409 = cast(Any, None)
30
+ return response_409
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[Union[Any, StartSandbox]]:
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
+ sandbox_name: str,
48
+ *,
49
+ client: Union[Client],
50
+ ) -> Response[Union[Any, StartSandbox]]:
51
+ """Start Sandbox
52
+
53
+ Starts a Sandbox by name.
54
+
55
+ Args:
56
+ sandbox_name (str):
57
+
58
+ Raises:
59
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
60
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
61
+
62
+ Returns:
63
+ Response[Union[Any, StartSandbox]]
64
+ """
65
+
66
+ kwargs = _get_kwargs(
67
+ sandbox_name=sandbox_name,
68
+ )
69
+
70
+ response = client.get_httpx_client().request(
71
+ **kwargs,
72
+ )
73
+
74
+ return _build_response(client=client, response=response)
75
+
76
+
77
+ def sync(
78
+ sandbox_name: str,
79
+ *,
80
+ client: Union[Client],
81
+ ) -> Optional[Union[Any, StartSandbox]]:
82
+ """Start Sandbox
83
+
84
+ Starts a Sandbox by name.
85
+
86
+ Args:
87
+ sandbox_name (str):
88
+
89
+ Raises:
90
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
91
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
92
+
93
+ Returns:
94
+ Union[Any, StartSandbox]
95
+ """
96
+
97
+ return sync_detailed(
98
+ sandbox_name=sandbox_name,
99
+ client=client,
100
+ ).parsed
101
+
102
+
103
+ async def asyncio_detailed(
104
+ sandbox_name: str,
105
+ *,
106
+ client: Union[Client],
107
+ ) -> Response[Union[Any, StartSandbox]]:
108
+ """Start Sandbox
109
+
110
+ Starts a Sandbox by name.
111
+
112
+ Args:
113
+ sandbox_name (str):
114
+
115
+ Raises:
116
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
117
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
118
+
119
+ Returns:
120
+ Response[Union[Any, StartSandbox]]
121
+ """
122
+
123
+ kwargs = _get_kwargs(
124
+ sandbox_name=sandbox_name,
125
+ )
126
+
127
+ response = await client.get_async_httpx_client().request(**kwargs)
128
+
129
+ return _build_response(client=client, response=response)
130
+
131
+
132
+ async def asyncio(
133
+ sandbox_name: str,
134
+ *,
135
+ client: Union[Client],
136
+ ) -> Optional[Union[Any, StartSandbox]]:
137
+ """Start Sandbox
138
+
139
+ Starts a Sandbox by name.
140
+
141
+ Args:
142
+ sandbox_name (str):
143
+
144
+ Raises:
145
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
146
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
147
+
148
+ Returns:
149
+ Union[Any, StartSandbox]
150
+ """
151
+
152
+ return (
153
+ await asyncio_detailed(
154
+ sandbox_name=sandbox_name,
155
+ client=client,
156
+ )
157
+ ).parsed
@@ -0,0 +1,157 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union, cast
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import Client
8
+ from ...models.stop_sandbox import StopSandbox
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": "put",
17
+ "url": f"/sandboxes/{sandbox_name}/stop",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, StopSandbox]]:
24
+ if response.status_code == 200:
25
+ response_200 = StopSandbox.from_dict(response.json())
26
+
27
+ return response_200
28
+ if response.status_code == 409:
29
+ response_409 = cast(Any, None)
30
+ return response_409
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[Union[Any, StopSandbox]]:
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
+ sandbox_name: str,
48
+ *,
49
+ client: Union[Client],
50
+ ) -> Response[Union[Any, StopSandbox]]:
51
+ """Stop Sandbox
52
+
53
+ Stops a Sandbox by name.
54
+
55
+ Args:
56
+ sandbox_name (str):
57
+
58
+ Raises:
59
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
60
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
61
+
62
+ Returns:
63
+ Response[Union[Any, StopSandbox]]
64
+ """
65
+
66
+ kwargs = _get_kwargs(
67
+ sandbox_name=sandbox_name,
68
+ )
69
+
70
+ response = client.get_httpx_client().request(
71
+ **kwargs,
72
+ )
73
+
74
+ return _build_response(client=client, response=response)
75
+
76
+
77
+ def sync(
78
+ sandbox_name: str,
79
+ *,
80
+ client: Union[Client],
81
+ ) -> Optional[Union[Any, StopSandbox]]:
82
+ """Stop Sandbox
83
+
84
+ Stops a Sandbox by name.
85
+
86
+ Args:
87
+ sandbox_name (str):
88
+
89
+ Raises:
90
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
91
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
92
+
93
+ Returns:
94
+ Union[Any, StopSandbox]
95
+ """
96
+
97
+ return sync_detailed(
98
+ sandbox_name=sandbox_name,
99
+ client=client,
100
+ ).parsed
101
+
102
+
103
+ async def asyncio_detailed(
104
+ sandbox_name: str,
105
+ *,
106
+ client: Union[Client],
107
+ ) -> Response[Union[Any, StopSandbox]]:
108
+ """Stop Sandbox
109
+
110
+ Stops a Sandbox by name.
111
+
112
+ Args:
113
+ sandbox_name (str):
114
+
115
+ Raises:
116
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
117
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
118
+
119
+ Returns:
120
+ Response[Union[Any, StopSandbox]]
121
+ """
122
+
123
+ kwargs = _get_kwargs(
124
+ sandbox_name=sandbox_name,
125
+ )
126
+
127
+ response = await client.get_async_httpx_client().request(**kwargs)
128
+
129
+ return _build_response(client=client, response=response)
130
+
131
+
132
+ async def asyncio(
133
+ sandbox_name: str,
134
+ *,
135
+ client: Union[Client],
136
+ ) -> Optional[Union[Any, StopSandbox]]:
137
+ """Stop Sandbox
138
+
139
+ Stops a Sandbox by name.
140
+
141
+ Args:
142
+ sandbox_name (str):
143
+
144
+ Raises:
145
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
146
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
147
+
148
+ Returns:
149
+ Union[Any, StopSandbox]
150
+ """
151
+
152
+ return (
153
+ await asyncio_detailed(
154
+ sandbox_name=sandbox_name,
155
+ client=client,
156
+ )
157
+ ).parsed
@@ -0,0 +1,179 @@
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
+ *,
15
+ body: Sandbox,
16
+ ) -> dict[str, Any]:
17
+ headers: dict[str, Any] = {}
18
+
19
+ _kwargs: dict[str, Any] = {
20
+ "method": "put",
21
+ "url": f"/sandboxes/{sandbox_name}",
22
+ }
23
+
24
+ if type(body) == dict:
25
+ _body = body
26
+ else:
27
+ _body = body.to_dict()
28
+
29
+ _kwargs["json"] = _body
30
+ headers["Content-Type"] = "application/json"
31
+
32
+ _kwargs["headers"] = headers
33
+ return _kwargs
34
+
35
+
36
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Sandbox]:
37
+ if response.status_code == 200:
38
+ response_200 = Sandbox.from_dict(response.json())
39
+
40
+ return response_200
41
+ if client.raise_on_unexpected_status:
42
+ raise errors.UnexpectedStatus(response.status_code, response.content)
43
+ else:
44
+ return None
45
+
46
+
47
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Sandbox]:
48
+ return Response(
49
+ status_code=HTTPStatus(response.status_code),
50
+ content=response.content,
51
+ headers=response.headers,
52
+ parsed=_parse_response(client=client, response=response),
53
+ )
54
+
55
+
56
+ def sync_detailed(
57
+ sandbox_name: str,
58
+ *,
59
+ client: Union[Client],
60
+ body: Sandbox,
61
+ ) -> Response[Sandbox]:
62
+ """Update Sandbox
63
+
64
+ Update a Sandbox by name.
65
+
66
+ Args:
67
+ sandbox_name (str):
68
+ body (Sandbox): Micro VM for running agentic tasks
69
+
70
+ Raises:
71
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
72
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
73
+
74
+ Returns:
75
+ Response[Sandbox]
76
+ """
77
+
78
+ kwargs = _get_kwargs(
79
+ sandbox_name=sandbox_name,
80
+ body=body,
81
+ )
82
+
83
+ response = client.get_httpx_client().request(
84
+ **kwargs,
85
+ )
86
+
87
+ return _build_response(client=client, response=response)
88
+
89
+
90
+ def sync(
91
+ sandbox_name: str,
92
+ *,
93
+ client: Union[Client],
94
+ body: Sandbox,
95
+ ) -> Optional[Sandbox]:
96
+ """Update Sandbox
97
+
98
+ Update a Sandbox by name.
99
+
100
+ Args:
101
+ sandbox_name (str):
102
+ body (Sandbox): Micro VM for running agentic tasks
103
+
104
+ Raises:
105
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
107
+
108
+ Returns:
109
+ Sandbox
110
+ """
111
+
112
+ return sync_detailed(
113
+ sandbox_name=sandbox_name,
114
+ client=client,
115
+ body=body,
116
+ ).parsed
117
+
118
+
119
+ async def asyncio_detailed(
120
+ sandbox_name: str,
121
+ *,
122
+ client: Union[Client],
123
+ body: Sandbox,
124
+ ) -> Response[Sandbox]:
125
+ """Update Sandbox
126
+
127
+ Update a Sandbox by name.
128
+
129
+ Args:
130
+ sandbox_name (str):
131
+ body (Sandbox): Micro VM for running agentic tasks
132
+
133
+ Raises:
134
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
135
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
136
+
137
+ Returns:
138
+ Response[Sandbox]
139
+ """
140
+
141
+ kwargs = _get_kwargs(
142
+ sandbox_name=sandbox_name,
143
+ body=body,
144
+ )
145
+
146
+ response = await client.get_async_httpx_client().request(**kwargs)
147
+
148
+ return _build_response(client=client, response=response)
149
+
150
+
151
+ async def asyncio(
152
+ sandbox_name: str,
153
+ *,
154
+ client: Union[Client],
155
+ body: Sandbox,
156
+ ) -> Optional[Sandbox]:
157
+ """Update Sandbox
158
+
159
+ Update a Sandbox by name.
160
+
161
+ Args:
162
+ sandbox_name (str):
163
+ body (Sandbox): Micro VM for running agentic tasks
164
+
165
+ Raises:
166
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
167
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
168
+
169
+ Returns:
170
+ Sandbox
171
+ """
172
+
173
+ return (
174
+ await asyncio_detailed(
175
+ sandbox_name=sandbox_name,
176
+ client=client,
177
+ body=body,
178
+ )
179
+ ).parsed