Skip to content

Commit 4ed8251

Browse files
authored
fix: add operating system to translate prompt (#148)
1 parent 1049033 commit 4ed8251

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

crates/q_cli/src/cli/translate.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,20 @@ struct CwResponse {
160160
}
161161

162162
async fn generate_response(question: &str, n: i32) -> Result<CwResponse> {
163-
let prompt = r#"# A collection of macOS shell one-liners that can be run interactively, they all must only be one line and line up with the comment above them
163+
let os = match std::env::consts::OS {
164+
"macos" => "macOS",
165+
"linux" => fig_util::system_info::linux::get_os_release()
166+
.and_then(|a| a.name.as_deref())
167+
.unwrap_or("Linux"),
168+
"windows" => "Windows",
169+
other => other,
170+
};
171+
172+
let prompt_comment = format!(
173+
"# A collection of {os} shell one-liners that can be run interactively, they all must only be one line and line up with the comment above them"
174+
);
164175

165-
# list all version of node on my path
176+
let prompt = r#"# list all version of node on my path
166177
which -a node | xargs -I{} bash -c 'echo -n "{}: "; {} --version'
167178
168179
# Generate all combination (e.g. A,T,C,G)
@@ -175,7 +186,7 @@ i=`wc -l $FILENAME|cut -d ' ' -f1`; cat $FILENAME| echo "scale=2;(`paste -sd+`)/
175186

176187
let mut input = RecommendationsInput {
177188
file_context: FileContext {
178-
left_file_content: format!("{prompt}{question}\n"),
189+
left_file_content: format!("{prompt_comment}\n\n{prompt}{question}\n"),
179190
right_file_content: "".into(),
180191
filename: "commands.sh".into(),
181192
programming_language: ProgrammingLanguage {

0 commit comments

Comments
 (0)