@@ -18,7 +18,8 @@ pip install "https://github.com/robusta-dev/holmesgpt/archive/refs/heads/master.
1818``` python
1919import os
2020from holmes.config import Config
21- from holmes.plugins.prompts import load_and_render_prompt
21+ from holmes.core.prompt import build_initial_ask_messages
22+ from rich.console import Console
2223
2324print (" 🚀 Initializing HolmesGPT..." )
2425
@@ -31,22 +32,28 @@ config = Config(
3132)
3233print (f " ✅ Configuration created with model: { config.model} " )
3334
34- # Create AI instance
35+ # Create AI instance and console
3536print (" Creating AI instance..." )
3637ai = config.create_console_toolcalling_llm()
38+ console = Console()
3739print (" ✅ AI instance ready" )
3840
3941# Ask a question
40- print (" Loading system prompt..." )
41- system_prompt = load_and_render_prompt(
42- " builtin://generic_ask.jinja2" ,
43- {" toolsets" : ai.tool_executor.toolsets}
42+ question = " what pods are failing in production?"
43+ print (f " \n 🔍 Asking: ' { question} ' " )
44+
45+ # Build initial messages with system prompt
46+ messages = build_initial_ask_messages(
47+ console = console,
48+ initial_user_prompt = question,
49+ file_paths = None ,
50+ tool_executor = ai.tool_executor,
51+ runbooks = config.get_runbook_catalog(),
52+ system_prompt_additions = None
4453)
45- print (" ✅ System prompt loaded" )
4654
47- print (" \n 🔍 Asking: 'what pods are failing in production?'" )
4855print (" Holmes is thinking..." )
49- response = ai.prompt_call(system_prompt, " what pods are failing in production? " )
56+ response = ai.call(messages )
5057print (f " Holmes: { response.result} " )
5158```
5259
@@ -62,7 +69,8 @@ Complete example of using HolmesGPT Python SDK with progress tracking
6269
6370import os
6471from holmes.config import Config
65- from holmes.plugins.prompts import load_and_render_prompt
72+ from holmes.core.prompt import build_initial_ask_messages
73+ from rich.console import Console
6674
6775def main ():
6876 print (" 🚀 Starting HolmesGPT Python SDK Example" )
@@ -81,8 +89,9 @@ def main():
8189 print (f " ✅ Configuration created with model: { config.model} " )
8290
8391 print (" \n Step 2: Creating AI instance..." )
84- # Create AI instance
92+ # Create AI instance and console
8593 ai = config.create_console_toolcalling_llm()
94+ console = Console()
8695 print (" ✅ AI instance created successfully" )
8796
8897 print (" \n Step 3: Listing available toolsets..." )
@@ -99,16 +108,7 @@ def main():
99108 for tool in sorted (available_tools):
100109 print (f " • { tool} " )
101110
102- print (" \n Step 5: Loading system prompt..." )
103- # Load system prompt
104- system_prompt = load_and_render_prompt(
105- " builtin://generic_ask.jinja2" ,
106- {" toolsets" : ai.tool_executor.toolsets}
107- )
108- print (" ✅ System prompt loaded successfully" )
109- print (f " Prompt length: { len (system_prompt)} characters " )
110-
111- print (" \n Step 6: Asking questions..." )
111+ print (" \n Step 5: Asking questions..." )
112112 # Ask questions
113113 questions = [
114114 " what pods are failing in production?" ,
@@ -122,7 +122,18 @@ def main():
122122
123123 try :
124124 print (" Holmes is thinking..." )
125- response = ai.prompt_call(system_prompt, question)
125+
126+ # Build initial messages
127+ messages = build_initial_ask_messages(
128+ console = console,
129+ initial_user_prompt = question,
130+ file_paths = None ,
131+ tool_executor = ai.tool_executor,
132+ runbooks = config.get_runbook_catalog(),
133+ system_prompt_additions = None
134+ )
135+
136+ response = ai.call(messages)
126137 print (f " Holmes: { response.result} " )
127138
128139 # Show tools that were used
@@ -200,20 +211,19 @@ def main():
200211 ai = config.create_console_toolcalling_llm()
201212 console = Console()
202213
203- # Load system prompt
204- system_prompt = load_and_render_prompt(
205- " builtin://generic_ask.jinja2" ,
206- {" toolsets" : ai.tool_executor.toolsets}
207- )
208-
209214 # First question
210215 print (" \n 🔍 First Question:" )
211216 first_question = " what pods are failing in my cluster?"
212217 print (f " User: { first_question} " )
213218
214- # Build initial messages (system + first user message)
219+ # Build initial messages (includes system prompt + first user message)
215220 messages = build_initial_ask_messages(
216- console, system_prompt, first_question, None
221+ console = console,
222+ initial_user_prompt = first_question,
223+ file_paths = None ,
224+ tool_executor = ai.tool_executor,
225+ runbooks = config.get_runbook_catalog(),
226+ system_prompt_additions = None
217227 )
218228
219229 # Call AI with initial messages
0 commit comments