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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. beamlit/agents/__init__.py +4 -0
  2. beamlit/agents/chat.py +87 -0
  3. beamlit/agents/decorator.py +147 -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 +36 -5
  34. beamlit/authentication/clientcredentials.py +18 -20
  35. beamlit/authentication/credentials.py +18 -11
  36. beamlit/authentication/device_mode.py +15 -12
  37. beamlit/common/__init__.py +13 -0
  38. beamlit/common/generate.py +31 -19
  39. beamlit/common/logger.py +9 -12
  40. beamlit/common/secrets.py +11 -0
  41. beamlit/common/settings.py +78 -30
  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/app.py +73 -0
  158. beamlit/serve/middlewares/__init__.py +4 -0
  159. beamlit/serve/middlewares/accesslog.py +14 -0
  160. beamlit/serve/middlewares/processtime.py +12 -0
  161. {beamlit-0.0.20rc5.dist-info → beamlit-0.0.20rc7.dist-info}/METADATA +7 -1
  162. beamlit-0.0.20rc7.dist-info/RECORD +293 -0
  163. beamlit-0.0.20rc5.dist-info/RECORD +0 -282
  164. {beamlit-0.0.20rc5.dist-info → beamlit-0.0.20rc7.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast
1
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
2
2
 
3
3
  from attrs import define as _attrs_define
4
4
  from attrs import field as _attrs_field
@@ -17,30 +17,30 @@ class StoreConfiguration:
17
17
  """Store configuration for resources (eg: agent, function, etc)
18
18
 
19
19
  Attributes:
20
- available_models (Union[Unset, List[str]]): Available models for the configuration
20
+ available_models (Union[Unset, list[str]]): Available models for the configuration
21
21
  description (Union[Unset, str]): Store configuration description
22
22
  display_name (Union[Unset, str]): Store configuration display name
23
23
  if_ (Union[Unset, str]): Conditional rendering for the configuration, example: provider === 'openai'
24
24
  name (Union[Unset, str]): Store configuration name
25
- options (Union[Unset, List['StoreConfigurationOption']]):
25
+ options (Union[Unset, list['StoreConfigurationOption']]):
26
26
  required (Union[Unset, bool]): Store configuration required
27
27
  secret (Union[Unset, bool]): Store configuration secret
28
- type (Union[Unset, str]): Store configuration type
28
+ type_ (Union[Unset, str]): Store configuration type
29
29
  """
30
30
 
31
- available_models: Union[Unset, List[str]] = UNSET
31
+ available_models: Union[Unset, list[str]] = UNSET
32
32
  description: Union[Unset, str] = UNSET
33
33
  display_name: Union[Unset, str] = UNSET
34
34
  if_: Union[Unset, str] = UNSET
35
35
  name: Union[Unset, str] = UNSET
36
- options: Union[Unset, List["StoreConfigurationOption"]] = UNSET
36
+ options: Union[Unset, list["StoreConfigurationOption"]] = UNSET
37
37
  required: Union[Unset, bool] = UNSET
38
38
  secret: Union[Unset, bool] = UNSET
39
- type: Union[Unset, str] = UNSET
39
+ type_: Union[Unset, str] = UNSET
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
- available_models: Union[Unset, List[str]] = UNSET
43
+ available_models: Union[Unset, list[str]] = UNSET
44
44
  if not isinstance(self.available_models, Unset):
45
45
  available_models = self.available_models
46
46
 
@@ -52,7 +52,7 @@ class StoreConfiguration:
52
52
 
53
53
  name = self.name
54
54
 
55
- options: Union[Unset, List[Dict[str, Any]]] = UNSET
55
+ options: Union[Unset, list[dict[str, Any]]] = UNSET
56
56
  if not isinstance(self.options, Unset):
57
57
  options = []
58
58
  for options_item_data in self.options:
@@ -63,7 +63,7 @@ class StoreConfiguration:
63
63
 
64
64
  secret = self.secret
65
65
 
66
- type = self.type
66
+ type_ = self.type_
67
67
 
68
68
  field_dict: dict[str, Any] = {}
69
69
  field_dict.update(self.additional_properties)
@@ -84,19 +84,19 @@ class StoreConfiguration:
84
84
  field_dict["required"] = required
85
85
  if secret is not UNSET:
86
86
  field_dict["secret"] = secret
87
- if type is not UNSET:
88
- field_dict["type"] = type
87
+ if type_ is not UNSET:
88
+ field_dict["type"] = type_
89
89
 
90
90
  return field_dict
91
91
 
92
92
  @classmethod
93
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
93
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
94
94
  from ..models.store_configuration_option import StoreConfigurationOption
95
95
 
96
96
  if not src_dict:
97
97
  return None
98
98
  d = src_dict.copy()
99
- available_models = cast(List[str], d.pop("available_models", UNSET))
99
+ available_models = cast(list[str], d.pop("available_models", UNSET))
100
100
 
101
101
  description = d.pop("description", UNSET)
102
102
 
@@ -117,7 +117,7 @@ class StoreConfiguration:
117
117
 
118
118
  secret = d.pop("secret", UNSET)
119
119
 
120
- type = d.pop("type", UNSET)
120
+ type_ = d.pop("type", UNSET)
121
121
 
122
122
  store_configuration = cls(
123
123
  available_models=available_models,
@@ -128,7 +128,7 @@ class StoreConfiguration:
128
128
  options=options,
129
129
  required=required,
130
130
  secret=secret,
131
- type=type,
131
+ type_=type_,
132
132
  )
133
133
 
134
134
  store_configuration.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
@@ -43,7 +43,7 @@ class StoreConfigurationOption:
43
43
  return field_dict
44
44
 
45
45
  @classmethod
46
- def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
46
+ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
47
47
  if not src_dict:
48
48
  return None
49
49
  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
@@ -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/app.py ADDED
@@ -0,0 +1,73 @@
1
+ import importlib
2
+ import traceback
3
+ from logging import getLogger
4
+ from uuid import uuid4
5
+
6
+ from asgi_correlation_id import CorrelationIdMiddleware
7
+ from fastapi import FastAPI, Request, Response
8
+ from fastapi.responses import JSONResponse
9
+
10
+ from beamlit.common.settings import get_settings, init
11
+
12
+ from .middlewares import AccessLogMiddleware, AddProcessTimeHeader
13
+
14
+
15
+ def import_module():
16
+ settings = get_settings()
17
+ main_module = importlib.import_module(".".join(settings.server.module.split(".")[0:-1]))
18
+ func = getattr(main_module, settings.server.module.split(".")[-1])
19
+ return func
20
+
21
+
22
+ settings = init()
23
+ logger = getLogger(__name__)
24
+ logger.info(f"Importing server module: {settings.server.module}")
25
+ func = import_module()
26
+ logger.info(
27
+ f"Running server with environment {settings.environment}"
28
+ f" on {settings.server.host}:{settings.server.port}"
29
+ )
30
+
31
+ app = FastAPI(docs_url=None, redoc_url=None)
32
+ app.add_middleware(
33
+ CorrelationIdMiddleware,
34
+ header_name="x-beamlit-request-id",
35
+ generator=lambda: str(uuid4()),
36
+ )
37
+ app.add_middleware(AddProcessTimeHeader)
38
+ app.add_middleware(AccessLogMiddleware)
39
+
40
+
41
+ @app.get("/health")
42
+ async def health():
43
+ return {"status": "ok"}
44
+
45
+
46
+ @app.post("/")
47
+ async def root(request: Request):
48
+ settings = get_settings()
49
+ logger = getLogger(__name__)
50
+ try:
51
+ body = await request.json()
52
+ response = await func(body)
53
+ if isinstance(response, Response):
54
+ return response
55
+ if type(response) is str:
56
+ return Response(
57
+ content=response,
58
+ headers={"Content-Type": "text/plain"},
59
+ media_type="text/plain",
60
+ status_code=200,
61
+ )
62
+ return JSONResponse(status_code=200, content=response)
63
+ except ValueError as e:
64
+ content = {"error": str(e)}
65
+ if settings.environment == "development":
66
+ content["traceback"] = str(traceback.format_exc())
67
+ logger.error(f"{content}")
68
+ return JSONResponse(status_code=400, content=content)
69
+ except Exception as e:
70
+ content = {"error": f"Internal server error, {e}"}
71
+ if settings.environment == "development":
72
+ content["traceback"] = str(traceback.format_exc())
73
+ return JSONResponse(status_code=500, content=content)
@@ -0,0 +1,4 @@
1
+ from .accesslog import AccessLogMiddleware
2
+ from .processtime import AddProcessTimeHeader
3
+
4
+ __all__ = ["AccessLogMiddleware", "AddProcessTimeHeader"]
@@ -0,0 +1,14 @@
1
+ from logging import getLogger
2
+
3
+ from starlette.middleware.base import BaseHTTPMiddleware
4
+
5
+
6
+ class AccessLogMiddleware(BaseHTTPMiddleware):
7
+ async def dispatch(self, request, call_next):
8
+ logger = getLogger(__name__)
9
+ response = await call_next(request)
10
+ process_time = response.headers.get("X-Process-Time")
11
+ rid_header = response.headers.get("X-Request-Id")
12
+ request_id = rid_header or response.headers.get("X-Beamlit-Request-Id")
13
+ logger.info(f"{request.method} {request.url.path} {response.status_code} {process_time}ms rid={request_id}")
14
+ return response
@@ -0,0 +1,12 @@
1
+ import time
2
+
3
+ from starlette.middleware.base import BaseHTTPMiddleware
4
+
5
+
6
+ class AddProcessTimeHeader(BaseHTTPMiddleware):
7
+ async def dispatch(self, request, call_next):
8
+ start_time = time.perf_counter()
9
+ response = await call_next(request)
10
+ process_time = (time.perf_counter() - start_time) * 1000
11
+ response.headers["X-Process-Time"] = f"{process_time:.2f}"
12
+ return response
@@ -1,11 +1,17 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: beamlit
3
- Version: 0.0.20rc5
3
+ Version: 0.0.20rc7
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<5.0.0,>=4.3.4
7
8
  Requires-Dist: attrs>=21.3.0
9
+ Requires-Dist: fastapi[standard]<0.116.0,>=0.115.4
8
10
  Requires-Dist: httpx<0.28.0,>=0.20.0
11
+ Requires-Dist: langchain-community<0.4.0,>=0.3.3
12
+ Requires-Dist: langchain-core<0.4.0,>=0.3.13
13
+ Requires-Dist: langchain-openai<0.3.0,>=0.2.4
14
+ Requires-Dist: langgraph<0.3.0,>=0.2.40
9
15
  Requires-Dist: pydantic-settings<2.7.0,>=2.6.1
10
16
  Requires-Dist: pydantic<2.11.0,>=2.10.3
11
17
  Requires-Dist: python-dateutil>=2.8.0