beamlit 0.0.20rc5__py3-none-any.whl → 0.0.20rc6__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. beamlit/agents/__init__.py +4 -0
  2. beamlit/agents/chat.py +87 -0
  3. beamlit/agents/decorator.py +129 -0
  4. beamlit/api/agents/delete_agent_history.py +6 -2
  5. beamlit/api/agents/get_agent_deployment_logs.py +11 -11
  6. beamlit/api/agents/get_agent_history.py +6 -2
  7. beamlit/api/agents/list_agent_deployment_history.py +11 -11
  8. beamlit/api/agents/list_agent_deployments.py +11 -11
  9. beamlit/api/agents/list_agents.py +11 -11
  10. beamlit/api/agents/put_agent_history.py +6 -2
  11. beamlit/api/environments/list_environments.py +11 -11
  12. beamlit/api/functions/get_function_deployment_logs.py +11 -11
  13. beamlit/api/functions/list_function_deployments.py +11 -11
  14. beamlit/api/functions/list_functions.py +11 -11
  15. beamlit/api/history/get_agents_history.py +11 -11
  16. beamlit/api/history/list_agents_history.py +11 -11
  17. beamlit/api/integrations/list_integration_connections.py +11 -11
  18. beamlit/api/invitations/list_all_pending_invitations.py +11 -11
  19. beamlit/api/locations/list_locations.py +11 -11
  20. beamlit/api/model_providers/list_model_providers.py +11 -11
  21. beamlit/api/models/get_model_deployment_logs.py +11 -11
  22. beamlit/api/models/list_model_deployments.py +11 -11
  23. beamlit/api/models/list_models.py +11 -11
  24. beamlit/api/policies/list_policies.py +11 -11
  25. beamlit/api/service_accounts/get_workspace_service_accounts.py +11 -11
  26. beamlit/api/service_accounts/list_api_keys_for_service_account.py +11 -11
  27. beamlit/api/store/list_store_agents.py +11 -11
  28. beamlit/api/store/list_store_functions.py +11 -11
  29. beamlit/api/workspaces/list_workspace_users.py +11 -11
  30. beamlit/api/workspaces/list_workspaces.py +11 -11
  31. beamlit/authentication/__init__.py +26 -10
  32. beamlit/authentication/apikey.py +4 -4
  33. beamlit/authentication/authentication.py +35 -6
  34. beamlit/authentication/clientcredentials.py +18 -20
  35. beamlit/authentication/credentials.py +9 -8
  36. beamlit/authentication/device_mode.py +15 -12
  37. beamlit/common/__init__.py +13 -0
  38. beamlit/common/generate.py +25 -13
  39. beamlit/common/logger.py +9 -12
  40. beamlit/common/secrets.py +11 -0
  41. beamlit/common/settings.py +29 -11
  42. beamlit/common/utils.py +4 -2
  43. beamlit/functions/__init__.py +5 -0
  44. beamlit/functions/decorator.py +90 -0
  45. beamlit/models/acl.py +2 -2
  46. beamlit/models/agent.py +3 -3
  47. beamlit/models/agent_chain.py +2 -2
  48. beamlit/models/agent_configuration.py +2 -2
  49. beamlit/models/agent_deployment.py +25 -25
  50. beamlit/models/agent_deployment_configuration.py +2 -2
  51. beamlit/models/agent_deployment_history.py +5 -5
  52. beamlit/models/agent_deployment_history_event.py +9 -9
  53. beamlit/models/agent_deployment_pod_template.py +2 -2
  54. beamlit/models/agent_release.py +2 -2
  55. beamlit/models/agent_spec.py +15 -5
  56. beamlit/models/agent_with_deployments.py +6 -6
  57. beamlit/models/api_key.py +2 -2
  58. beamlit/models/authentication_provider_model.py +6 -6
  59. beamlit/models/authentication_provider_organization.py +2 -2
  60. beamlit/models/configuration.py +10 -10
  61. beamlit/models/continent.py +2 -2
  62. beamlit/models/core_spec.py +9 -3
  63. beamlit/models/country.py +2 -2
  64. beamlit/models/create_api_key_for_service_account_body.py +2 -2
  65. beamlit/models/create_workspace_service_account_body.py +2 -2
  66. beamlit/models/create_workspace_service_account_response_200.py +2 -2
  67. beamlit/models/delete_workspace_service_account_response_200.py +2 -2
  68. beamlit/models/deployment_configuration.py +2 -2
  69. beamlit/models/deployment_configurations.py +2 -2
  70. beamlit/models/deployment_serverless_config.py +2 -2
  71. beamlit/models/deployment_serverless_config_type_0.py +3 -1
  72. beamlit/models/environment.py +7 -7
  73. beamlit/models/environment_metrics.py +8 -8
  74. beamlit/models/flavor.py +9 -9
  75. beamlit/models/function.py +3 -3
  76. beamlit/models/function_configuration.py +2 -2
  77. beamlit/models/function_deployment.py +24 -24
  78. beamlit/models/function_deployment_configuration.py +2 -2
  79. beamlit/models/function_deployment_pod_template.py +2 -2
  80. beamlit/models/function_kit.py +5 -5
  81. beamlit/models/function_provider_ref.py +2 -2
  82. beamlit/models/function_release.py +2 -2
  83. beamlit/models/function_spec.py +9 -3
  84. beamlit/models/function_with_deployments.py +6 -6
  85. beamlit/models/get_workspace_service_accounts_response_200_item.py +2 -2
  86. beamlit/models/increase_and_rate_metric.py +5 -5
  87. beamlit/models/integration.py +12 -12
  88. beamlit/models/integration_config.py +2 -2
  89. beamlit/models/integration_connection.py +5 -5
  90. beamlit/models/integration_connection_config.py +2 -2
  91. beamlit/models/integration_connection_secret.py +2 -2
  92. beamlit/models/integration_model.py +6 -6
  93. beamlit/models/integration_secret.py +2 -2
  94. beamlit/models/invite_workspace_user_body.py +2 -2
  95. beamlit/models/labels_type_0.py +2 -2
  96. beamlit/models/location.py +5 -5
  97. beamlit/models/location_response.py +5 -5
  98. beamlit/models/metric.py +2 -2
  99. beamlit/models/metrics.py +8 -8
  100. beamlit/models/model.py +3 -3
  101. beamlit/models/model_deployment.py +18 -18
  102. beamlit/models/model_deployment_log.py +2 -2
  103. beamlit/models/model_deployment_metrics.py +9 -9
  104. beamlit/models/model_deployment_metrics_inference_per_second_per_region.py +5 -5
  105. beamlit/models/model_deployment_metrics_query_per_second_per_region_per_code.py +3 -3
  106. beamlit/models/model_deployment_pod_template.py +2 -2
  107. beamlit/models/model_metrics.py +6 -6
  108. beamlit/models/model_provider.py +11 -11
  109. beamlit/models/model_provider_ref.py +2 -2
  110. beamlit/models/model_release.py +2 -2
  111. beamlit/models/model_spec.py +9 -3
  112. beamlit/models/model_with_deployments.py +6 -6
  113. beamlit/models/pending_invitation.py +2 -2
  114. beamlit/models/pending_invitation_accept.py +3 -3
  115. beamlit/models/pending_invitation_render.py +5 -5
  116. beamlit/models/pending_invitation_render_invited_by.py +2 -2
  117. beamlit/models/pending_invitation_render_workspace.py +2 -2
  118. beamlit/models/pending_invitation_workspace_details.py +6 -6
  119. beamlit/models/policy.py +20 -20
  120. beamlit/models/policy_location.py +9 -9
  121. beamlit/models/policy_spec.py +9 -3
  122. beamlit/models/provider_config.py +7 -7
  123. beamlit/models/qps.py +2 -2
  124. beamlit/models/resource_deployment_log.py +2 -2
  125. beamlit/models/resource_deployment_metrics.py +16 -16
  126. beamlit/models/resource_deployment_metrics_inference_per_region.py +5 -5
  127. beamlit/models/resource_deployment_metrics_inference_per_region_type_0.py +6 -2
  128. beamlit/models/resource_deployment_metrics_inference_per_second_per_region.py +5 -5
  129. beamlit/models/resource_deployment_metrics_inference_per_second_per_region_type_0.py +6 -2
  130. beamlit/models/resource_deployment_metrics_query_per_region_per_code.py +3 -3
  131. beamlit/models/resource_deployment_metrics_query_per_second_per_region_per_code.py +3 -3
  132. beamlit/models/resource_environment_metrics.py +62 -24
  133. beamlit/models/resource_environment_metrics_inference_per_second_per_region.py +6 -2
  134. beamlit/models/resource_metrics.py +10 -10
  135. beamlit/models/runtime.py +23 -23
  136. beamlit/models/runtime_readiness_probe.py +2 -2
  137. beamlit/models/runtime_resources.py +2 -2
  138. beamlit/models/serverless_config.py +2 -2
  139. beamlit/models/standard_fields_dynamo_db.py +2 -2
  140. beamlit/models/store_agent.py +6 -6
  141. beamlit/models/store_agent_configuration.py +2 -2
  142. beamlit/models/store_agent_labels.py +2 -2
  143. beamlit/models/store_configuration.py +16 -16
  144. beamlit/models/store_configuration_option.py +2 -2
  145. beamlit/models/store_function.py +12 -12
  146. beamlit/models/store_function_configuration.py +2 -2
  147. beamlit/models/store_function_kit.py +5 -5
  148. beamlit/models/store_function_labels.py +2 -2
  149. beamlit/models/store_function_parameter.py +9 -9
  150. beamlit/models/update_workspace_service_account_body.py +2 -2
  151. beamlit/models/update_workspace_service_account_response_200.py +2 -2
  152. beamlit/models/update_workspace_user_role_body.py +2 -2
  153. beamlit/models/workspace.py +3 -3
  154. beamlit/models/workspace_labels.py +2 -2
  155. beamlit/models/workspace_user.py +2 -2
  156. beamlit/run.py +6 -6
  157. beamlit/serve.py +120 -0
  158. {beamlit-0.0.20rc5.dist-info → beamlit-0.0.20rc6.dist-info}/METADATA +5 -1
  159. beamlit-0.0.20rc6.dist-info/RECORD +290 -0
  160. beamlit-0.0.20rc5.dist-info/RECORD +0 -282
  161. {beamlit-0.0.20rc5.dist-info → beamlit-0.0.20rc6.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union
1
+ from typing import TYPE_CHECKING, Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -24,28 +24,28 @@ class StoreFunction:
24
24
  created_by (Union[Unset, str]): The user or service account who created the resource
25
25
  updated_at (Union[Unset, str]): The date and time when the resource was updated
26
26
  updated_by (Union[Unset, str]): The user or service account who updated the resource
27
- configuration (Union[Unset, List['StoreConfiguration']]): Store function configuration
27
+ configuration (Union[Unset, list['StoreConfiguration']]): Store function configuration
28
28
  description (Union[Unset, str]): Store function description
29
29
  display_name (Union[Unset, str]): Store function display name
30
30
  image (Union[Unset, str]): Store function image
31
- kit (Union[Unset, List['StoreFunctionKit']]): Store function kit
31
+ kit (Union[Unset, list['StoreFunctionKit']]): Store function kit
32
32
  labels (Union[Unset, StoreFunctionLabels]): Store function labels
33
33
  name (Union[Unset, str]): Store function name
34
- parameters (Union[Unset, List['StoreFunctionParameter']]): Store function parameters
34
+ parameters (Union[Unset, list['StoreFunctionParameter']]): Store function parameters
35
35
  """
36
36
 
37
37
  created_at: Union[Unset, str] = UNSET
38
38
  created_by: Union[Unset, str] = UNSET
39
39
  updated_at: Union[Unset, str] = UNSET
40
40
  updated_by: Union[Unset, str] = UNSET
41
- configuration: Union[Unset, List["StoreConfiguration"]] = UNSET
41
+ configuration: Union[Unset, list["StoreConfiguration"]] = UNSET
42
42
  description: Union[Unset, str] = UNSET
43
43
  display_name: Union[Unset, str] = UNSET
44
44
  image: Union[Unset, str] = UNSET
45
- kit: Union[Unset, List["StoreFunctionKit"]] = UNSET
45
+ kit: Union[Unset, list["StoreFunctionKit"]] = UNSET
46
46
  labels: Union[Unset, "StoreFunctionLabels"] = UNSET
47
47
  name: Union[Unset, str] = UNSET
48
- parameters: Union[Unset, List["StoreFunctionParameter"]] = UNSET
48
+ parameters: Union[Unset, list["StoreFunctionParameter"]] = UNSET
49
49
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
50
50
 
51
51
  def to_dict(self) -> dict[str, Any]:
@@ -57,7 +57,7 @@ class StoreFunction:
57
57
 
58
58
  updated_by = self.updated_by
59
59
 
60
- configuration: Union[Unset, List[Dict[str, Any]]] = UNSET
60
+ configuration: Union[Unset, list[dict[str, Any]]] = UNSET
61
61
  if not isinstance(self.configuration, Unset):
62
62
  configuration = []
63
63
  for configuration_item_data in self.configuration:
@@ -70,20 +70,20 @@ class StoreFunction:
70
70
 
71
71
  image = self.image
72
72
 
73
- kit: Union[Unset, List[Dict[str, Any]]] = UNSET
73
+ kit: Union[Unset, list[dict[str, Any]]] = UNSET
74
74
  if not isinstance(self.kit, Unset):
75
75
  kit = []
76
76
  for kit_item_data in self.kit:
77
77
  kit_item = kit_item_data.to_dict()
78
78
  kit.append(kit_item)
79
79
 
80
- labels: Union[Unset, Dict[str, Any]] = UNSET
80
+ labels: Union[Unset, dict[str, Any]] = UNSET
81
81
  if not isinstance(self.labels, Unset):
82
82
  labels = self.labels.to_dict()
83
83
 
84
84
  name = self.name
85
85
 
86
- parameters: Union[Unset, List[Dict[str, Any]]] = UNSET
86
+ parameters: Union[Unset, list[dict[str, Any]]] = UNSET
87
87
  if not isinstance(self.parameters, Unset):
88
88
  parameters = []
89
89
  for parameters_item_data in self.parameters:
@@ -121,7 +121,7 @@ class StoreFunction:
121
121
  return field_dict
122
122
 
123
123
  @classmethod
124
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
124
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
125
125
  from ..models.store_configuration import StoreConfiguration
126
126
  from ..models.store_function_kit import StoreFunctionKit
127
127
  from ..models.store_function_labels import StoreFunctionLabels
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar, Union
1
+ from typing import Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -55,7 +55,7 @@ class StoreFunctionConfiguration:
55
55
  return field_dict
56
56
 
57
57
  @classmethod
58
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
58
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
59
59
  if not src_dict:
60
60
  return None
61
61
  d = src_dict.copy()
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union
1
+ from typing import TYPE_CHECKING, Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -20,13 +20,13 @@ class StoreFunctionKit:
20
20
  description (Union[Unset, str]): Description of the function kit, very important for the agent to work with your
21
21
  kit
22
22
  name (Union[Unset, str]): The kit name, very important for the agent to work with your kit
23
- parameters (Union[Unset, List['StoreFunctionParameter']]): Kit parameters, for your kit to be callable with an
23
+ parameters (Union[Unset, list['StoreFunctionParameter']]): Kit parameters, for your kit to be callable with an
24
24
  Agent
25
25
  """
26
26
 
27
27
  description: Union[Unset, str] = UNSET
28
28
  name: Union[Unset, str] = UNSET
29
- parameters: Union[Unset, List["StoreFunctionParameter"]] = UNSET
29
+ parameters: Union[Unset, list["StoreFunctionParameter"]] = UNSET
30
30
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
31
 
32
32
  def to_dict(self) -> dict[str, Any]:
@@ -34,7 +34,7 @@ class StoreFunctionKit:
34
34
 
35
35
  name = self.name
36
36
 
37
- parameters: Union[Unset, List[Dict[str, Any]]] = UNSET
37
+ parameters: Union[Unset, list[dict[str, Any]]] = UNSET
38
38
  if not isinstance(self.parameters, Unset):
39
39
  parameters = []
40
40
  for parameters_item_data in self.parameters:
@@ -54,7 +54,7 @@ class StoreFunctionKit:
54
54
  return field_dict
55
55
 
56
56
  @classmethod
57
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
57
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
58
58
  from ..models.store_function_parameter import StoreFunctionParameter
59
59
 
60
60
  if not src_dict:
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar
1
+ from typing import Any, TypeVar
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -19,7 +19,7 @@ class StoreFunctionLabels:
19
19
  return field_dict
20
20
 
21
21
  @classmethod
22
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
22
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
23
23
  if not src_dict:
24
24
  return None
25
25
  d = src_dict.copy()
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar, Union
1
+ from typing import Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -16,13 +16,13 @@ class StoreFunctionParameter:
16
16
  description (Union[Unset, str]): Store function parameter description
17
17
  name (Union[Unset, str]): Store function parameter name
18
18
  required (Union[Unset, bool]): Store function parameter required
19
- type (Union[Unset, str]): Store function parameter type
19
+ type_ (Union[Unset, str]): Store function parameter type
20
20
  """
21
21
 
22
22
  description: Union[Unset, str] = UNSET
23
23
  name: Union[Unset, str] = UNSET
24
24
  required: Union[Unset, bool] = UNSET
25
- type: Union[Unset, str] = UNSET
25
+ type_: Union[Unset, str] = UNSET
26
26
  additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
27
27
 
28
28
  def to_dict(self) -> dict[str, Any]:
@@ -32,7 +32,7 @@ class StoreFunctionParameter:
32
32
 
33
33
  required = self.required
34
34
 
35
- type = self.type
35
+ type_ = self.type_
36
36
 
37
37
  field_dict: dict[str, Any] = {}
38
38
  field_dict.update(self.additional_properties)
@@ -43,13 +43,13 @@ class StoreFunctionParameter:
43
43
  field_dict["name"] = name
44
44
  if required is not UNSET:
45
45
  field_dict["required"] = required
46
- if type is not UNSET:
47
- field_dict["type"] = type
46
+ if type_ is not UNSET:
47
+ field_dict["type"] = type_
48
48
 
49
49
  return field_dict
50
50
 
51
51
  @classmethod
52
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
52
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
53
53
  if not src_dict:
54
54
  return None
55
55
  d = src_dict.copy()
@@ -59,13 +59,13 @@ class StoreFunctionParameter:
59
59
 
60
60
  required = d.pop("required", UNSET)
61
61
 
62
- type = d.pop("type", UNSET)
62
+ type_ = d.pop("type", UNSET)
63
63
 
64
64
  store_function_parameter = cls(
65
65
  description=description,
66
66
  name=name,
67
67
  required=required,
68
- type=type,
68
+ type_=type_,
69
69
  )
70
70
 
71
71
  store_function_parameter.additional_properties = d
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar, Union
1
+ from typing import Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -36,7 +36,7 @@ class UpdateWorkspaceServiceAccountBody:
36
36
  return field_dict
37
37
 
38
38
  @classmethod
39
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
39
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
40
40
  if not src_dict:
41
41
  return None
42
42
  d = src_dict.copy()
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar, Union
1
+ from typing import Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -54,7 +54,7 @@ class UpdateWorkspaceServiceAccountResponse200:
54
54
  return field_dict
55
55
 
56
56
  @classmethod
57
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
57
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
58
58
  if not src_dict:
59
59
  return None
60
60
  d = src_dict.copy()
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar
1
+ from typing import Any, TypeVar
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -30,7 +30,7 @@ class UpdateWorkspaceUserRoleBody:
30
30
  return field_dict
31
31
 
32
32
  @classmethod
33
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
33
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
34
34
  if not src_dict:
35
35
  return None
36
36
  d = src_dict.copy()
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union
1
+ from typing import TYPE_CHECKING, Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -46,7 +46,7 @@ class Workspace:
46
46
 
47
47
  display_name = self.display_name
48
48
 
49
- labels: Union[Unset, Dict[str, Any]] = UNSET
49
+ labels: Union[Unset, dict[str, Any]] = UNSET
50
50
  if not isinstance(self.labels, Unset):
51
51
  labels = self.labels.to_dict()
52
52
 
@@ -73,7 +73,7 @@ class Workspace:
73
73
  return field_dict
74
74
 
75
75
  @classmethod
76
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
76
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
77
77
  from ..models.workspace_labels import WorkspaceLabels
78
78
 
79
79
  if not src_dict:
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar
1
+ from typing import Any, TypeVar
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -19,7 +19,7 @@ class WorkspaceLabels:
19
19
  return field_dict
20
20
 
21
21
  @classmethod
22
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
22
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
23
23
  if not src_dict:
24
24
  return None
25
25
  d = src_dict.copy()
@@ -1,4 +1,4 @@
1
- from typing import Any, Type, TypeVar, Union
1
+ from typing import Any, TypeVar, Union
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -67,7 +67,7 @@ class WorkspaceUser:
67
67
  return field_dict
68
68
 
69
69
  @classmethod
70
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
70
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
71
71
  if not src_dict:
72
72
  return None
73
73
  d = src_dict.copy()
beamlit/run.py CHANGED
@@ -1,8 +1,8 @@
1
1
  import urllib.parse
2
- from contextlib import contextmanager
3
- from typing import Any, Callable, Dict, List, Optional
2
+ from typing import Any
4
3
 
5
4
  import requests
5
+
6
6
  from beamlit.client import AuthenticatedClient
7
7
  from beamlit.common.settings import get_settings
8
8
 
@@ -18,10 +18,10 @@ class RunClient:
18
18
  environment: str,
19
19
  method: str,
20
20
  path: str = "",
21
- headers: Optional[Dict[str, str]] = None,
22
- json: Optional[Dict[str, Any]] = None,
23
- data: Optional[str] = None,
24
- params: Optional[Dict[str, str]] = None,
21
+ headers: dict[str, str] | None = None,
22
+ json: dict[str, Any] | None = None,
23
+ data: str | None = None,
24
+ params: dict[str, str] | None = None,
25
25
  ) -> requests.Response:
26
26
  settings = get_settings()
27
27
  headers = headers or {}
beamlit/serve.py ADDED
@@ -0,0 +1,120 @@
1
+ import importlib
2
+ import time
3
+ import traceback
4
+ from contextlib import asynccontextmanager
5
+ from logging import getLogger
6
+ from uuid import uuid4
7
+
8
+ import uvicorn
9
+ from asgi_correlation_id import CorrelationIdMiddleware
10
+ from fastapi import FastAPI, Request, Response
11
+ from fastapi.responses import JSONResponse
12
+ from starlette.middleware.base import BaseHTTPMiddleware
13
+
14
+ from beamlit.common.settings import get_settings, init
15
+
16
+ main_agent = None
17
+
18
+
19
+ class AccessLogMiddleware(BaseHTTPMiddleware):
20
+ async def dispatch(self, request, call_next):
21
+ logger = getLogger(__name__)
22
+ response = await call_next(request)
23
+ process_time = response.headers.get("X-Process-Time")
24
+ rid_header = response.headers.get("X-Request-Id")
25
+ request_id = rid_header or response.headers.get("X-Beamlit-Request-Id")
26
+ logger.info(f"{request.method} {request.url.path} {response.status_code} {process_time}ms rid={request_id}")
27
+ return response
28
+
29
+
30
+ class AddProcessTimeHeader(BaseHTTPMiddleware):
31
+ async def dispatch(self, request, call_next):
32
+ start_time = time.perf_counter()
33
+ response = await call_next(request)
34
+ process_time = (time.perf_counter() - start_time) * 1000
35
+ response.headers["X-Process-Time"] = f"{process_time:.2f}"
36
+ return response
37
+
38
+
39
+ @asynccontextmanager
40
+ async def lifespan(app: FastAPI):
41
+ try:
42
+ is_main = __name__ == "main"
43
+ if not is_main:
44
+ init()
45
+
46
+ logger = getLogger(__name__)
47
+ settings = get_settings()
48
+
49
+ # Import the agent
50
+ global main_agent
51
+ main_agent = importlib.import_module(".".join(settings.agent_module.split(".")[0:-1]))
52
+ # Log the server is running
53
+ if is_main:
54
+ logger.info(f"Server running on http://{settings.host}:{settings.port}")
55
+ yield
56
+ except Exception as e:
57
+ logger = getLogger(__name__)
58
+ logger.error(f"Error initializing agent: {e}", exc_info=True)
59
+ raise e
60
+
61
+
62
+ app = FastAPI(lifespan=lifespan, docs_url=None, redoc_url=None)
63
+ app.add_middleware(
64
+ CorrelationIdMiddleware,
65
+ header_name="x-beamlit-request-id",
66
+ generator=lambda: str(uuid4()),
67
+ )
68
+ app.add_middleware(AddProcessTimeHeader)
69
+ app.add_middleware(AccessLogMiddleware)
70
+
71
+
72
+ @app.get("/health")
73
+ async def health():
74
+ return {"status": "ok"}
75
+
76
+
77
+ @app.post("/")
78
+ async def root(request: Request):
79
+ settings = get_settings()
80
+ logger = getLogger(__name__)
81
+ try:
82
+ func = getattr(main_agent, settings.agent_module.split(".")[-1])
83
+ body = await request.json()
84
+ response = await func(body)
85
+ if isinstance(response, Response):
86
+ return response
87
+ if type(response) is str:
88
+ return Response(
89
+ content=response,
90
+ headers={"Content-Type": "text/plain"},
91
+ media_type="text/plain",
92
+ status_code=200,
93
+ )
94
+ return JSONResponse(status_code=200, content=response)
95
+ except ValueError as e:
96
+ content = {"error": str(e)}
97
+ if settings.environment == "development":
98
+ content["traceback"] = str(traceback.format_exc())
99
+ logger.error(f"{content}")
100
+ return JSONResponse(status_code=400, content=content)
101
+ except Exception as e:
102
+ content = {"error": f"Internal server error, {e}"}
103
+ if settings.environment == "development":
104
+ content["traceback"] = str(traceback.format_exc())
105
+ return JSONResponse(status_code=500, content=content)
106
+
107
+
108
+ def main():
109
+ settings = init()
110
+ uvicorn.run(
111
+ f"{__name__}:app",
112
+ host=settings.host,
113
+ port=settings.port,
114
+ log_level="critical",
115
+ reload=settings.environment != "production",
116
+ )
117
+
118
+
119
+ if __name__ == "__main__":
120
+ main()
@@ -1,11 +1,15 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: beamlit
3
- Version: 0.0.20rc5
3
+ Version: 0.0.20rc6
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <ch.ploujoux@gmail.com>
6
6
  Requires-Python: >=3.12
7
+ Requires-Dist: asgi-correlation-id==4.3.4
7
8
  Requires-Dist: attrs>=21.3.0
9
+ Requires-Dist: fastapi[standard]==0.115.4
8
10
  Requires-Dist: httpx<0.28.0,>=0.20.0
11
+ Requires-Dist: langchain-core==0.3.13
12
+ Requires-Dist: langgraph==0.2.40
9
13
  Requires-Dist: pydantic-settings<2.7.0,>=2.6.1
10
14
  Requires-Dist: pydantic<2.11.0,>=2.10.3
11
15
  Requires-Dist: python-dateutil>=2.8.0