11from rich .console import Console
2- from typing import Optional , List , Dict
2+ from typing import Optional , List , Dict , Any , Union
33from pathlib import Path
4+ from holmes .plugins .prompts import load_and_render_prompt
5+ from holmes .plugins .runbooks import RunbookCatalog
46
57
68def append_file_to_user_prompt (user_prompt : str , file_path : Path ) -> str :
@@ -25,11 +27,31 @@ def append_all_files_to_user_prompt(
2527
2628def build_initial_ask_messages (
2729 console : Console ,
28- system_prompt_rendered : str ,
2930 initial_user_prompt : str ,
3031 file_paths : Optional [List [Path ]],
32+ tool_executor : Any , # ToolExecutor type
33+ runbooks : Union [RunbookCatalog , Dict , None ] = None ,
3134) -> List [Dict ]:
32- """Build the initial messages for the AI call."""
35+ """Build the initial messages for the AI call.
36+
37+ Args:
38+ console: Rich console for output
39+ initial_user_prompt: The user's prompt
40+ file_paths: Optional list of files to include
41+ tool_executor: The tool executor with available toolsets
42+ runbooks: Optional runbook catalog
43+ """
44+ # Load and render system prompt internally
45+ system_prompt_template = "builtin://generic_ask.jinja2"
46+ template_context = {
47+ "toolsets" : tool_executor .toolsets ,
48+ "runbooks" : runbooks or {},
49+ }
50+ system_prompt_rendered = load_and_render_prompt (
51+ system_prompt_template , template_context
52+ )
53+
54+ # Append files to user prompt
3355 user_prompt_with_files = append_all_files_to_user_prompt (
3456 console , initial_user_prompt , file_paths
3557 )
0 commit comments