----------------------
To print out the intermediate prompts used in TreeSummarizer, you can use the
get_prompts
method of the query engine. This method returns a dictionary of prompts. You can then display this dictionary using a function like
display_prompt_dict
.
Here is an example of how you can do this:
# Get the prompts dictionary
prompts_dict = query_engine.get_prompts()
# Define a function to display the prompts
def display_prompt_dict(prompts_dict):
for k, p in prompts_dict.items():
text_md = f"**Prompt Key**: {k}<br>" f"**Text:** <br>"
display(Markdown(text_md))
print(p.get_template())
display(Markdown("<br><br>"))
# Use the function to display the prompts
display_prompt_dict(prompts_dict)
Please note that you need to have an instance of the query engine. You can create one like this:
query_engine = index.as_query_engine(response_mode="tree_summarize")
You can find more details in the
LlamaIndex documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------