|
12 | 12 | LlamaCliChatRequest, |
13 | 13 | BatchLlamaCliInitRequest, |
14 | 14 | BatchLlamaCliRemoveRequest, |
15 | | - BatchLlamaCliChatRequest |
| 15 | + BatchLlamaCliChatRequest, |
| 16 | + BatchLlamaCliStatusRequest |
16 | 17 | ) |
17 | 18 |
|
18 | 19 | from lib.endpoints.chat_endpoints import ChatRequest, MultiChatRequest |
|
46 | 47 | chat_with_llama_cli_session, |
47 | 48 | handle_initialize_batch_llama_cli_configs, |
48 | 49 | handle_remove_batch_llama_cli_configs, |
49 | | - handle_batch_chat_with_llama_cli |
| 50 | + handle_batch_chat_with_llama_cli, |
| 51 | + handle_get_batch_llama_cli_status |
50 | 52 | ) |
51 | 53 |
|
52 | 54 | # --- Logging Configuration --- |
@@ -628,6 +630,33 @@ async def get_llama_cli_status_endpoint(cli_alias: str = Path(..., description=" |
628 | 630 | logger.error(f"Unexpected error in /llama-cli-status for alias {cli_alias}: {str(e)}", exc_info=True) |
629 | 631 | raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=f"An unexpected error occurred: {str(e)}") |
630 | 632 |
|
| 633 | +@app.post( |
| 634 | + "/batch-llama-cli-status", |
| 635 | + summary="Get Status of Multiple Llama CLI Sessions", |
| 636 | + tags=["Llama CLI Management"], |
| 637 | + operation_id="get_batch_llama_cli_session_status" |
| 638 | +) |
| 639 | +async def batch_llama_cli_status(request: BatchLlamaCliStatusRequest): |
| 640 | + """ |
| 641 | + Retrieves the status of multiple `llama-cli` sessions in a single batch request. |
| 642 | +
|
| 643 | + **Request Body**: |
| 644 | + - `BatchLlamaCliStatusRequest`: A JSON object containing a list of `aliases` (strings) |
| 645 | + of the `llama-cli` sessions to check. |
| 646 | +
|
| 647 | + **Successful Response (200 OK)**: |
| 648 | + - A JSON list where each item corresponds to an alias in the request, detailing its |
| 649 | + status (running/stopped), PID (if running), and configuration. |
| 650 | +
|
| 651 | + **Error Responses**: |
| 652 | + - `500 Internal Server Error`: If an unexpected error occurs during the batch processing logic. |
| 653 | + """ |
| 654 | + try: |
| 655 | + return await handle_get_batch_llama_cli_status(request) |
| 656 | + except Exception as e: |
| 657 | + logger.error(f"Error in /batch-llama-cli-status endpoint: {str(e)}", exc_info=True) |
| 658 | + raise HTTPException(status_code=500, detail=f"An unexpected error occurred while fetching batch CLI status: {str(e)}") |
| 659 | + |
631 | 660 | @app.post( |
632 | 661 | "/chat-llama-cli", |
633 | 662 | summary="Chat with a Persistent Llama CLI Session", |
|
0 commit comments