blaxel 0.2.31__py3-none-any.whl → 0.2.31rc121__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 (174) hide show
  1. blaxel/__init__.py +3 -3
  2. blaxel/core/agents/__init__.py +6 -13
  3. blaxel/core/authentication/__init__.py +1 -2
  4. blaxel/core/authentication/devicemode.py +1 -9
  5. blaxel/core/authentication/oauth.py +6 -13
  6. blaxel/core/authentication/types.py +0 -1
  7. blaxel/core/cache/cache.py +3 -10
  8. blaxel/core/client/api/agents/list_agent_revisions.py +1 -3
  9. blaxel/core/client/api/compute/delete_sandbox_preview_token.py +2 -6
  10. blaxel/core/client/api/compute/start_sandbox.py +1 -3
  11. blaxel/core/client/api/compute/stop_sandbox.py +1 -3
  12. blaxel/core/client/api/default/list_sandbox_hub_definitions.py +2 -6
  13. blaxel/core/client/api/functions/list_function_revisions.py +1 -3
  14. blaxel/core/client/api/images/cleanup_images.py +1 -3
  15. blaxel/core/client/api/integrations/list_integration_connections.py +2 -6
  16. blaxel/core/client/api/invitations/list_all_pending_invitations.py +1 -3
  17. blaxel/core/client/api/jobs/create_job_execution.py +1 -3
  18. blaxel/core/client/api/jobs/delete_job_execution.py +1 -3
  19. blaxel/core/client/api/jobs/get_job_execution.py +1 -3
  20. blaxel/core/client/api/jobs/list_job_executions.py +2 -6
  21. blaxel/core/client/api/jobs/list_job_revisions.py +1 -3
  22. blaxel/core/client/api/locations/list_locations.py +1 -3
  23. blaxel/core/client/api/models/list_model_revisions.py +1 -3
  24. blaxel/core/client/api/service_accounts/create_workspace_service_account.py +2 -6
  25. blaxel/core/client/api/service_accounts/delete_workspace_service_account.py +2 -6
  26. blaxel/core/client/api/service_accounts/get_workspace_service_accounts.py +1 -3
  27. blaxel/core/client/api/service_accounts/update_workspace_service_account.py +2 -6
  28. blaxel/core/client/api/volume_templates/list_volume_templates.py +1 -3
  29. blaxel/core/client/api/workspaces/accept_workspace_invitation.py +2 -6
  30. blaxel/core/client/api/workspaces/invite_workspace_user.py +2 -6
  31. blaxel/core/client/api/workspaces/update_workspace_user_role.py +2 -6
  32. blaxel/core/client/client.py +1 -3
  33. blaxel/core/client/models/agent.py +4 -11
  34. blaxel/core/client/models/agent_spec.py +5 -18
  35. blaxel/core/client/models/billable_time_metric.py +1 -0
  36. blaxel/core/client/models/configuration.py +1 -0
  37. blaxel/core/client/models/core_spec.py +3 -10
  38. blaxel/core/client/models/core_spec_configurations.py +1 -0
  39. blaxel/core/client/models/create_job_execution_request.py +1 -0
  40. blaxel/core/client/models/create_job_execution_response.py +1 -0
  41. blaxel/core/client/models/custom_domain.py +2 -5
  42. blaxel/core/client/models/custom_domain_metadata.py +1 -0
  43. blaxel/core/client/models/custom_domain_spec.py +2 -5
  44. blaxel/core/client/models/delete_volume_template_version_response_200.py +2 -5
  45. blaxel/core/client/models/entrypoint.py +1 -0
  46. blaxel/core/client/models/form.py +2 -5
  47. blaxel/core/client/models/function.py +4 -11
  48. blaxel/core/client/models/function_spec.py +4 -13
  49. blaxel/core/client/models/image.py +2 -5
  50. blaxel/core/client/models/image_spec.py +1 -0
  51. blaxel/core/client/models/integration.py +3 -10
  52. blaxel/core/client/models/integration_connection.py +2 -5
  53. blaxel/core/client/models/integration_connection_spec.py +1 -0
  54. blaxel/core/client/models/integration_endpoint.py +2 -5
  55. blaxel/core/client/models/integration_endpoints.py +2 -0
  56. blaxel/core/client/models/job.py +4 -11
  57. blaxel/core/client/models/job_execution.py +2 -5
  58. blaxel/core/client/models/job_execution_spec.py +1 -0
  59. blaxel/core/client/models/job_execution_task.py +2 -5
  60. blaxel/core/client/models/job_metrics.py +2 -5
  61. blaxel/core/client/models/job_spec.py +4 -13
  62. blaxel/core/client/models/jobs_network_chart.py +1 -0
  63. blaxel/core/client/models/jobs_success_failed_chart.py +3 -10
  64. blaxel/core/client/models/latency_metric.py +2 -5
  65. blaxel/core/client/models/location_response.py +1 -0
  66. blaxel/core/client/models/mcp_definition.py +2 -5
  67. blaxel/core/client/models/metadata.py +1 -0
  68. blaxel/core/client/models/metrics.py +4 -11
  69. blaxel/core/client/models/model.py +4 -11
  70. blaxel/core/client/models/model_spec.py +3 -10
  71. blaxel/core/client/models/pending_invitation_accept.py +2 -5
  72. blaxel/core/client/models/pending_invitation_render.py +3 -10
  73. blaxel/core/client/models/policy.py +2 -5
  74. blaxel/core/client/models/policy_spec.py +4 -11
  75. blaxel/core/client/models/preview.py +2 -5
  76. blaxel/core/client/models/preview_spec.py +1 -0
  77. blaxel/core/client/models/preview_token.py +2 -5
  78. blaxel/core/client/models/public_ips.py +1 -0
  79. blaxel/core/client/models/request_duration_over_time_metrics.py +1 -0
  80. blaxel/core/client/models/request_total_by_origin_metric.py +7 -16
  81. blaxel/core/client/models/request_total_metric.py +3 -8
  82. blaxel/core/client/models/resource_metrics.py +17 -58
  83. blaxel/core/client/models/runtime.py +1 -0
  84. blaxel/core/client/models/sandbox.py +4 -11
  85. blaxel/core/client/models/sandbox_definition.py +1 -0
  86. blaxel/core/client/models/sandbox_lifecycle.py +1 -0
  87. blaxel/core/client/models/sandbox_spec.py +6 -21
  88. blaxel/core/client/models/serverless_config.py +1 -0
  89. blaxel/core/client/models/start_sandbox.py +2 -5
  90. blaxel/core/client/models/stop_sandbox.py +2 -5
  91. blaxel/core/client/models/store_agent.py +1 -0
  92. blaxel/core/client/models/store_configuration.py +1 -0
  93. blaxel/core/client/models/template.py +1 -0
  94. blaxel/core/client/models/time_to_first_token_over_time_metrics.py +2 -3
  95. blaxel/core/client/models/token_rate_metrics.py +1 -0
  96. blaxel/core/client/models/trigger.py +1 -0
  97. blaxel/core/client/models/trigger_configuration.py +1 -0
  98. blaxel/core/client/models/volume.py +4 -11
  99. blaxel/core/client/models/volume_template.py +2 -5
  100. blaxel/core/client/models/workspace.py +2 -5
  101. blaxel/core/client/response_interceptor.py +1 -3
  102. blaxel/core/common/autoload.py +11 -9
  103. blaxel/core/common/env.py +8 -10
  104. blaxel/core/common/settings.py +2 -4
  105. blaxel/core/common/webhook.py +1 -0
  106. blaxel/core/jobs/__init__.py +3 -13
  107. blaxel/core/mcp/client.py +2 -8
  108. blaxel/core/mcp/server.py +2 -8
  109. blaxel/core/models/__init__.py +5 -6
  110. blaxel/core/sandbox/__init__.py +1 -1
  111. blaxel/core/sandbox/client/api/codegen/get_codegen_reranking_path.py +2 -6
  112. blaxel/core/sandbox/client/api/fastapply/put_codegen_fastapply_path.py +2 -6
  113. blaxel/core/sandbox/client/api/filesystem/delete_filesystem_multipart_upload_id_abort.py +2 -6
  114. blaxel/core/sandbox/client/api/filesystem/delete_filesystem_path.py +2 -6
  115. blaxel/core/sandbox/client/api/filesystem/delete_filesystem_tree_path.py +2 -6
  116. blaxel/core/sandbox/client/api/filesystem/get_filesystem_content_search_path.py +1 -3
  117. blaxel/core/sandbox/client/api/filesystem/get_filesystem_find_path.py +2 -6
  118. blaxel/core/sandbox/client/api/filesystem/get_filesystem_search_path.py +2 -6
  119. blaxel/core/sandbox/client/api/filesystem/get_watch_filesystem_path.py +2 -6
  120. blaxel/core/sandbox/client/api/filesystem/post_filesystem_multipart_upload_id_complete.py +2 -6
  121. blaxel/core/sandbox/client/api/filesystem/put_filesystem_path.py +2 -6
  122. blaxel/core/sandbox/client/api/process/delete_process_identifier.py +2 -6
  123. blaxel/core/sandbox/client/api/process/delete_process_identifier_kill.py +2 -6
  124. blaxel/core/sandbox/client/api/process/get_process.py +1 -3
  125. blaxel/core/sandbox/client/api/process/get_process_identifier.py +2 -6
  126. blaxel/core/sandbox/client/api/process/get_process_identifier_logs.py +2 -6
  127. blaxel/core/sandbox/client/api/process/get_process_identifier_logs_stream.py +2 -6
  128. blaxel/core/sandbox/client/api/process/post_process.py +2 -6
  129. blaxel/core/sandbox/client/client.py +1 -3
  130. blaxel/core/sandbox/client/models/filesystem_multipart_upload_parts.py +1 -3
  131. blaxel/core/sandbox/default/__init__.py +1 -0
  132. blaxel/core/sandbox/default/action.py +3 -3
  133. blaxel/core/sandbox/default/codegen.py +4 -2
  134. blaxel/core/sandbox/default/filesystem.py +82 -38
  135. blaxel/core/sandbox/default/interpreter.py +10 -17
  136. blaxel/core/sandbox/default/preview.py +2 -6
  137. blaxel/core/sandbox/default/process.py +7 -25
  138. blaxel/core/sandbox/default/sandbox.py +2 -7
  139. blaxel/core/sandbox/sync/__init__.py +2 -0
  140. blaxel/core/sandbox/sync/action.py +3 -2
  141. blaxel/core/sandbox/sync/codegen.py +5 -1
  142. blaxel/core/sandbox/sync/filesystem.py +6 -17
  143. blaxel/core/sandbox/sync/interpreter.py +6 -10
  144. blaxel/core/sandbox/sync/network.py +2 -0
  145. blaxel/core/sandbox/sync/preview.py +9 -21
  146. blaxel/core/sandbox/sync/process.py +8 -32
  147. blaxel/core/sandbox/sync/sandbox.py +6 -13
  148. blaxel/core/sandbox/sync/session.py +4 -6
  149. blaxel/core/sandbox/types.py +1 -2
  150. blaxel/core/tools/__init__.py +6 -30
  151. blaxel/core/tools/common.py +1 -1
  152. blaxel/core/tools/types.py +1 -2
  153. blaxel/crewai/model.py +5 -20
  154. blaxel/googleadk/__init__.py +1 -1
  155. blaxel/googleadk/tools.py +5 -3
  156. blaxel/langgraph/custom/gemini.py +133 -126
  157. blaxel/langgraph/model.py +50 -54
  158. blaxel/langgraph/tools.py +3 -9
  159. blaxel/llamaindex/custom/cohere.py +16 -25
  160. blaxel/llamaindex/model.py +57 -44
  161. blaxel/llamaindex/tools.py +3 -2
  162. blaxel/pydantic/custom/gemini.py +3 -3
  163. blaxel/pydantic/tools.py +4 -2
  164. blaxel/telemetry/exporters.py +3 -10
  165. blaxel/telemetry/instrumentation/blaxel_langgraph.py +2 -4
  166. blaxel/telemetry/instrumentation/blaxel_langgraph_gemini.py +5 -22
  167. blaxel/telemetry/instrumentation/utils.py +3 -3
  168. blaxel/telemetry/log/log.py +3 -2
  169. blaxel/telemetry/log/logger.py +15 -21
  170. blaxel/telemetry/span.py +6 -10
  171. {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/METADATA +2 -2
  172. {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/RECORD +174 -174
  173. {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/WHEEL +0 -0
  174. {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/licenses/LICENSE +0 -0
@@ -49,6 +49,7 @@ class SandboxSpec:
49
49
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
50
50
 
51
51
  def to_dict(self) -> dict[str, Any]:
52
+
52
53
  configurations: Union[Unset, dict[str, Any]] = UNSET
53
54
  if (
54
55
  self.configurations
@@ -80,21 +81,13 @@ class SandboxSpec:
80
81
  policies = self.policies
81
82
 
82
83
  revision: Union[Unset, dict[str, Any]] = UNSET
83
- if (
84
- self.revision
85
- and not isinstance(self.revision, Unset)
86
- and not isinstance(self.revision, dict)
87
- ):
84
+ if self.revision and not isinstance(self.revision, Unset) and not isinstance(self.revision, dict):
88
85
  revision = self.revision.to_dict()
89
86
  elif self.revision and isinstance(self.revision, dict):
90
87
  revision = self.revision
91
88
 
92
89
  runtime: Union[Unset, dict[str, Any]] = UNSET
93
- if (
94
- self.runtime
95
- and not isinstance(self.runtime, Unset)
96
- and not isinstance(self.runtime, dict)
97
- ):
90
+ if self.runtime and not isinstance(self.runtime, Unset) and not isinstance(self.runtime, dict):
98
91
  runtime = self.runtime.to_dict()
99
92
  elif self.runtime and isinstance(self.runtime, dict):
100
93
  runtime = self.runtime
@@ -102,11 +95,7 @@ class SandboxSpec:
102
95
  sandbox = self.sandbox
103
96
 
104
97
  lifecycle: Union[Unset, dict[str, Any]] = UNSET
105
- if (
106
- self.lifecycle
107
- and not isinstance(self.lifecycle, Unset)
108
- and not isinstance(self.lifecycle, dict)
109
- ):
98
+ if self.lifecycle and not isinstance(self.lifecycle, Unset) and not isinstance(self.lifecycle, dict):
110
99
  lifecycle = self.lifecycle.to_dict()
111
100
  elif self.lifecycle and isinstance(self.lifecycle, dict):
112
101
  lifecycle = self.lifecycle
@@ -118,13 +107,9 @@ class SandboxSpec:
118
107
  volumes = []
119
108
  for componentsschemas_volume_attachments_item_data in self.volumes:
120
109
  if type(componentsschemas_volume_attachments_item_data) is dict:
121
- componentsschemas_volume_attachments_item = (
122
- componentsschemas_volume_attachments_item_data
123
- )
110
+ componentsschemas_volume_attachments_item = componentsschemas_volume_attachments_item_data
124
111
  else:
125
- componentsschemas_volume_attachments_item = (
126
- componentsschemas_volume_attachments_item_data.to_dict()
127
- )
112
+ componentsschemas_volume_attachments_item = componentsschemas_volume_attachments_item_data.to_dict()
128
113
  volumes.append(componentsschemas_volume_attachments_item)
129
114
 
130
115
  field_dict: dict[str, Any] = {}
@@ -33,6 +33,7 @@ class ServerlessConfig:
33
33
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
34
34
 
35
35
  def to_dict(self) -> dict[str, Any]:
36
+
36
37
  configuration: Union[Unset, dict[str, Any]] = UNSET
37
38
  if (
38
39
  self.configuration
@@ -28,14 +28,11 @@ class StartSandbox:
28
28
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
29
 
30
30
  def to_dict(self) -> dict[str, Any]:
31
+
31
32
  message = self.message
32
33
 
33
34
  metadata: Union[Unset, dict[str, Any]] = UNSET
34
- if (
35
- self.metadata
36
- and not isinstance(self.metadata, Unset)
37
- and not isinstance(self.metadata, dict)
38
- ):
35
+ if self.metadata and not isinstance(self.metadata, Unset) and not isinstance(self.metadata, dict):
39
36
  metadata = self.metadata.to_dict()
40
37
  elif self.metadata and isinstance(self.metadata, dict):
41
38
  metadata = self.metadata
@@ -28,14 +28,11 @@ class StopSandbox:
28
28
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
29
 
30
30
  def to_dict(self) -> dict[str, Any]:
31
+
31
32
  message = self.message
32
33
 
33
34
  metadata: Union[Unset, dict[str, Any]] = UNSET
34
- if (
35
- self.metadata
36
- and not isinstance(self.metadata, Unset)
37
- and not isinstance(self.metadata, dict)
38
- ):
35
+ if self.metadata and not isinstance(self.metadata, Unset) and not isinstance(self.metadata, dict):
39
36
  metadata = self.metadata.to_dict()
40
37
  elif self.metadata and isinstance(self.metadata, dict):
41
38
  metadata = self.metadata
@@ -45,6 +45,7 @@ class StoreAgent:
45
45
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
46
46
 
47
47
  def to_dict(self) -> dict[str, Any]:
48
+
48
49
  created_at = self.created_at
49
50
 
50
51
  updated_at = self.updated_at
@@ -40,6 +40,7 @@ class StoreConfiguration:
40
40
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
41
41
 
42
42
  def to_dict(self) -> dict[str, Any]:
43
+
43
44
  available_models: Union[Unset, list[str]] = UNSET
44
45
  if not isinstance(self.available_models, Unset):
45
46
  available_models = self.available_models
@@ -46,6 +46,7 @@ class Template:
46
46
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
47
47
 
48
48
  def to_dict(self) -> dict[str, Any]:
49
+
49
50
  default_branch = self.default_branch
50
51
 
51
52
  description = self.description
@@ -25,6 +25,7 @@ class TimeToFirstTokenOverTimeMetrics:
25
25
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
26
26
 
27
27
  def to_dict(self) -> dict[str, Any]:
28
+
28
29
  time_to_first_token_over_time: Union[Unset, list[dict[str, Any]]] = UNSET
29
30
  if not isinstance(self.time_to_first_token_over_time, Unset):
30
31
  time_to_first_token_over_time = []
@@ -32,9 +33,7 @@ class TimeToFirstTokenOverTimeMetrics:
32
33
  if type(time_to_first_token_over_time_item_data) is dict:
33
34
  time_to_first_token_over_time_item = time_to_first_token_over_time_item_data
34
35
  else:
35
- time_to_first_token_over_time_item = (
36
- time_to_first_token_over_time_item_data.to_dict()
37
- )
36
+ time_to_first_token_over_time_item = time_to_first_token_over_time_item_data.to_dict()
38
37
  time_to_first_token_over_time.append(time_to_first_token_over_time_item)
39
38
 
40
39
  field_dict: dict[str, Any] = {}
@@ -28,6 +28,7 @@ class TokenRateMetrics:
28
28
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
29
 
30
30
  def to_dict(self) -> dict[str, Any]:
31
+
31
32
  token_rate: Union[Unset, list[dict[str, Any]]] = UNSET
32
33
  if not isinstance(self.token_rate, Unset):
33
34
  token_rate = []
@@ -30,6 +30,7 @@ class Trigger:
30
30
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
31
 
32
32
  def to_dict(self) -> dict[str, Any]:
33
+
33
34
  configuration: Union[Unset, dict[str, Any]] = UNSET
34
35
  if (
35
36
  self.configuration
@@ -38,6 +38,7 @@ class TriggerConfiguration:
38
38
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
39
39
 
40
40
  def to_dict(self) -> dict[str, Any]:
41
+
41
42
  authentication_type = self.authentication_type
42
43
 
43
44
  callback_secret = self.callback_secret
@@ -37,6 +37,7 @@ class Volume:
37
37
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
38
38
 
39
39
  def to_dict(self) -> dict[str, Any]:
40
+
40
41
  events: Union[Unset, list[dict[str, Any]]] = UNSET
41
42
  if not isinstance(self.events, Unset):
42
43
  events = []
@@ -44,17 +45,11 @@ class Volume:
44
45
  if type(componentsschemas_core_events_item_data) is dict:
45
46
  componentsschemas_core_events_item = componentsschemas_core_events_item_data
46
47
  else:
47
- componentsschemas_core_events_item = (
48
- componentsschemas_core_events_item_data.to_dict()
49
- )
48
+ componentsschemas_core_events_item = componentsschemas_core_events_item_data.to_dict()
50
49
  events.append(componentsschemas_core_events_item)
51
50
 
52
51
  metadata: Union[Unset, dict[str, Any]] = UNSET
53
- if (
54
- self.metadata
55
- and not isinstance(self.metadata, Unset)
56
- and not isinstance(self.metadata, dict)
57
- ):
52
+ if self.metadata and not isinstance(self.metadata, Unset) and not isinstance(self.metadata, dict):
58
53
  metadata = self.metadata.to_dict()
59
54
  elif self.metadata and isinstance(self.metadata, dict):
60
55
  metadata = self.metadata
@@ -106,9 +101,7 @@ class Volume:
106
101
  events = []
107
102
  _events = d.pop("events", UNSET)
108
103
  for componentsschemas_core_events_item_data in _events or []:
109
- componentsschemas_core_events_item = CoreEvent.from_dict(
110
- componentsschemas_core_events_item_data
111
- )
104
+ componentsschemas_core_events_item = CoreEvent.from_dict(componentsschemas_core_events_item_data)
112
105
 
113
106
  events.append(componentsschemas_core_events_item)
114
107
 
@@ -33,12 +33,9 @@ class VolumeTemplate:
33
33
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
34
34
 
35
35
  def to_dict(self) -> dict[str, Any]:
36
+
36
37
  metadata: Union[Unset, dict[str, Any]] = UNSET
37
- if (
38
- self.metadata
39
- and not isinstance(self.metadata, Unset)
40
- and not isinstance(self.metadata, dict)
41
- ):
38
+ if self.metadata and not isinstance(self.metadata, Unset) and not isinstance(self.metadata, dict):
42
39
  metadata = self.metadata.to_dict()
43
40
  elif self.metadata and isinstance(self.metadata, dict):
44
41
  metadata = self.metadata
@@ -50,6 +50,7 @@ class Workspace:
50
50
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
51
51
 
52
52
  def to_dict(self) -> dict[str, Any]:
53
+
53
54
  created_at = self.created_at
54
55
 
55
56
  updated_at = self.updated_at
@@ -75,11 +76,7 @@ class Workspace:
75
76
  region = self.region
76
77
 
77
78
  runtime: Union[Unset, dict[str, Any]] = UNSET
78
- if (
79
- self.runtime
80
- and not isinstance(self.runtime, Unset)
81
- and not isinstance(self.runtime, dict)
82
- ):
79
+ if self.runtime and not isinstance(self.runtime, Unset) and not isinstance(self.runtime, dict):
83
80
  runtime = self.runtime.to_dict()
84
81
  elif self.runtime and isinstance(self.runtime, dict):
85
82
  runtime = self.runtime
@@ -50,9 +50,7 @@ def authentication_error_interceptor_sync(response: httpx.Response) -> None:
50
50
  logger.error("Error processing authentication error response: %s", error)
51
51
 
52
52
 
53
- async def authentication_error_interceptor_async(
54
- response: httpx.Response,
55
- ) -> None:
53
+ async def authentication_error_interceptor_async(response: httpx.Response) -> None:
56
54
  """
57
55
  Intercepts HTTP responses and adds authentication documentation
58
56
  to 401/403 error responses (asynchronous version)
@@ -22,16 +22,18 @@ _captured_exceptions: set = set() # Track already captured exceptions to avoid
22
22
 
23
23
  # Exceptions that are part of normal control flow and should not be captured
24
24
  _IGNORED_EXCEPTIONS = (
25
- StopIteration, # Iterator exhaustion
25
+ StopIteration, # Iterator exhaustion
26
26
  StopAsyncIteration, # Async iterator exhaustion
27
- GeneratorExit, # Generator cleanup
28
- KeyboardInterrupt, # User interrupt (Ctrl+C)
29
- SystemExit, # Program exit
30
- CancelledError, # Async task cancellation
27
+ GeneratorExit, # Generator cleanup
28
+ KeyboardInterrupt, # User interrupt (Ctrl+C)
29
+ SystemExit, # Program exit
30
+ CancelledError, # Async task cancellation
31
31
  )
32
32
 
33
33
  # Optional dependencies that may not be installed - import errors for these are expected
34
- _OPTIONAL_DEPENDENCIES = ("opentelemetry",)
34
+ _OPTIONAL_DEPENDENCIES = (
35
+ 'opentelemetry',
36
+ )
35
37
 
36
38
 
37
39
  def _get_exception_key(exc_type, exc_value, frame) -> str:
@@ -41,7 +43,7 @@ def _get_exception_key(exc_type, exc_value, frame) -> str:
41
43
  exc_name = exc_type.__name__ if exc_type else "Unknown"
42
44
  exc_msg = str(exc_value) if exc_value else ""
43
45
  # Get the original traceback location (where exception was first raised)
44
- tb = getattr(exc_value, "__traceback__", None)
46
+ tb = getattr(exc_value, '__traceback__', None)
45
47
  if tb:
46
48
  # Walk to the deepest frame (origin of exception)
47
49
  while tb.tb_next:
@@ -63,7 +65,7 @@ def _is_optional_dependency_error(exc_type, exc_value) -> bool:
63
65
 
64
66
  def _trace_blaxel_exceptions(frame, event, arg):
65
67
  """Trace function that captures exceptions from blaxel SDK code."""
66
- if event == "exception":
68
+ if event == 'exception':
67
69
  exc_type, exc_value, exc_tb = arg
68
70
 
69
71
  # Skip control flow exceptions (not actual errors)
@@ -77,7 +79,7 @@ def _trace_blaxel_exceptions(frame, event, arg):
77
79
  filename = frame.f_code.co_filename
78
80
 
79
81
  # Only capture if it's from blaxel in site-packages
80
- if "site-packages/blaxel" in filename:
82
+ if 'site-packages/blaxel' in filename:
81
83
  # Avoid capturing the same exception multiple times using a content-based key
82
84
  exc_key = _get_exception_key(exc_type, exc_value, frame)
83
85
  if exc_key not in _captured_exceptions:
blaxel/core/common/env.py CHANGED
@@ -19,31 +19,29 @@ class EnvConfig(BaseModel):
19
19
  def __getitem__(self, name: str) -> str | None:
20
20
  return self.__getattr__(name)
21
21
 
22
-
23
22
  def load_env() -> EnvConfig:
24
23
  env_config = EnvConfig()
25
24
 
26
25
  # Load config from blaxel.toml
27
26
  try:
28
- with open("blaxel.toml", "rb") as f:
27
+ with open('blaxel.toml', 'rb') as f:
29
28
  config_infos = tomli.load(f)
30
- if "env" in config_infos:
31
- env_config.config_env.update(config_infos["env"])
29
+ if 'env' in config_infos:
30
+ env_config.config_env.update(config_infos['env'])
32
31
  except Exception:
33
32
  pass
34
33
 
35
34
  # Load secrets from .env
36
35
  try:
37
- with open(".env") as f:
36
+ with open('.env') as f:
38
37
  for line in f:
39
38
  line = line.strip()
40
- if line and not line.startswith("#"):
41
- key, value = line.split("=", 1)
42
- env_config.secret_env[key] = value.replace('"', "")
39
+ if line and not line.startswith('#'):
40
+ key, value = line.split('=', 1)
41
+ env_config.secret_env[key] = value.replace('"', '')
43
42
  except Exception:
44
43
  pass
45
44
 
46
45
  return env_config
47
46
 
48
-
49
- env = load_env()
47
+ env = load_env()
@@ -69,25 +69,23 @@ class Settings:
69
69
  return "https://run.blaxel.ai"
70
70
  return "https://run.blaxel.dev"
71
71
 
72
+
72
73
  @property
73
74
  def sentry_dsn(self) -> str:
74
75
  """Get the Sentry DSN (injected at build time)."""
75
76
  import blaxel
76
-
77
77
  return blaxel.__sentry_dsn__
78
78
 
79
79
  @property
80
80
  def version(self) -> str:
81
81
  """Get the package version (injected at build time)."""
82
82
  import blaxel
83
-
84
83
  return blaxel.__version__ or "unknown"
85
84
 
86
85
  @property
87
86
  def commit(self) -> str:
88
87
  """Get the commit hash (injected at build time)."""
89
88
  import blaxel
90
-
91
89
  return blaxel.__commit__ or "unknown"
92
90
 
93
91
  @property
@@ -98,6 +96,7 @@ class Settings:
98
96
  headers["User-Agent"] = f"blaxel/sdk/python/{self.version} ({os_arch}) blaxel/{self.commit}"
99
97
  return headers
100
98
 
99
+
101
100
  @property
102
101
  def name(self) -> str:
103
102
  """Get the name."""
@@ -166,5 +165,4 @@ class Settings:
166
165
 
167
166
  return True
168
167
 
169
-
170
168
  settings = Settings()
@@ -184,3 +184,4 @@ __all__ = [
184
184
  "AsyncSidecarCallback",
185
185
  "RequestLike",
186
186
  ]
187
+
@@ -14,9 +14,7 @@ from ..client.api.jobs import (
14
14
  get_job_execution,
15
15
  list_job_executions,
16
16
  )
17
- from ..client.models.create_job_execution_request import (
18
- CreateJobExecutionRequest,
19
- )
17
+ from ..client.models.create_job_execution_request import CreateJobExecutionRequest
20
18
  from ..client.models.job_execution import JobExecution
21
19
  from ..common.internal import get_forced_url, get_global_unique_hash
22
20
  from ..common.settings import settings
@@ -107,11 +105,7 @@ class BlJob:
107
105
  body = {"tasks": input_data}
108
106
 
109
107
  # Merge settings headers with provided headers
110
- merged_headers = {
111
- **settings.headers,
112
- "Content-Type": "application/json",
113
- **headers,
114
- }
108
+ merged_headers = {**settings.headers, "Content-Type": "application/json", **headers}
115
109
 
116
110
  return client.get_httpx_client().post(
117
111
  url + "/executions",
@@ -125,11 +119,7 @@ class BlJob:
125
119
  body = {"tasks": input_data}
126
120
 
127
121
  # Merge settings headers with provided headers
128
- merged_headers = {
129
- **settings.headers,
130
- "Content-Type": "application/json",
131
- **headers,
132
- }
122
+ merged_headers = {**settings.headers, "Content-Type": "application/json", **headers}
133
123
 
134
124
  return await client.get_async_httpx_client().post(
135
125
  url + "/executions",
blaxel/core/mcp/client.py CHANGED
@@ -6,10 +6,7 @@ from urllib.parse import urljoin, urlparse
6
6
  import anyio
7
7
  import mcp.types as types
8
8
  from anyio.abc import TaskStatus
9
- from anyio.streams.memory import (
10
- MemoryObjectReceiveStream,
11
- MemoryObjectSendStream,
12
- )
9
+ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
13
10
  from mcp.shared.message import SessionMessage
14
11
  from websockets.asyncio.client import ClientConnection
15
12
  from websockets.asyncio.client import connect as ws_connect
@@ -50,10 +47,7 @@ async def websocket_client(
50
47
  logger.debug(f"Connecting to WebSocket endpoint: {remove_request_params(ws_url)}")
51
48
 
52
49
  # Use different parameters based on websockets version
53
- connection_kwargs = {
54
- "additional_headers": headers,
55
- "open_timeout": timeout,
56
- }
50
+ connection_kwargs = {"additional_headers": headers, "open_timeout": timeout}
57
51
 
58
52
  async with ws_connect(ws_url, **connection_kwargs) as websocket:
59
53
  logger.debug("WebSocket connection established")
blaxel/core/mcp/server.py CHANGED
@@ -6,10 +6,7 @@ from typing import Literal
6
6
 
7
7
  import anyio
8
8
  import mcp.types as types
9
- from anyio.streams.memory import (
10
- MemoryObjectReceiveStream,
11
- MemoryObjectSendStream,
12
- )
9
+ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
13
10
  from mcp.server.fastmcp import FastMCP as FastMCPBase
14
11
  from mcp.shared.message import SessionMessage
15
12
  from websockets.asyncio.server import ServerConnection, serve
@@ -137,10 +134,7 @@ class FastMCP(FastMCPBase):
137
134
  anyio.run(self.run_sse_async)
138
135
 
139
136
  async def run_ws_async(self) -> None:
140
- async with BlaxelMcpServerTransport().websocket_server() as (
141
- read_stream,
142
- write_stream,
143
- ):
137
+ async with BlaxelMcpServerTransport().websocket_server() as (read_stream, write_stream):
144
138
  await self._mcp_server.run(
145
139
  read_stream,
146
140
  write_stream,
@@ -1,3 +1,4 @@
1
+
1
2
  from ..cache import find_from_cache
2
3
  from ..client import client
3
4
  from ..client.api.models import get_model
@@ -22,21 +23,21 @@ class BLModel:
22
23
  model_data = await self._get_model_metadata()
23
24
  if not model_data:
24
25
  raise Exception(f"Model {self.model_name} not found")
25
- runtime = model_data.spec and model_data.spec.runtime
26
+ runtime = (model_data.spec and model_data.spec.runtime)
26
27
  if not runtime:
27
28
  raise Exception(f"Model {self.model_name} has no runtime")
28
29
 
29
- type = runtime.type_ or "openai"
30
+ type = runtime.type_ or 'openai'
30
31
  model = runtime.model
31
32
  self.models[self.model_name] = {
32
33
  "url": url,
33
34
  "type": type,
34
- "model": model,
35
+ "model": model
35
36
  }
36
37
  return url, type, model
37
38
 
38
39
  async def _get_model_metadata(self) -> Model | None:
39
- cache_data = await find_from_cache("Model", self.model_name)
40
+ cache_data = await find_from_cache('Model', self.model_name)
40
41
  if cache_data:
41
42
  return Model.from_dict(cache_data)
42
43
 
@@ -45,9 +46,7 @@ class BLModel:
45
46
  except Exception:
46
47
  return None
47
48
 
48
-
49
49
  def bl_model(model_name, **kwargs):
50
50
  return BLModel(model_name, **kwargs)
51
51
 
52
-
53
52
  __all__ = ["bl_model"]
@@ -59,4 +59,4 @@ __all__ = [
59
59
  "SyncSandboxProcess",
60
60
  "SyncCodeInterpreter",
61
61
  "CodeInterpreter",
62
- ]
62
+ ]
@@ -39,9 +39,7 @@ def _get_kwargs(
39
39
  return _kwargs
40
40
 
41
41
 
42
- def _parse_response(
43
- *, client: Client, response: httpx.Response
44
- ) -> Union[ErrorResponse, RerankingResponse] | None:
42
+ def _parse_response(*, client: Client, response: httpx.Response) -> Union[ErrorResponse, RerankingResponse] | None:
45
43
  if response.status_code == 200:
46
44
  response_200 = RerankingResponse.from_dict(response.json())
47
45
 
@@ -64,9 +62,7 @@ def _parse_response(
64
62
  return None
65
63
 
66
64
 
67
- def _build_response(
68
- *, client: Client, response: httpx.Response
69
- ) -> Response[Union[ErrorResponse, RerankingResponse]]:
65
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, RerankingResponse]]:
70
66
  return Response(
71
67
  status_code=HTTPStatus(response.status_code),
72
68
  content=response.content,
@@ -35,9 +35,7 @@ def _get_kwargs(
35
35
  return _kwargs
36
36
 
37
37
 
38
- def _parse_response(
39
- *, client: Client, response: httpx.Response
40
- ) -> Union[ApplyEditResponse, ErrorResponse] | None:
38
+ def _parse_response(*, client: Client, response: httpx.Response) -> Union[ApplyEditResponse, ErrorResponse] | None:
41
39
  if response.status_code == 200:
42
40
  response_200 = ApplyEditResponse.from_dict(response.json())
43
41
 
@@ -60,9 +58,7 @@ def _parse_response(
60
58
  return None
61
59
 
62
60
 
63
- def _build_response(
64
- *, client: Client, response: httpx.Response
65
- ) -> Response[Union[ApplyEditResponse, ErrorResponse]]:
61
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ApplyEditResponse, ErrorResponse]]:
66
62
  return Response(
67
63
  status_code=HTTPStatus(response.status_code),
68
64
  content=response.content,
@@ -21,9 +21,7 @@ def _get_kwargs(
21
21
  return _kwargs
22
22
 
23
23
 
24
- def _parse_response(
25
- *, client: Client, response: httpx.Response
26
- ) -> Union[ErrorResponse, SuccessResponse] | None:
24
+ def _parse_response(*, client: Client, response: httpx.Response) -> Union[ErrorResponse, SuccessResponse] | None:
27
25
  if response.status_code == 200:
28
26
  response_200 = SuccessResponse.from_dict(response.json())
29
27
 
@@ -46,9 +44,7 @@ def _parse_response(
46
44
  return None
47
45
 
48
46
 
49
- def _build_response(
50
- *, client: Client, response: httpx.Response
51
- ) -> Response[Union[ErrorResponse, SuccessResponse]]:
47
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, SuccessResponse]]:
52
48
  return Response(
53
49
  status_code=HTTPStatus(response.status_code),
54
50
  content=response.content,
@@ -30,9 +30,7 @@ def _get_kwargs(
30
30
  return _kwargs
31
31
 
32
32
 
33
- def _parse_response(
34
- *, client: Client, response: httpx.Response
35
- ) -> Union[ErrorResponse, SuccessResponse] | None:
33
+ def _parse_response(*, client: Client, response: httpx.Response) -> Union[ErrorResponse, SuccessResponse] | None:
36
34
  if response.status_code == 200:
37
35
  response_200 = SuccessResponse.from_dict(response.json())
38
36
 
@@ -55,9 +53,7 @@ def _parse_response(
55
53
  return None
56
54
 
57
55
 
58
- def _build_response(
59
- *, client: Client, response: httpx.Response
60
- ) -> Response[Union[ErrorResponse, SuccessResponse]]:
56
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, SuccessResponse]]:
61
57
  return Response(
62
58
  status_code=HTTPStatus(response.status_code),
63
59
  content=response.content,
@@ -30,9 +30,7 @@ def _get_kwargs(
30
30
  return _kwargs
31
31
 
32
32
 
33
- def _parse_response(
34
- *, client: Client, response: httpx.Response
35
- ) -> Union[ErrorResponse, SuccessResponse] | None:
33
+ def _parse_response(*, client: Client, response: httpx.Response) -> Union[ErrorResponse, SuccessResponse] | None:
36
34
  if response.status_code == 200:
37
35
  response_200 = SuccessResponse.from_dict(response.json())
38
36
 
@@ -55,9 +53,7 @@ def _parse_response(
55
53
  return None
56
54
 
57
55
 
58
- def _build_response(
59
- *, client: Client, response: httpx.Response
60
- ) -> Response[Union[ErrorResponse, SuccessResponse]]:
56
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, SuccessResponse]]:
61
57
  return Response(
62
58
  status_code=HTTPStatus(response.status_code),
63
59
  content=response.content,