beamlit 0.0.18__py3-none-any.whl → 0.0.20__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) 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/create_agent.py +14 -9
  5. beamlit/api/agents/delete_agent_history.py +159 -0
  6. beamlit/api/agents/get_agent_deployment_logs.py +11 -11
  7. beamlit/api/{authentication_providers/list_organizations_for_authentication_provider.py → agents/get_agent_environment_logs.py} +30 -42
  8. beamlit/api/{authentication_providers/get_model_with_repo_for_authentication_provider.py → agents/get_agent_history.py} +43 -68
  9. beamlit/api/agents/list_agent_deployment_history.py +11 -11
  10. beamlit/api/agents/list_agent_deployments.py +11 -11
  11. beamlit/api/agents/list_agent_history.py +151 -0
  12. beamlit/api/agents/list_agents.py +11 -11
  13. beamlit/api/agents/put_agent_history.py +185 -0
  14. beamlit/api/agents/update_agent.py +14 -9
  15. beamlit/api/environments/list_environments.py +11 -11
  16. beamlit/api/functions/create_function.py +14 -9
  17. beamlit/api/functions/get_function_deployment_logs.py +11 -11
  18. beamlit/api/functions/get_function_environment_logs.py +151 -0
  19. beamlit/api/functions/list_function_deployments.py +11 -11
  20. beamlit/api/functions/list_functions.py +11 -11
  21. beamlit/api/functions/update_function.py +14 -9
  22. beamlit/api/history/get_agents_history.py +11 -11
  23. beamlit/api/history/list_agents_history.py +11 -11
  24. beamlit/api/integrations/create_integration_connection.py +167 -0
  25. beamlit/api/integrations/delete_integration_connection.py +158 -0
  26. beamlit/api/integrations/get_integration.py +97 -0
  27. beamlit/api/integrations/get_integration_connection.py +154 -0
  28. beamlit/api/integrations/get_integration_connection_model.py +97 -0
  29. beamlit/api/integrations/get_integration_model.py +97 -0
  30. beamlit/api/integrations/list_integration_connection_models.py +97 -0
  31. beamlit/api/integrations/list_integration_connections.py +139 -0
  32. beamlit/api/integrations/list_integration_models.py +97 -0
  33. beamlit/api/integrations/update_integration_connection.py +180 -0
  34. beamlit/api/invitations/list_all_pending_invitations.py +11 -11
  35. beamlit/api/locations/list_locations.py +11 -11
  36. beamlit/api/model_providers/list_model_providers.py +11 -11
  37. beamlit/api/models/get_model_deployment_logs.py +11 -11
  38. beamlit/api/{authentication_providers/list_models_for_authentication_provider.py → models/get_model_environment_logs.py} +30 -38
  39. beamlit/api/models/list_model_deployments.py +11 -11
  40. beamlit/api/models/list_models.py +11 -11
  41. beamlit/api/policies/list_policies.py +11 -11
  42. beamlit/api/service_accounts/get_workspace_service_accounts.py +11 -11
  43. beamlit/api/service_accounts/list_api_keys_for_service_account.py +11 -11
  44. beamlit/api/store/list_store_agents.py +11 -11
  45. beamlit/api/store/list_store_functions.py +11 -11
  46. beamlit/api/workspaces/list_workspace_users.py +11 -11
  47. beamlit/api/workspaces/list_workspaces.py +11 -11
  48. beamlit/authentication/__init__.py +29 -8
  49. beamlit/authentication/apikey.py +8 -2
  50. beamlit/authentication/authentication.py +66 -3
  51. beamlit/authentication/clientcredentials.py +108 -0
  52. beamlit/authentication/credentials.py +22 -8
  53. beamlit/authentication/device_mode.py +23 -13
  54. beamlit/common/__init__.py +13 -0
  55. beamlit/common/generate.py +183 -0
  56. beamlit/common/logger.py +29 -0
  57. beamlit/common/secrets.py +11 -0
  58. beamlit/common/settings.py +156 -0
  59. beamlit/common/utils.py +15 -0
  60. beamlit/functions/__init__.py +5 -0
  61. beamlit/functions/decorator.py +90 -0
  62. beamlit/functions/github/__init__.py +3 -0
  63. beamlit/functions/github/github.py +21 -0
  64. beamlit/functions/github/kit/__init__.py +7 -0
  65. beamlit/functions/github/kit/pull_request.py +51 -0
  66. beamlit/functions/math/__init__.py +3 -0
  67. beamlit/functions/math/math.py +40 -0
  68. beamlit/functions/search/__init__.py +3 -0
  69. beamlit/functions/search/search.py +15 -0
  70. beamlit/models/__init__.py +24 -0
  71. beamlit/models/acl.py +4 -2
  72. beamlit/models/agent.py +5 -3
  73. beamlit/models/agent_chain.py +4 -2
  74. beamlit/models/agent_configuration.py +4 -2
  75. beamlit/models/agent_deployment.py +41 -28
  76. beamlit/models/agent_deployment_configuration.py +4 -2
  77. beamlit/models/agent_deployment_configuration_type_0.py +43 -0
  78. beamlit/models/agent_deployment_history.py +7 -5
  79. beamlit/models/agent_deployment_history_event.py +11 -9
  80. beamlit/models/agent_deployment_pod_template.py +4 -2
  81. beamlit/models/agent_deployment_pod_template_type_0.py +43 -0
  82. beamlit/models/agent_history.py +165 -0
  83. beamlit/models/agent_history_event.py +131 -0
  84. beamlit/models/agent_metadata.py +144 -0
  85. beamlit/models/agent_release.py +4 -2
  86. beamlit/models/agent_spec.py +248 -0
  87. beamlit/models/agent_with_deployments.py +176 -0
  88. beamlit/models/api_key.py +4 -2
  89. beamlit/models/authentication_provider_model.py +8 -6
  90. beamlit/models/authentication_provider_organization.py +4 -2
  91. beamlit/models/configuration.py +12 -10
  92. beamlit/models/continent.py +4 -2
  93. beamlit/models/core_spec.py +185 -0
  94. beamlit/models/country.py +4 -2
  95. beamlit/models/create_api_key_for_service_account_body.py +4 -2
  96. beamlit/models/create_workspace_service_account_body.py +4 -2
  97. beamlit/models/create_workspace_service_account_response_200.py +4 -2
  98. beamlit/models/delete_workspace_service_account_response_200.py +4 -2
  99. beamlit/models/deployment_configuration.py +4 -2
  100. beamlit/models/deployment_configurations.py +22 -7
  101. beamlit/models/deployment_serverless_config.py +4 -2
  102. beamlit/models/deployment_serverless_config_type_0.py +220 -0
  103. beamlit/models/environment.py +9 -7
  104. beamlit/models/environment_metrics.py +26 -5
  105. beamlit/models/environment_spec.py +61 -0
  106. beamlit/models/flavor.py +11 -9
  107. beamlit/models/function.py +5 -3
  108. beamlit/models/function_configuration.py +4 -2
  109. beamlit/models/function_deployment.py +33 -20
  110. beamlit/models/function_deployment_configuration.py +4 -2
  111. beamlit/models/function_deployment_configuration_type_0.py +43 -0
  112. beamlit/models/function_deployment_pod_template.py +4 -2
  113. beamlit/models/function_deployment_pod_template_type_0.py +43 -0
  114. beamlit/models/function_kit.py +7 -5
  115. beamlit/models/function_metadata.py +144 -0
  116. beamlit/models/function_provider_ref.py +4 -2
  117. beamlit/models/function_release.py +4 -2
  118. beamlit/models/function_spec.py +246 -0
  119. beamlit/models/function_with_deployments.py +176 -0
  120. beamlit/models/get_workspace_service_accounts_response_200_item.py +4 -2
  121. beamlit/models/increase_and_rate_metric.py +104 -0
  122. beamlit/models/integration.py +198 -0
  123. beamlit/models/integration_config.py +45 -0
  124. beamlit/models/integration_connection.py +198 -0
  125. beamlit/models/integration_connection_config.py +45 -0
  126. beamlit/models/integration_connection_secret.py +61 -0
  127. beamlit/models/integration_connection_spec.py +99 -0
  128. beamlit/models/integration_model.py +144 -0
  129. beamlit/models/integration_secret.py +61 -0
  130. beamlit/models/invite_workspace_user_body.py +4 -2
  131. beamlit/models/labels_type_0.py +4 -2
  132. beamlit/models/location.py +7 -5
  133. beamlit/models/location_response.py +7 -5
  134. beamlit/models/metadata.py +135 -0
  135. beamlit/models/{labels.py → metadata_labels.py} +5 -5
  136. beamlit/models/metric.py +4 -2
  137. beamlit/models/metrics.py +68 -25
  138. beamlit/models/model.py +5 -3
  139. beamlit/models/model_deployment.py +27 -14
  140. beamlit/models/model_deployment_log.py +4 -2
  141. beamlit/models/model_deployment_metrics.py +11 -9
  142. beamlit/models/model_deployment_metrics_inference_per_second_per_region.py +7 -5
  143. beamlit/models/model_deployment_metrics_query_per_second_per_region_per_code.py +5 -3
  144. beamlit/models/model_deployment_pod_template.py +4 -2
  145. beamlit/models/model_deployment_pod_template_type_0.py +43 -0
  146. beamlit/models/model_metadata.py +144 -0
  147. beamlit/models/model_metrics.py +8 -6
  148. beamlit/models/model_provider.py +13 -11
  149. beamlit/models/model_provider_ref.py +4 -2
  150. beamlit/models/model_release.py +4 -2
  151. beamlit/models/model_spec.py +194 -0
  152. beamlit/models/model_with_deployments.py +8 -6
  153. beamlit/models/owner_fields.py +68 -0
  154. beamlit/models/pending_invitation.py +4 -2
  155. beamlit/models/pending_invitation_accept.py +5 -3
  156. beamlit/models/pending_invitation_render.py +7 -5
  157. beamlit/models/pending_invitation_render_invited_by.py +4 -2
  158. beamlit/models/pending_invitation_render_workspace.py +4 -2
  159. beamlit/models/pending_invitation_workspace_details.py +8 -6
  160. beamlit/models/pod_template_spec.py +43 -0
  161. beamlit/models/policy.py +22 -20
  162. beamlit/models/policy_location.py +11 -9
  163. beamlit/models/policy_spec.py +125 -0
  164. beamlit/models/provider_config.py +9 -16
  165. beamlit/models/qps.py +4 -2
  166. beamlit/models/resource_deployment_log.py +4 -2
  167. beamlit/models/resource_deployment_metrics.py +119 -9
  168. beamlit/models/resource_deployment_metrics_inference_per_region.py +77 -0
  169. beamlit/models/resource_deployment_metrics_inference_per_region_type_0.py +79 -0
  170. beamlit/models/resource_deployment_metrics_inference_per_second_per_region.py +7 -5
  171. beamlit/models/resource_deployment_metrics_inference_per_second_per_region_type_0.py +79 -0
  172. beamlit/models/resource_deployment_metrics_query_per_region_per_code.py +75 -0
  173. beamlit/models/resource_deployment_metrics_query_per_region_per_code_type_0.py +73 -0
  174. beamlit/models/resource_deployment_metrics_query_per_second_per_region_per_code.py +5 -3
  175. beamlit/models/resource_deployment_metrics_query_per_second_per_region_per_code_type_0.py +73 -0
  176. beamlit/models/resource_environment_metrics.py +210 -0
  177. beamlit/models/resource_environment_metrics_inference_per_second_per_region.py +79 -0
  178. beamlit/models/resource_environment_metrics_query_per_second_per_region_per_code.py +73 -0
  179. beamlit/models/resource_log.py +68 -0
  180. beamlit/models/resource_metrics.py +44 -6
  181. beamlit/models/runtime.py +25 -23
  182. beamlit/models/runtime_readiness_probe.py +4 -2
  183. beamlit/models/runtime_readiness_probe_type_0.py +43 -0
  184. beamlit/models/runtime_resources.py +4 -2
  185. beamlit/models/runtime_type_0.py +111 -0
  186. beamlit/models/runtime_type_0_readiness_probe.py +43 -0
  187. beamlit/models/runtime_type_0_readiness_probe_type_0.py +43 -0
  188. beamlit/models/runtime_type_0_resources.py +59 -0
  189. beamlit/models/serverless_config.py +4 -2
  190. beamlit/models/spec_configuration.py +68 -0
  191. beamlit/models/standard_fields_dynamo_db.py +4 -2
  192. beamlit/models/store_agent.py +8 -6
  193. beamlit/models/store_agent_configuration.py +4 -2
  194. beamlit/models/store_agent_labels.py +4 -2
  195. beamlit/models/store_agent_labels_type_0.py +43 -0
  196. beamlit/models/store_configuration.py +18 -16
  197. beamlit/models/store_configuration_option.py +4 -2
  198. beamlit/models/store_function.py +14 -12
  199. beamlit/models/store_function_configuration.py +4 -2
  200. beamlit/models/store_function_kit.py +7 -5
  201. beamlit/models/store_function_labels.py +4 -2
  202. beamlit/models/store_function_labels_type_0.py +43 -0
  203. beamlit/models/store_function_parameter.py +11 -9
  204. beamlit/models/time_fields.py +68 -0
  205. beamlit/models/update_workspace_service_account_body.py +4 -2
  206. beamlit/models/update_workspace_service_account_response_200.py +4 -2
  207. beamlit/models/update_workspace_user_role_body.py +4 -2
  208. beamlit/models/websocket_channel.py +86 -0
  209. beamlit/models/workspace.py +5 -3
  210. beamlit/models/workspace_labels.py +4 -2
  211. beamlit/models/workspace_user.py +4 -2
  212. beamlit/run.py +49 -0
  213. beamlit/serve/app.py +78 -0
  214. beamlit/serve/middlewares/__init__.py +4 -0
  215. beamlit/serve/middlewares/accesslog.py +14 -0
  216. beamlit/serve/middlewares/processtime.py +12 -0
  217. {beamlit-0.0.18.dist-info → beamlit-0.0.20.dist-info}/METADATA +11 -2
  218. beamlit-0.0.20.dist-info/RECORD +301 -0
  219. beamlit-0.0.18.dist-info/RECORD +0 -211
  220. /beamlit/api/{authentication_providers → integrations}/__init__.py +0 -0
  221. {beamlit-0.0.18.dist-info → beamlit-0.0.20.dist-info}/WHEEL +0 -0
@@ -0,0 +1,4 @@
1
+ from .chat import get_chat_model
2
+ from .decorator import agent
3
+
4
+ __all__ = ["agent", "get_chat_model"]
beamlit/agents/chat.py ADDED
@@ -0,0 +1,87 @@
1
+ from logging import getLogger
2
+
3
+ from beamlit.authentication import get_authentication_headers, new_client
4
+ from beamlit.common.settings import get_settings
5
+ from beamlit.models import AgentDeployment
6
+
7
+ logger = getLogger(__name__)
8
+
9
+
10
+ def get_base_url(agent_model: AgentDeployment):
11
+ settings = get_settings()
12
+ return f"{settings.run_url}/{settings.workspace}/models/{agent_model.model}/v1"
13
+
14
+
15
+ def get_mistral_chat_model(**kwargs):
16
+ from langchain_mistralai.chat_models import ChatMistralAI # type: ignore
17
+
18
+ return ChatMistralAI(**kwargs)
19
+
20
+
21
+ def get_openai_chat_model(**kwargs):
22
+ from langchain_openai import ChatOpenAI # type: ignore
23
+
24
+ return ChatOpenAI(**kwargs)
25
+
26
+
27
+ def get_anthropic_chat_model(**kwargs):
28
+ from langchain_anthropic import ChatAnthropic # type: ignore
29
+
30
+ return ChatAnthropic(**kwargs)
31
+
32
+
33
+ def get_chat_model(agent_model: AgentDeployment):
34
+ settings = get_settings()
35
+ client = new_client()
36
+
37
+ headers = get_authentication_headers(settings)
38
+ headers["X-Beamlit-Environment"] = agent_model.environment
39
+
40
+ jwt = headers.pop("X-Beamlit-Authorization").replace("Bearer ", "")
41
+ params = {"environment": agent_model.environment}
42
+ chat_classes = {
43
+ "openai": {
44
+ "func": get_openai_chat_model,
45
+ "kwargs": {
46
+ "http_client": client.get_httpx_client(),
47
+ },
48
+ },
49
+ "anthropic": {
50
+ "func": get_anthropic_chat_model,
51
+ "kwargs": {},
52
+ },
53
+ "mistral": {
54
+ "func": get_mistral_chat_model,
55
+ "kwargs": {
56
+ "api_key": jwt,
57
+ },
58
+ },
59
+ }
60
+
61
+ if agent_model is None:
62
+ raise ValueError("agent_model not found in configuration")
63
+ if agent_model.runtime is None:
64
+ raise ValueError("runtime not found in agent model")
65
+ if agent_model.runtime.type_ is None:
66
+ raise ValueError("type not found in runtime")
67
+ if agent_model.runtime.model is None:
68
+ raise ValueError("model not found in runtime")
69
+
70
+ provider = agent_model.runtime.type_
71
+ model = agent_model.runtime.model
72
+
73
+ kwargs = {
74
+ "model": model,
75
+ "base_url": get_base_url(agent_model),
76
+ "default_query": params,
77
+ "default_headers": headers,
78
+ "api_key": "fake_api_key",
79
+ "temperature": 0,
80
+ }
81
+ chat_class = chat_classes.get(provider)
82
+ if not chat_class:
83
+ logger.warning(f"Provider {provider} not currently supported, defaulting to OpenAI")
84
+ chat_class = chat_classes["openai"]
85
+ if "kwargs" in chat_class:
86
+ kwargs.update(chat_class["kwargs"])
87
+ return chat_class["func"](**kwargs)
@@ -0,0 +1,147 @@
1
+ # Import necessary modules
2
+ import ast
3
+ import importlib
4
+ import os
5
+ from logging import getLogger
6
+
7
+ from langgraph.checkpoint.memory import MemorySaver
8
+ from langgraph.prebuilt import create_react_agent
9
+
10
+ from beamlit.api.models import get_model_deployment
11
+ from beamlit.authentication import new_client
12
+ from beamlit.common.settings import get_settings, init
13
+ from beamlit.errors import UnexpectedStatus
14
+ from beamlit.models import AgentDeployment
15
+
16
+ from .chat import get_chat_model
17
+
18
+
19
+ def get_functions(dir="src/functions", from_decorator="function"):
20
+ functions = []
21
+ logger = getLogger(__name__)
22
+
23
+ # Walk through all Python files in functions directory and subdirectories
24
+ for root, _, files in os.walk(dir):
25
+ for file in files:
26
+ if file.endswith(".py"):
27
+ file_path = os.path.join(root, file)
28
+ # Read and compile the file content
29
+ with open(file_path) as f:
30
+ try:
31
+ file_content = f.read()
32
+ # Parse the file content to find decorated functions
33
+ tree = ast.parse(file_content)
34
+
35
+ # Look for function definitions with decorators
36
+ for node in ast.walk(tree):
37
+ if (
38
+ not isinstance(node, ast.FunctionDef)
39
+ or len(node.decorator_list) == 0
40
+ ):
41
+ continue
42
+ decorator = node.decorator_list[0]
43
+
44
+ decorator_name = ""
45
+ if isinstance(decorator, ast.Call):
46
+ decorator_name = decorator.func.id
47
+ if isinstance(decorator, ast.Name):
48
+ decorator_name = decorator.id
49
+
50
+ if decorator_name == from_decorator:
51
+ # Get the function name and decorator name
52
+ func_name = node.name
53
+
54
+ # Import the module to get the actual function
55
+ spec = importlib.util.spec_from_file_location(func_name, file_path)
56
+ module = importlib.util.module_from_spec(spec)
57
+ spec.loader.exec_module(module)
58
+ # Check if kit=True in the decorator arguments
59
+ is_kit = False
60
+ if isinstance(decorator, ast.Call):
61
+ for keyword in decorator.keywords:
62
+ if keyword.arg == "kit" and isinstance(
63
+ keyword.value, ast.Constant
64
+ ):
65
+ is_kit = keyword.value.value
66
+ if is_kit:
67
+ kit_functions = get_functions(
68
+ dir=os.path.join(root),
69
+ from_decorator="kit",
70
+ )
71
+ functions.extend(kit_functions)
72
+
73
+ # Get the decorated function
74
+ if not is_kit and hasattr(module, func_name):
75
+ func = getattr(module, func_name)
76
+ functions.append(func)
77
+ except Exception as e:
78
+ logger.warning(f"Error processing {file_path}: {e!s}")
79
+ return functions
80
+
81
+
82
+ def agent(
83
+ bl_agent: AgentDeployment = None,
84
+ chat_model=None,
85
+ agent=None,
86
+ ):
87
+ settings = init()
88
+ logger = getLogger(__name__)
89
+
90
+ def wrapper(func):
91
+ settings = get_settings()
92
+
93
+ def wrapped(*args, **kwargs):
94
+ return func(
95
+ settings.agent.agent,
96
+ settings.agent.chat_model,
97
+ settings.agent.functions,
98
+ *args,
99
+ **kwargs,
100
+ )
101
+
102
+ return wrapped
103
+
104
+ # Initialize functions array to store decorated functions
105
+ functions = get_functions(dir=settings.agent.functions_directory)
106
+ settings.agent.functions = functions
107
+
108
+ if bl_agent.model and chat_model is None:
109
+ client = new_client()
110
+ try:
111
+ response = get_model_deployment.sync_detailed(
112
+ bl_agent.model, settings.environment, client=client
113
+ )
114
+ settings.agent.model = response.parsed
115
+ except UnexpectedStatus as e:
116
+ if e.status_code == 404 and settings.environment != "production":
117
+ try:
118
+ response = get_model_deployment.sync_detailed(
119
+ bl_agent.model, "production", client=client
120
+ )
121
+ settings.agent.model = response.parsed
122
+ except UnexpectedStatus as e:
123
+ if e.status_code == 404:
124
+ raise ValueError(f"Model {bl_agent.model} not found")
125
+ else:
126
+ raise e
127
+ chat_model = get_chat_model(settings.agent.model)
128
+ settings.agent.chat_model = chat_model
129
+ runtime = settings.agent.model.runtime
130
+ logger.info(f"Chat model configured, using: {runtime.type_}:{runtime.model}")
131
+
132
+ if len(functions) == 0:
133
+ raise ValueError(
134
+ "You must define at least one function, you can define this function in directory "
135
+ f'"{settings.agent.functions_directory}". Here is a sample function you can use:\n\n'
136
+ "from beamlit.functions import function\n\n"
137
+ "@function()\n"
138
+ "def hello_world(query: str):\n"
139
+ " return 'Hello, world!'\n"
140
+ )
141
+
142
+ if agent is None and chat_model is not None:
143
+ memory = MemorySaver()
144
+ agent = create_react_agent(chat_model, functions, checkpointer=memory)
145
+ settings.agent.agent = agent
146
+
147
+ return wrapper
@@ -6,12 +6,13 @@ import httpx
6
6
  from ... import errors
7
7
  from ...client import AuthenticatedClient, Client
8
8
  from ...models.agent import Agent
9
+ from ...models.agent_with_deployments import AgentWithDeployments
9
10
  from ...types import Response
10
11
 
11
12
 
12
13
  def _get_kwargs(
13
14
  *,
14
- body: Agent,
15
+ body: AgentWithDeployments,
15
16
  ) -> dict[str, Any]:
16
17
  headers: dict[str, Any] = {}
17
18
 
@@ -52,12 +53,13 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt
52
53
  def sync_detailed(
53
54
  *,
54
55
  client: AuthenticatedClient,
55
- body: Agent,
56
+ body: AgentWithDeployments,
56
57
  ) -> Response[Agent]:
57
58
  """Create agent by name
58
59
 
59
60
  Args:
60
- body (Agent): Agent parent of AgentDeployment
61
+ body (AgentWithDeployments): Logical object representing an agent but with deployment
62
+ definition inside
61
63
 
62
64
  Raises:
63
65
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -81,12 +83,13 @@ def sync_detailed(
81
83
  def sync(
82
84
  *,
83
85
  client: AuthenticatedClient,
84
- body: Agent,
86
+ body: AgentWithDeployments,
85
87
  ) -> Optional[Agent]:
86
88
  """Create agent by name
87
89
 
88
90
  Args:
89
- body (Agent): Agent parent of AgentDeployment
91
+ body (AgentWithDeployments): Logical object representing an agent but with deployment
92
+ definition inside
90
93
 
91
94
  Raises:
92
95
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -105,12 +108,13 @@ def sync(
105
108
  async def asyncio_detailed(
106
109
  *,
107
110
  client: AuthenticatedClient,
108
- body: Agent,
111
+ body: AgentWithDeployments,
109
112
  ) -> Response[Agent]:
110
113
  """Create agent by name
111
114
 
112
115
  Args:
113
- body (Agent): Agent parent of AgentDeployment
116
+ body (AgentWithDeployments): Logical object representing an agent but with deployment
117
+ definition inside
114
118
 
115
119
  Raises:
116
120
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -132,12 +136,13 @@ async def asyncio_detailed(
132
136
  async def asyncio(
133
137
  *,
134
138
  client: AuthenticatedClient,
135
- body: Agent,
139
+ body: AgentWithDeployments,
136
140
  ) -> Optional[Agent]:
137
141
  """Create agent by name
138
142
 
139
143
  Args:
140
- body (Agent): Agent parent of AgentDeployment
144
+ body (AgentWithDeployments): Logical object representing an agent but with deployment
145
+ definition inside
141
146
 
142
147
  Raises:
143
148
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -0,0 +1,159 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.agent_history import AgentHistory
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ agent_name: str,
14
+ request_id: str,
15
+ ) -> dict[str, Any]:
16
+ _kwargs: dict[str, Any] = {
17
+ "method": "delete",
18
+ "url": f"/agents/{agent_name}/history/{request_id}",
19
+ }
20
+
21
+ return _kwargs
22
+
23
+
24
+ def _parse_response(
25
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
26
+ ) -> Optional[AgentHistory]:
27
+ if response.status_code == 200:
28
+ response_200 = AgentHistory.from_dict(response.json())
29
+
30
+ return response_200
31
+ if client.raise_on_unexpected_status:
32
+ raise errors.UnexpectedStatus(response.status_code, response.content)
33
+ else:
34
+ return None
35
+
36
+
37
+ def _build_response(
38
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
39
+ ) -> Response[AgentHistory]:
40
+ return Response(
41
+ status_code=HTTPStatus(response.status_code),
42
+ content=response.content,
43
+ headers=response.headers,
44
+ parsed=_parse_response(client=client, response=response),
45
+ )
46
+
47
+
48
+ def sync_detailed(
49
+ agent_name: str,
50
+ request_id: str,
51
+ *,
52
+ client: AuthenticatedClient,
53
+ ) -> Response[AgentHistory]:
54
+ """
55
+ Args:
56
+ agent_name (str):
57
+ request_id (str):
58
+
59
+ Raises:
60
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
61
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
62
+
63
+ Returns:
64
+ Response[AgentHistory]
65
+ """
66
+
67
+ kwargs = _get_kwargs(
68
+ agent_name=agent_name,
69
+ request_id=request_id,
70
+ )
71
+
72
+ response = client.get_httpx_client().request(
73
+ **kwargs,
74
+ )
75
+
76
+ return _build_response(client=client, response=response)
77
+
78
+
79
+ def sync(
80
+ agent_name: str,
81
+ request_id: str,
82
+ *,
83
+ client: AuthenticatedClient,
84
+ ) -> Optional[AgentHistory]:
85
+ """
86
+ Args:
87
+ agent_name (str):
88
+ request_id (str):
89
+
90
+ Raises:
91
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
92
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
93
+
94
+ Returns:
95
+ AgentHistory
96
+ """
97
+
98
+ return sync_detailed(
99
+ agent_name=agent_name,
100
+ request_id=request_id,
101
+ client=client,
102
+ ).parsed
103
+
104
+
105
+ async def asyncio_detailed(
106
+ agent_name: str,
107
+ request_id: str,
108
+ *,
109
+ client: AuthenticatedClient,
110
+ ) -> Response[AgentHistory]:
111
+ """
112
+ Args:
113
+ agent_name (str):
114
+ request_id (str):
115
+
116
+ Raises:
117
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
118
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
119
+
120
+ Returns:
121
+ Response[AgentHistory]
122
+ """
123
+
124
+ kwargs = _get_kwargs(
125
+ agent_name=agent_name,
126
+ request_id=request_id,
127
+ )
128
+
129
+ response = await client.get_async_httpx_client().request(**kwargs)
130
+
131
+ return _build_response(client=client, response=response)
132
+
133
+
134
+ async def asyncio(
135
+ agent_name: str,
136
+ request_id: str,
137
+ *,
138
+ client: AuthenticatedClient,
139
+ ) -> Optional[AgentHistory]:
140
+ """
141
+ Args:
142
+ agent_name (str):
143
+ request_id (str):
144
+
145
+ Raises:
146
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
147
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
148
+
149
+ Returns:
150
+ AgentHistory
151
+ """
152
+
153
+ return (
154
+ await asyncio_detailed(
155
+ agent_name=agent_name,
156
+ request_id=request_id,
157
+ client=client,
158
+ )
159
+ ).parsed
@@ -1,5 +1,5 @@
1
1
  from http import HTTPStatus
2
- from typing import Any, List, Optional, Union
2
+ from typing import Any, Optional, Union
3
3
 
4
4
  import httpx
5
5
 
@@ -23,7 +23,7 @@ def _get_kwargs(
23
23
 
24
24
  def _parse_response(
25
25
  *, client: Union[AuthenticatedClient, Client], response: httpx.Response
26
- ) -> Optional[List["ResourceDeploymentLog"]]:
26
+ ) -> Optional[list["ResourceDeploymentLog"]]:
27
27
  if response.status_code == 200:
28
28
  response_200 = []
29
29
  _response_200 = response.json()
@@ -41,7 +41,7 @@ def _parse_response(
41
41
 
42
42
  def _build_response(
43
43
  *, client: Union[AuthenticatedClient, Client], response: httpx.Response
44
- ) -> Response[List["ResourceDeploymentLog"]]:
44
+ ) -> Response[list["ResourceDeploymentLog"]]:
45
45
  return Response(
46
46
  status_code=HTTPStatus(response.status_code),
47
47
  content=response.content,
@@ -55,7 +55,7 @@ def sync_detailed(
55
55
  environment_name: str,
56
56
  *,
57
57
  client: AuthenticatedClient,
58
- ) -> Response[List["ResourceDeploymentLog"]]:
58
+ ) -> Response[list["ResourceDeploymentLog"]]:
59
59
  """
60
60
  Args:
61
61
  agent_name (str):
@@ -66,7 +66,7 @@ def sync_detailed(
66
66
  httpx.TimeoutException: If the request takes longer than Client.timeout.
67
67
 
68
68
  Returns:
69
- Response[List['ResourceDeploymentLog']]
69
+ Response[list['ResourceDeploymentLog']]
70
70
  """
71
71
 
72
72
  kwargs = _get_kwargs(
@@ -86,7 +86,7 @@ def sync(
86
86
  environment_name: str,
87
87
  *,
88
88
  client: AuthenticatedClient,
89
- ) -> Optional[List["ResourceDeploymentLog"]]:
89
+ ) -> Optional[list["ResourceDeploymentLog"]]:
90
90
  """
91
91
  Args:
92
92
  agent_name (str):
@@ -97,7 +97,7 @@ def sync(
97
97
  httpx.TimeoutException: If the request takes longer than Client.timeout.
98
98
 
99
99
  Returns:
100
- List['ResourceDeploymentLog']
100
+ list['ResourceDeploymentLog']
101
101
  """
102
102
 
103
103
  return sync_detailed(
@@ -112,7 +112,7 @@ async def asyncio_detailed(
112
112
  environment_name: str,
113
113
  *,
114
114
  client: AuthenticatedClient,
115
- ) -> Response[List["ResourceDeploymentLog"]]:
115
+ ) -> Response[list["ResourceDeploymentLog"]]:
116
116
  """
117
117
  Args:
118
118
  agent_name (str):
@@ -123,7 +123,7 @@ async def asyncio_detailed(
123
123
  httpx.TimeoutException: If the request takes longer than Client.timeout.
124
124
 
125
125
  Returns:
126
- Response[List['ResourceDeploymentLog']]
126
+ Response[list['ResourceDeploymentLog']]
127
127
  """
128
128
 
129
129
  kwargs = _get_kwargs(
@@ -141,7 +141,7 @@ async def asyncio(
141
141
  environment_name: str,
142
142
  *,
143
143
  client: AuthenticatedClient,
144
- ) -> Optional[List["ResourceDeploymentLog"]]:
144
+ ) -> Optional[list["ResourceDeploymentLog"]]:
145
145
  """
146
146
  Args:
147
147
  agent_name (str):
@@ -152,7 +152,7 @@ async def asyncio(
152
152
  httpx.TimeoutException: If the request takes longer than Client.timeout.
153
153
 
154
154
  Returns:
155
- List['ResourceDeploymentLog']
155
+ list['ResourceDeploymentLog']
156
156
  """
157
157
 
158
158
  return (