control_plane
#
BaseControlPlane #
Bases: MessageQueuePublisherMixin
, ABC
The control plane for the system.
The control plane is responsible for managing the state of the system, including: - Registering services. - Managing sessions and tasks. - Handling service completion. - Launching the control plane server.
Source code in llama_deploy/control_plane/base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
message_queue
abstractmethod
property
#
message_queue: BaseMessageQueue
Return associated message queue.
as_consumer
abstractmethod
#
as_consumer(remote: bool = False) -> BaseMessageQueueConsumer
Get the consumer for the message queue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remote |
bool
|
Whether the consumer is remote. If True, the consumer will be a RemoteMessageConsumer. |
False
|
Returns:
Name | Type | Description |
---|---|---|
BaseMessageQueueConsumer |
BaseMessageQueueConsumer
|
Message queue consumer. |
Source code in llama_deploy/control_plane/base.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
register_service
abstractmethod
async
#
register_service(service_def: ServiceDefinition) -> None
Register a service with the control plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_def |
ServiceDefinition
|
Definition of the service. |
required |
Source code in llama_deploy/control_plane/base.py
48 49 50 51 52 53 54 55 56 |
|
deregister_service
abstractmethod
async
#
deregister_service(service_name: str) -> None
Deregister a service from the control plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
Name of the service. |
required |
Source code in llama_deploy/control_plane/base.py
58 59 60 61 62 63 64 65 66 |
|
get_service
abstractmethod
async
#
get_service(service_name: str) -> ServiceDefinition
Get the definition of a service by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
Name of the service. |
required |
Returns:
Name | Type | Description |
---|---|---|
ServiceDefinition |
ServiceDefinition
|
Definition of the service. |
Source code in llama_deploy/control_plane/base.py
68 69 70 71 72 73 74 75 76 77 78 79 |
|
get_all_services
abstractmethod
async
#
get_all_services() -> Dict[str, ServiceDefinition]
Get all services registered with the control plane.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, ServiceDefinition]
|
All services, mapped from service name to service definition. |
Source code in llama_deploy/control_plane/base.py
81 82 83 84 85 86 87 88 89 |
|
create_session
abstractmethod
async
#
create_session() -> str
Create a new session.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Session ID. |
Source code in llama_deploy/control_plane/base.py
91 92 93 94 95 96 97 98 99 |
|
add_task_to_session
abstractmethod
async
#
add_task_to_session(session_id: str, task_def: TaskDefinition) -> str
Add a task to an existing session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
ID of the session. |
required |
task_def |
TaskDefinition
|
Definition of the task. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Task ID. |
Source code in llama_deploy/control_plane/base.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
send_task_to_service
abstractmethod
async
#
send_task_to_service(task_def: TaskDefinition) -> TaskDefinition
Send a task to a service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_def |
TaskDefinition
|
Definition of the task. |
required |
Returns:
Name | Type | Description |
---|---|---|
TaskDefinition |
TaskDefinition
|
Task definition with updated state. |
Source code in llama_deploy/control_plane/base.py
117 118 119 120 121 122 123 124 125 126 127 128 |
|
handle_service_completion
abstractmethod
async
#
handle_service_completion(task_result: TaskResult) -> None
Handle the completion of a task by a service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_result |
TaskResult
|
Result of the task. |
required |
Source code in llama_deploy/control_plane/base.py
130 131 132 133 134 135 136 137 138 139 140 141 |
|
get_session
abstractmethod
async
#
get_session(session_id: str) -> SessionDefinition
Get the specified session session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique identifier of the session. |
required |
Returns:
Name | Type | Description |
---|---|---|
SessionDefinition |
SessionDefinition
|
The session definition. |
Source code in llama_deploy/control_plane/base.py
143 144 145 146 147 148 149 150 151 152 153 154 |
|
delete_session
abstractmethod
async
#
delete_session(session_id: str) -> None
Delete the specified session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique identifier of the session. |
required |
Source code in llama_deploy/control_plane/base.py
156 157 158 159 160 161 162 163 164 |
|
get_all_sessions
abstractmethod
async
#
get_all_sessions() -> Dict[str, SessionDefinition]
Get all sessions.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, SessionDefinition]
|
All sessions, mapped from session ID to session definition. |
Source code in llama_deploy/control_plane/base.py
166 167 168 169 170 171 172 173 174 |
|
get_session_tasks
abstractmethod
async
#
get_session_tasks(session_id: str) -> List[TaskDefinition]
Get all tasks for a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique identifier of the session. |
required |
Returns:
Type | Description |
---|---|
List[TaskDefinition]
|
List[TaskDefinition]: All tasks in the session. |
Source code in llama_deploy/control_plane/base.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
get_current_task
abstractmethod
async
#
get_current_task(session_id: str) -> Optional[TaskDefinition]
Get the current task for a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique identifier of the session. |
required |
Returns:
Type | Description |
---|---|
Optional[TaskDefinition]
|
Optional[TaskDefinition]: The current task, if any. |
Source code in llama_deploy/control_plane/base.py
189 190 191 192 193 194 195 196 197 198 199 200 |
|
get_task
abstractmethod
async
#
get_task(task_id: str) -> TaskDefinition
Get the specified task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
str
|
Unique identifier of the task. |
required |
Returns:
Name | Type | Description |
---|---|---|
TaskDefinition |
TaskDefinition
|
The task definition. |
Source code in llama_deploy/control_plane/base.py
202 203 204 205 206 207 208 209 210 211 212 213 |
|
get_message_queue_config
abstractmethod
async
#
get_message_queue_config() -> Dict[str, dict]
Gets the config dict for the message queue being used.
Returns:
Type | Description |
---|---|
Dict[str, dict]
|
Dict[str, dict]: A dict of message queue name -> config dict |
Source code in llama_deploy/control_plane/base.py
215 216 217 218 219 220 221 222 223 |
|
launch_server
abstractmethod
async
#
launch_server() -> None
Launch the control plane server.
Source code in llama_deploy/control_plane/base.py
225 226 227 228 229 230 |
|
register_to_message_queue
abstractmethod
async
#
register_to_message_queue() -> StartConsumingCallable
Register the service to the message queue.
Source code in llama_deploy/control_plane/base.py
232 233 234 |
|
ControlPlaneServer #
Bases: BaseControlPlane
Control plane server.
The control plane is responsible for managing the state of the system, including: - Registering services. - Submitting tasks. - Managing task state. - Handling service completion. - Launching the control plane server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_queue |
BaseMessageQueue
|
Message queue for the system. |
required |
orchestrator |
BaseOrchestrator
|
Orchestrator for the system. |
required |
publish_callback |
Optional[PublishCallback]
|
Callback for publishing messages. Defaults to None. |
None
|
state_store |
Optional[BaseKVStore]
|
State store for the system. Defaults to None. |
None
|
services_store_key |
str
|
Key for the services store. Defaults to "services". |
'services'
|
tasks_store_key |
str
|
Key for the tasks store. Defaults to "tasks". |
'tasks'
|
step_interval |
float
|
The interval in seconds to poll for tool call results. Defaults to 0.1s. |
0.1
|
host |
str
|
The host of the service. Defaults to "127.0.0.1". |
'127.0.0.1'
|
port |
Optional[int]
|
The port of the service. Defaults to 8000. |
8000
|
internal_host |
Optional[str]
|
The host for external networking as in Docker-Compose or K8s. |
None
|
internal_port |
Optional[int]
|
The port for external networking as in Docker-Compose or K8s. |
None
|
running |
bool
|
Whether the service is running. Defaults to True. |
True
|
Examples:
from llama_deploy import ControlPlaneServer
from llama_deploy import SimpleMessageQueue, SimpleOrchestrator
from llama_index.llms.openai import OpenAI
control_plane = ControlPlaneServer(
SimpleMessageQueue(),
SimpleOrchestrator(),
)
Source code in llama_deploy/control_plane/server.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
|
get_task_result
async
#
get_task_result(task_id: str, session_id: str) -> Optional[TaskResult]
Get the result of a task if it has one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
str
|
The ID of the task to get the result for. |
required |
session_id |
str
|
The ID of the session the task belongs to. |
required |
Returns:
Type | Description |
---|---|
Optional[TaskResult]
|
Optional[TaskResult]: The result of the task if it has one, otherwise None. |
Source code in llama_deploy/control_plane/server.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
|
get_message_queue_config
async
#
get_message_queue_config() -> Dict[str, dict]
Gets the config dict for the message queue being used.
Returns:
Type | Description |
---|---|
Dict[str, dict]
|
Dict[str, dict]: A dict of message queue name -> config dict |
Source code in llama_deploy/control_plane/server.py
582 583 584 585 586 587 588 589 590 |
|
ControlPlaneConfig #
Bases: BaseSettings
Control plane configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state_store |
BaseKVStore | None
|
|
None
|
services_store_key |
str
|
|
'services'
|
tasks_store_key |
str
|
|
'tasks'
|
session_store_key |
str
|
|
'sessions'
|
step_interval |
float
|
|
0.1
|
host |
str
|
|
'127.0.0.1'
|
port |
int | None
|
|
8000
|
internal_host |
str | None
|
|
None
|
internal_port |
int | None
|
|
None
|
running |
bool
|
|
True
|
Source code in llama_deploy/control_plane/server.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|