Skip to content

Move summary prompt templates to dedicated file #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 3 additions & 40 deletions crates/q_cli/src/cli/chat/mod.rs
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ mod input_source;
mod parse;
mod parser;
mod prompt;
mod prompts;
mod summarization_state;
mod tools;

@@ -911,46 +912,8 @@ where

// Create a summary request based on user input or default
let summary_request = match prompt {
Some(custom_prompt) => {
// Make the custom instructions much more prominent and directive
format!(
"[SYSTEM NOTE: This is an automated summarization request, not from the user]\n\n\
FORMAT REQUIREMENTS: Create a structured, concise summary in bullet-point format. DO NOT respond conversationally. DO NOT address the user directly.\n\n\
IMPORTANT CUSTOM INSTRUCTION: {}\n\n\
Your task is to create a structured summary document containing:\n\
1) A bullet-point list of key topics/questions covered\n\
2) Bullet points for all significant tools executed and their results\n\
3) Bullet points for any code or technical information shared\n\
4) A section of key insights gained\n\n\
FORMAT THE SUMMARY IN THIRD PERSON, NOT AS A DIRECT RESPONSE. Example format:\n\n\
## CONVERSATION SUMMARY\n\
* Topic 1: Key information\n\
* Topic 2: Key information\n\n\
## TOOLS EXECUTED\n\
* Tool X: Result Y\n\n\
Remember this is a DOCUMENT not a chat response. The custom instruction above modifies what to prioritize.\n\
FILTER OUT CHAT CONVENTIONS (greetings, offers to help, etc).",
custom_prompt
)
},
None => {
// Default prompt
"[SYSTEM NOTE: This is an automated summarization request, not from the user]\n\n\
FORMAT REQUIREMENTS: Create a structured, concise summary in bullet-point format. DO NOT respond conversationally. DO NOT address the user directly.\n\n\
Your task is to create a structured summary document containing:\n\
1) A bullet-point list of key topics/questions covered\n\
2) Bullet points for all significant tools executed and their results\n\
3) Bullet points for any code or technical information shared\n\
4) A section of key insights gained\n\n\
FORMAT THE SUMMARY IN THIRD PERSON, NOT AS A DIRECT RESPONSE. Example format:\n\n\
## CONVERSATION SUMMARY\n\
* Topic 1: Key information\n\
* Topic 2: Key information\n\n\
## TOOLS EXECUTED\n\
* Tool X: Result Y\n\n\
Remember this is a DOCUMENT not a chat response.\n\
FILTER OUT CHAT CONVENTIONS (greetings, offers to help, etc).".to_string()
},
Some(custom_prompt) => prompts::summary::with_custom_prompt(&custom_prompt),
None => prompts::summary::default(),
};

// Add the summarization request
46 changes: 46 additions & 0 deletions crates/q_cli/src/cli/chat/prompts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// This file contains prompt templates used in the chat module.

/// Summary request templates for conversation summarization
pub mod summary {
/// Creates a summary request with custom instructions
pub fn with_custom_prompt(custom_prompt: &str) -> String {
format!(
"\n\n\
FORMAT REQUIREMENTS: Create a structured, concise summary in bullet-point format. DO NOT respond conversationally. DO NOT address the user directly.\n\n\
IMPORTANT CUSTOM INSTRUCTION: {}\n\n\
Your task is to create a structured summary document containing:\n\
1) A bullet-point list of key topics/questions covered\n\
2) Bullet points for all significant tools executed and their results\n\
3) Bullet points for any code or technical information shared\n\
4) A section of key insights gained\n\n\
FORMAT THE SUMMARY IN THIRD PERSON, NOT AS A DIRECT RESPONSE. Example format:\n\n\
## CONVERSATION SUMMARY\n\
* Topic 1: Key information\n\
* Topic 2: Key information\n\n\
## TOOLS EXECUTED\n\
* Tool X: Result Y\n\n\
Remember this is a DOCUMENT not a chat response. The custom instruction above modifies what to prioritize.\n\
FILTER OUT CHAT CONVENTIONS (greetings, offers to help, etc).",
custom_prompt
)
}

/// Default summary request without custom instructions
pub fn default() -> String {
"[SYSTEM NOTE: This is an automated summarization request, not from the user]\n\n\
FORMAT REQUIREMENTS: Create a structured, concise summary in bullet-point format. DO NOT respond conversationally. DO NOT address the user directly.\n\n\
Your task is to create a structured summary document containing:\n\
1) A bullet-point list of key topics/questions covered\n\
2) Bullet points for all significant tools executed and their results\n\
3) Bullet points for any code or technical information shared\n\
4) A section of key insights gained\n\n\
FORMAT THE SUMMARY IN THIRD PERSON, NOT AS A DIRECT RESPONSE. Example format:\n\n\
## CONVERSATION SUMMARY\n\
* Topic 1: Key information\n\
* Topic 2: Key information\n\n\
## TOOLS EXECUTED\n\
* Tool X: Result Y\n\n\
Remember this is a DOCUMENT not a chat response.\n\
FILTER OUT CHAT CONVENTIONS (greetings, offers to help, etc).".to_string()
}
}
9 changes: 0 additions & 9 deletions crates/q_cli/src/cli/chat/summarization_state.rs
Original file line number Diff line number Diff line change
@@ -26,15 +26,6 @@ pub struct SummarizationState {
}

impl SummarizationState {
#[allow(dead_code)]
pub fn new() -> Self {
Self {
original_history: None,
custom_prompt: None,
show_summary: false,
}
}

pub fn with_prompt(prompt: Option<String>) -> Self {
Self {
original_history: None,
Loading