digitalkin 0.2.23__py3-none-any.whl → 0.3.1.dev2__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 (78) hide show
  1. digitalkin/__version__.py +1 -1
  2. digitalkin/core/__init__.py +1 -0
  3. digitalkin/core/common/__init__.py +9 -0
  4. digitalkin/core/common/factories.py +156 -0
  5. digitalkin/core/job_manager/__init__.py +1 -0
  6. digitalkin/{modules → core}/job_manager/base_job_manager.py +137 -31
  7. digitalkin/core/job_manager/single_job_manager.py +354 -0
  8. digitalkin/{modules → core}/job_manager/taskiq_broker.py +116 -22
  9. digitalkin/core/job_manager/taskiq_job_manager.py +541 -0
  10. digitalkin/core/task_manager/__init__.py +1 -0
  11. digitalkin/core/task_manager/base_task_manager.py +539 -0
  12. digitalkin/core/task_manager/local_task_manager.py +108 -0
  13. digitalkin/core/task_manager/remote_task_manager.py +87 -0
  14. digitalkin/core/task_manager/surrealdb_repository.py +266 -0
  15. digitalkin/core/task_manager/task_executor.py +249 -0
  16. digitalkin/core/task_manager/task_session.py +406 -0
  17. digitalkin/grpc_servers/__init__.py +1 -19
  18. digitalkin/grpc_servers/_base_server.py +3 -3
  19. digitalkin/grpc_servers/module_server.py +27 -43
  20. digitalkin/grpc_servers/module_servicer.py +51 -36
  21. digitalkin/grpc_servers/registry_server.py +2 -2
  22. digitalkin/grpc_servers/registry_servicer.py +4 -4
  23. digitalkin/grpc_servers/utils/__init__.py +1 -0
  24. digitalkin/grpc_servers/utils/exceptions.py +0 -8
  25. digitalkin/grpc_servers/utils/grpc_client_wrapper.py +4 -4
  26. digitalkin/grpc_servers/utils/grpc_error_handler.py +53 -0
  27. digitalkin/logger.py +73 -24
  28. digitalkin/mixins/__init__.py +19 -0
  29. digitalkin/mixins/base_mixin.py +10 -0
  30. digitalkin/mixins/callback_mixin.py +24 -0
  31. digitalkin/mixins/chat_history_mixin.py +110 -0
  32. digitalkin/mixins/cost_mixin.py +76 -0
  33. digitalkin/mixins/file_history_mixin.py +93 -0
  34. digitalkin/mixins/filesystem_mixin.py +46 -0
  35. digitalkin/mixins/logger_mixin.py +51 -0
  36. digitalkin/mixins/storage_mixin.py +79 -0
  37. digitalkin/models/core/__init__.py +1 -0
  38. digitalkin/{modules/job_manager → models/core}/job_manager_models.py +3 -3
  39. digitalkin/models/core/task_monitor.py +70 -0
  40. digitalkin/models/grpc_servers/__init__.py +1 -0
  41. digitalkin/{grpc_servers/utils → models/grpc_servers}/models.py +5 -5
  42. digitalkin/models/module/__init__.py +2 -0
  43. digitalkin/models/module/module.py +9 -1
  44. digitalkin/models/module/module_context.py +122 -6
  45. digitalkin/models/module/module_types.py +307 -19
  46. digitalkin/models/services/__init__.py +9 -0
  47. digitalkin/models/services/cost.py +1 -0
  48. digitalkin/models/services/storage.py +39 -5
  49. digitalkin/modules/_base_module.py +123 -118
  50. digitalkin/modules/tool_module.py +10 -2
  51. digitalkin/modules/trigger_handler.py +7 -6
  52. digitalkin/services/cost/__init__.py +9 -2
  53. digitalkin/services/cost/grpc_cost.py +9 -42
  54. digitalkin/services/filesystem/default_filesystem.py +0 -2
  55. digitalkin/services/filesystem/grpc_filesystem.py +10 -39
  56. digitalkin/services/setup/default_setup.py +5 -6
  57. digitalkin/services/setup/grpc_setup.py +52 -15
  58. digitalkin/services/storage/grpc_storage.py +4 -4
  59. digitalkin/services/user_profile/__init__.py +1 -0
  60. digitalkin/services/user_profile/default_user_profile.py +55 -0
  61. digitalkin/services/user_profile/grpc_user_profile.py +69 -0
  62. digitalkin/services/user_profile/user_profile_strategy.py +40 -0
  63. digitalkin/utils/__init__.py +28 -0
  64. digitalkin/utils/arg_parser.py +1 -1
  65. digitalkin/utils/development_mode_action.py +2 -2
  66. digitalkin/utils/dynamic_schema.py +483 -0
  67. digitalkin/utils/package_discover.py +1 -2
  68. {digitalkin-0.2.23.dist-info → digitalkin-0.3.1.dev2.dist-info}/METADATA +11 -30
  69. digitalkin-0.3.1.dev2.dist-info/RECORD +119 -0
  70. modules/dynamic_setup_module.py +362 -0
  71. digitalkin/grpc_servers/utils/factory.py +0 -180
  72. digitalkin/modules/job_manager/single_job_manager.py +0 -294
  73. digitalkin/modules/job_manager/taskiq_job_manager.py +0 -290
  74. digitalkin-0.2.23.dist-info/RECORD +0 -89
  75. /digitalkin/{grpc_servers/utils → models/grpc_servers}/types.py +0 -0
  76. {digitalkin-0.2.23.dist-info → digitalkin-0.3.1.dev2.dist-info}/WHEEL +0 -0
  77. {digitalkin-0.2.23.dist-info → digitalkin-0.3.1.dev2.dist-info}/licenses/LICENSE +0 -0
  78. {digitalkin-0.2.23.dist-info → digitalkin-0.3.1.dev2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,362 @@
1
+ """Example module demonstrating dynamic schema fields in SetupModel.
2
+
3
+ This example shows how to use the Dynamic metadata class with async fetchers
4
+ to populate field schemas (like enums) at runtime. This is useful when the
5
+ available options come from external sources like databases or APIs.
6
+
7
+ Usage:
8
+ # Start the module server
9
+ python examples/modules/dynamic_setup_module.py
10
+
11
+ # Or import and use in your own code
12
+ from examples.modules.dynamic_setup_module import DynamicSetupModule
13
+ """
14
+
15
+ import asyncio
16
+ import logging
17
+ from typing import Annotated, Any, ClassVar
18
+
19
+ from pydantic import BaseModel, Field
20
+
21
+ from digitalkin.models.module.module_context import ModuleContext
22
+ from digitalkin.models.module.module_types import DataModel, DataTrigger, SetupModel
23
+ from digitalkin.modules._base_module import BaseModule
24
+ from digitalkin.services.services_models import ServicesStrategy
25
+ from digitalkin.utils import Dynamic
26
+
27
+ # Configure logging
28
+ logging.basicConfig(
29
+ level=logging.DEBUG,
30
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
31
+ )
32
+ logger = logging.getLogger(__name__)
33
+
34
+
35
+ # =============================================================================
36
+ # Simulated External Services (replace with real implementations)
37
+ # =============================================================================
38
+
39
+
40
+ class MockModelRegistry:
41
+ """Simulates an external model registry service.
42
+
43
+ In a real application, this would be a connection to a database,
44
+ API service, or configuration management system.
45
+ """
46
+
47
+ _models: ClassVar[list[str]] = ["gpt-4", "gpt-4-turbo", "gpt-3.5-turbo"]
48
+ _languages: ClassVar[list[str]] = ["en", "fr", "de", "es", "it", "pt"]
49
+
50
+ @classmethod
51
+ async def fetch_available_models(cls) -> list[str]:
52
+ """Fetch available models from the registry.
53
+
54
+ Simulates an async API call with a small delay.
55
+ """
56
+ await asyncio.sleep(0.1) # Simulate network latency
57
+ logger.info("Fetched %d models from registry", len(cls._models))
58
+ return cls._models.copy()
59
+
60
+ @classmethod
61
+ async def fetch_supported_languages(cls) -> list[str]:
62
+ """Fetch supported languages from the registry."""
63
+ await asyncio.sleep(0.05) # Simulate network latency
64
+ logger.info("Fetched %d languages from registry", len(cls._languages))
65
+ return cls._languages.copy()
66
+
67
+ @classmethod
68
+ def get_default_model(cls) -> str:
69
+ """Get the default model (sync fetcher example)."""
70
+ return cls._models[0] if cls._models else "gpt-4"
71
+
72
+
73
+ # =============================================================================
74
+ # Dynamic Fetcher Functions
75
+ # =============================================================================
76
+
77
+
78
+ async def fetch_models() -> list[str]:
79
+ """Async fetcher for available model names.
80
+
81
+ This function is called when SetupModel.get_clean_model(force=True)
82
+ is invoked, typically during module initialization or schema refresh.
83
+ """
84
+ return await MockModelRegistry.fetch_available_models()
85
+
86
+
87
+ async def fetch_languages() -> list[str]:
88
+ """Async fetcher for supported languages."""
89
+ return await MockModelRegistry.fetch_supported_languages()
90
+
91
+
92
+ def get_temperature_range() -> dict[str, float]:
93
+ """Sync fetcher example returning min/max for temperature.
94
+
95
+ Demonstrates that fetchers can return any JSON-serializable value,
96
+ not just lists for enums.
97
+ """
98
+ return {"minimum": 0.0, "maximum": 2.0}
99
+
100
+
101
+ # =============================================================================
102
+ # Setup Model with Dynamic Fields
103
+ # =============================================================================
104
+
105
+
106
+ class DynamicAgentSetup(SetupModel):
107
+ """Setup model demonstrating dynamic schema fields.
108
+
109
+ Fields marked with Dynamic(...) will have their schema values
110
+ refreshed at runtime when get_clean_model(force=True) is called.
111
+
112
+ Attributes:
113
+ model_name: The LLM model to use. Enum values fetched from registry.
114
+ language: Output language. Enum values fetched dynamically.
115
+ temperature: Sampling temperature. Static field for comparison.
116
+ max_tokens: Maximum tokens to generate.
117
+ system_prompt: The system prompt for the model.
118
+ """
119
+
120
+ # Dynamic field: enum values fetched asynchronously from model registry
121
+ model_name: Annotated[str, Dynamic(enum=fetch_models)] = Field(
122
+ default="gpt-4",
123
+ title="Model Name",
124
+ description="The LLM model to use for generation.",
125
+ json_schema_extra={
126
+ "config": True, # Shown in initial configuration
127
+ "ui:widget": "select",
128
+ },
129
+ )
130
+
131
+ # Dynamic field: language options fetched asynchronously
132
+ language: Annotated[str, Dynamic(enum=fetch_languages)] = Field(
133
+ default="en",
134
+ title="Output Language",
135
+ description="The language for generated responses.",
136
+ json_schema_extra={
137
+ "config": True,
138
+ "ui:widget": "select",
139
+ },
140
+ )
141
+
142
+ # Static field: no dynamic fetcher, values defined at class time
143
+ temperature: float = Field(
144
+ default=0.7,
145
+ ge=0.0,
146
+ le=2.0,
147
+ title="Temperature",
148
+ description="Controls randomness. Higher values = more creative.",
149
+ json_schema_extra={"config": True},
150
+ )
151
+
152
+ # Static field with hidden flag (runtime-only, not in initial config)
153
+ max_tokens: int = Field(
154
+ default=1024,
155
+ ge=1,
156
+ le=4096,
157
+ title="Max Tokens",
158
+ description="Maximum tokens in the response.",
159
+ json_schema_extra={"hidden": True},
160
+ )
161
+
162
+ # Static field without any special flags
163
+ system_prompt: str = Field(
164
+ default="You are a helpful assistant.",
165
+ title="System Prompt",
166
+ description="The system prompt defining assistant behavior.",
167
+ )
168
+
169
+
170
+ # =============================================================================
171
+ # Input/Output Models (Using DataModel/DataTrigger pattern)
172
+ # =============================================================================
173
+
174
+
175
+ class MessageInputTrigger(DataTrigger):
176
+ """Message input trigger following DigitalKin DataTrigger pattern.
177
+
178
+ The protocol field determines which trigger handler processes this input.
179
+ """
180
+
181
+ protocol: str = "message"
182
+ content: str = Field(default="", description="The user message content.")
183
+
184
+
185
+ class DynamicModuleInput(DataModel[MessageInputTrigger]):
186
+ """Input model following DigitalKin DataModel pattern.
187
+
188
+ Wraps the trigger in a root field with optional annotations.
189
+ """
190
+
191
+ root: MessageInputTrigger = Field(default_factory=MessageInputTrigger)
192
+
193
+
194
+ class MessageOutputTrigger(DataTrigger):
195
+ """Message output trigger following DigitalKin DataTrigger pattern."""
196
+
197
+ protocol: str = "message"
198
+ content: str = Field(default="", description="The generated response.")
199
+ model_used: str = Field(default="", description="The model that generated this response.")
200
+ language: str = Field(default="", description="The output language.")
201
+
202
+
203
+ class DynamicModuleOutput(DataModel[MessageOutputTrigger]):
204
+ """Output model following DigitalKin DataModel pattern."""
205
+
206
+ root: MessageOutputTrigger = Field(default_factory=MessageOutputTrigger)
207
+
208
+
209
+ class DynamicModuleSecret(BaseModel):
210
+ """Secret model (empty for this example)."""
211
+
212
+ pass
213
+
214
+
215
+ # =============================================================================
216
+ # Module Implementation
217
+ # =============================================================================
218
+
219
+
220
+ class DynamicSetupModule(
221
+ BaseModule[
222
+ DynamicModuleInput,
223
+ DynamicModuleOutput,
224
+ DynamicAgentSetup,
225
+ DynamicModuleSecret,
226
+ ]
227
+ ):
228
+ """Example module demonstrating dynamic schema in SetupModel.
229
+
230
+ This module shows how to:
231
+ 1. Define setup fields with Dynamic() metadata for runtime enum fetching
232
+ 2. Mix static and dynamic fields in the same SetupModel
233
+ 3. Use async fetchers that simulate external service calls
234
+ 4. Follow DigitalKin's DataModel/DataTrigger pattern for I/O
235
+
236
+ The key integration point is in the gRPC servicer, which calls
237
+ SetupModel.get_clean_model(force=True) to refresh dynamic values
238
+ before returning schema information to clients.
239
+ """
240
+
241
+ name = "DynamicSetupModule"
242
+ description = "Demonstrates dynamic schema fields in module setup"
243
+
244
+ # Schema format definitions
245
+ input_format = DynamicModuleInput
246
+ output_format = DynamicModuleOutput
247
+ setup_format = DynamicAgentSetup
248
+ secret_format = DynamicModuleSecret
249
+
250
+ # Module metadata
251
+ metadata: ClassVar[dict[str, Any]] = {
252
+ "name": "DynamicSetupModule",
253
+ "description": "Example module with dynamic setup schema",
254
+ "version": "1.0.0",
255
+ "tags": ["example", "dynamic-schema"],
256
+ }
257
+
258
+ # Services configuration (empty for this example)
259
+ services_config_strategies: ClassVar[dict[str, ServicesStrategy | None]] = {}
260
+ services_config_params: ClassVar[dict[str, dict[str, Any | None] | None]] = {}
261
+
262
+ async def initialize(self, context: ModuleContext, setup_data: DynamicAgentSetup) -> None:
263
+ """Initialize the module with setup data.
264
+
265
+ Args:
266
+ context: The module context with services and session info.
267
+ setup_data: The validated setup configuration.
268
+ """
269
+ logger.info(
270
+ "Initializing DynamicSetupModule with model=%s, language=%s",
271
+ setup_data.model_name,
272
+ setup_data.language,
273
+ )
274
+ self.setup = setup_data
275
+
276
+ async def cleanup(self) -> None:
277
+ """Clean up resources."""
278
+ logger.info("Cleaning up DynamicSetupModule")
279
+
280
+
281
+ # =============================================================================
282
+ # Demonstration Script
283
+ # =============================================================================
284
+
285
+
286
+ async def demonstrate_dynamic_schema() -> None:
287
+ """Demonstrate the dynamic schema functionality."""
288
+ print("=" * 60)
289
+ print("Dynamic Schema Demonstration")
290
+ print("=" * 60)
291
+
292
+ # 1. Show schema WITHOUT force (dynamic fields not resolved)
293
+ print("\n1. Schema without force=True (fetchers NOT called):")
294
+ print("-" * 40)
295
+
296
+ model_no_force = await DynamicAgentSetup.get_clean_model(
297
+ config_fields=True,
298
+ hidden_fields=False,
299
+ force=False,
300
+ )
301
+ schema_no_force = model_no_force.model_json_schema()
302
+
303
+ # Check if enum is present
304
+ model_name_schema = schema_no_force.get("properties", {}).get("model_name", {})
305
+ print(f"model_name has enum: {'enum' in model_name_schema}")
306
+ if "enum" in model_name_schema:
307
+ print(f" enum values: {model_name_schema['enum']}")
308
+
309
+ # 2. Show schema WITH force (dynamic fields resolved)
310
+ print("\n2. Schema with force=True (fetchers called):")
311
+ print("-" * 40)
312
+
313
+ model_with_force = await DynamicAgentSetup.get_clean_model(
314
+ config_fields=True,
315
+ hidden_fields=False,
316
+ force=True,
317
+ )
318
+ schema_with_force = model_with_force.model_json_schema()
319
+
320
+ # Check enum values after force
321
+ model_name_schema = schema_with_force.get("properties", {}).get("model_name", {})
322
+ print(f"model_name has enum: {'enum' in model_name_schema}")
323
+ if "enum" in model_name_schema:
324
+ print(f" enum values: {model_name_schema['enum']}")
325
+
326
+ language_schema = schema_with_force.get("properties", {}).get("language", {})
327
+ print(f"language has enum: {'enum' in language_schema}")
328
+ if "enum" in language_schema:
329
+ print(f" enum values: {language_schema['enum']}")
330
+
331
+ # 3. Show that static json_schema_extra is preserved
332
+ print("\n3. Static json_schema_extra preserved:")
333
+ print("-" * 40)
334
+ print(f"model_name ui:widget: {model_name_schema.get('ui:widget', 'NOT FOUND')}")
335
+
336
+ # 4. Show field filtering
337
+ print("\n4. Field filtering demonstration:")
338
+ print("-" * 40)
339
+
340
+ # Config fields only (hidden excluded)
341
+ config_model = await DynamicAgentSetup.get_clean_model(
342
+ config_fields=True,
343
+ hidden_fields=False,
344
+ force=False,
345
+ )
346
+ print(f"Config fields (hidden=False): {list(config_model.model_fields.keys())}")
347
+
348
+ # All fields including hidden
349
+ all_model = await DynamicAgentSetup.get_clean_model(
350
+ config_fields=True,
351
+ hidden_fields=True,
352
+ force=False,
353
+ )
354
+ print(f"All fields (hidden=True): {list(all_model.model_fields.keys())}")
355
+
356
+ print("\n" + "=" * 60)
357
+ print("Demonstration complete!")
358
+ print("=" * 60)
359
+
360
+
361
+ if __name__ == "__main__":
362
+ asyncio.run(demonstrate_dynamic_schema())
@@ -1,180 +0,0 @@
1
- """Factory functions for creating gRPC servers."""
2
-
3
- from pathlib import Path
4
- from typing import Any
5
-
6
- from digitalkin.grpc_servers.module_server import ModuleServer
7
- from digitalkin.grpc_servers.registry_server import RegistryServer
8
- from digitalkin.grpc_servers.utils.models import (
9
- ModuleServerConfig,
10
- RegistryServerConfig,
11
- SecurityMode,
12
- ServerCredentials,
13
- ServerMode,
14
- )
15
- from digitalkin.modules._base_module import BaseModule
16
-
17
-
18
- def create_module_server(
19
- module: type[BaseModule],
20
- host: str = "0.0.0.0", # noqa: S104
21
- port: int = 50051,
22
- max_workers: int = 10,
23
- mode: str = "sync",
24
- security: str = "insecure",
25
- registry_address: str | None = None,
26
- server_key_path: str | None = None,
27
- server_cert_path: str | None = None,
28
- root_cert_path: str | None = None,
29
- server_options: list[tuple[str, Any]] | None = None,
30
- ) -> ModuleServer:
31
- """Create a new module server.
32
-
33
- Args:
34
- module: The module to serve.
35
- host: The host address to bind to.
36
- port: The port to listen on.
37
- max_workers: Maximum number of workers for the thread pool (sync mode only).
38
- mode: Server mode ("sync" or "async").
39
- security: Security mode ("secure" or "insecure").
40
- registry_address: Optional address of a registry server for auto-registration.
41
- server_key_path: Path to server private key (required for secure mode).
42
- server_cert_path: Path to server certificate (required for secure mode).
43
- root_cert_path: Optional path to root certificate.
44
- server_options: Additional server options.
45
-
46
- Returns:
47
- A configured ModuleServer instance.
48
-
49
- Raises:
50
- ValueError: If secure mode is requested but credentials are missing.
51
- """
52
- # Create configuration with credentials if needed
53
- config = _create_server_config(
54
- ModuleServerConfig,
55
- host=host,
56
- port=port,
57
- max_workers=max_workers,
58
- mode=mode,
59
- security=security,
60
- server_key_path=server_key_path,
61
- server_cert_path=server_cert_path,
62
- root_cert_path=root_cert_path,
63
- server_options=server_options,
64
- registry_address=registry_address,
65
- )
66
-
67
- # Create and return the server
68
- return ModuleServer(module, config)
69
-
70
-
71
- def create_registry_server(
72
- host: str = "0.0.0.0", # noqa: S104
73
- port: int = 50052,
74
- max_workers: int = 10,
75
- mode: str = "sync",
76
- security: str = "insecure",
77
- database_url: str | None = None,
78
- server_key_path: str | None = None,
79
- server_cert_path: str | None = None,
80
- root_cert_path: str | None = None,
81
- server_options: list[tuple[str, Any]] | None = None,
82
- ) -> RegistryServer:
83
- """Create a new registry server.
84
-
85
- Args:
86
- host: The host address to bind to.
87
- port: The port to listen on.
88
- max_workers: Maximum number of workers for the thread pool (sync mode only).
89
- mode: Server mode ("sync" or "async").
90
- security: Security mode ("secure" or "insecure").
91
- database_url: Optional database URL for registry data storage.
92
- server_key_path: Path to server private key (required for secure mode).
93
- server_cert_path: Path to server certificate (required for secure mode).
94
- root_cert_path: Optional path to root certificate.
95
- server_options: Additional server options.
96
-
97
- Returns:
98
- A configured RegistryServer instance.
99
-
100
- Raises:
101
- ValueError: If secure mode is requested but credentials are missing.
102
- """
103
- # Create configuration with credentials if needed
104
- config = _create_server_config(
105
- RegistryServerConfig,
106
- host=host,
107
- port=port,
108
- max_workers=max_workers,
109
- mode=mode,
110
- security=security,
111
- server_key_path=server_key_path,
112
- server_cert_path=server_cert_path,
113
- root_cert_path=root_cert_path,
114
- server_options=server_options,
115
- database_url=database_url,
116
- )
117
-
118
- # Create and return the server
119
- return RegistryServer(config)
120
-
121
-
122
- def _create_server_config(
123
- config_class: Any,
124
- host: str,
125
- port: int,
126
- max_workers: int,
127
- mode: str,
128
- security: str,
129
- server_key_path: str | None,
130
- server_cert_path: str | None,
131
- root_cert_path: str | None,
132
- server_options: list[tuple[str, Any]] | None,
133
- **kwargs,
134
- ) -> ModuleServerConfig | RegistryServerConfig:
135
- """Create a server configuration with appropriate settings.
136
-
137
- Args:
138
- config_class: The configuration class to instantiate.
139
- host: The host address.
140
- port: The port number.
141
- max_workers: Maximum number of workers.
142
- mode: Server mode.
143
- security: Security mode.
144
- server_key_path: Path to server key.
145
- server_cert_path: Path to server certificate.
146
- root_cert_path: Path to root certificate.
147
- server_options: Additional server options.
148
- **kwargs: Additional configuration parameters.
149
-
150
- Returns:
151
- A server configuration instance.
152
-
153
- Raises:
154
- ValueError: If secure mode is requested but credentials are missing.
155
- """
156
- # Create basic config
157
- config_params = {
158
- "host": host,
159
- "port": port,
160
- "max_workers": max_workers,
161
- "mode": ServerMode(mode),
162
- "security": SecurityMode(security),
163
- "server_options": server_options or [],
164
- **kwargs,
165
- }
166
-
167
- # Add credentials if secure mode
168
- if security == "secure":
169
- if not server_key_path or not server_cert_path:
170
- raise ValueError(
171
- "Server key and certificate paths are required for secure mode"
172
- )
173
-
174
- config_params["credentials"] = ServerCredentials(
175
- server_key_path=Path(server_key_path),
176
- server_cert_path=Path(server_cert_path),
177
- root_cert_path=Path(root_cert_path) if root_cert_path else None,
178
- )
179
-
180
- return config_class(**config_params)