Add more context to the terminal assistant (#15492)
Release Notes: - N/A
This commit is contained in:
parent
73e3dfc0c3
commit
eedef487ac
4 changed files with 33 additions and 8 deletions
|
@ -115,11 +115,19 @@ pub fn generate_terminal_assistant_prompt(
|
|||
user_prompt: &str,
|
||||
shell: Option<&str>,
|
||||
working_directory: Option<&str>,
|
||||
latest_output: &[String],
|
||||
) -> String {
|
||||
let mut prompt = String::new();
|
||||
writeln!(&mut prompt, "You are an expert terminal user.").unwrap();
|
||||
writeln!(&mut prompt, "You will be given a description of a command and you need to respond with a command that matches the description.").unwrap();
|
||||
writeln!(&mut prompt, "Do not include markdown blocks or any other text formatting in your response, always respond with a single command that can be executed in the given shell.").unwrap();
|
||||
writeln!(
|
||||
&mut prompt,
|
||||
"Current OS name is '{}', architecture is '{}'.",
|
||||
std::env::consts::OS,
|
||||
std::env::consts::ARCH,
|
||||
)
|
||||
.unwrap();
|
||||
if let Some(shell) = shell {
|
||||
writeln!(&mut prompt, "Current shell is '{shell}'.").unwrap();
|
||||
}
|
||||
|
@ -130,6 +138,15 @@ pub fn generate_terminal_assistant_prompt(
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
if !latest_output.is_empty() {
|
||||
writeln!(
|
||||
&mut prompt,
|
||||
"Latest non-empty {} lines of the terminal output: {:?}",
|
||||
latest_output.len(),
|
||||
latest_output
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
writeln!(&mut prompt, "Here is the description of the command:").unwrap();
|
||||
prompt.push_str(user_prompt);
|
||||
prompt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue