Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 4177d5c

Browse files
committed
feat(cli): do not strip newlines from prompt files
1 parent a4a6c54 commit 4177d5c

File tree

5 files changed

+6
-20
lines changed

5 files changed

+6
-20
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
utils/prompts/*.txt text eol=lf

binaries/llm-cli/src/cli_args.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -555,24 +555,8 @@ impl PromptFile {
555555
}
556556

557557
pub fn read_prompt_file(path: &Path) -> eyre::Result<String> {
558-
match std::fs::read_to_string(path) {
559-
Ok(mut prompt) => {
560-
// Strip off the last character if it's exactly newline. Also strip off a single
561-
// carriage return if it's there. Since String must be valid UTF-8 it should be
562-
// guaranteed that looking at the string as bytes here is safe: UTF-8 non-ASCII
563-
// bytes will always the high bit set.
564-
if matches!(prompt.as_bytes().last(), Some(b'\n')) {
565-
prompt.pop();
566-
}
567-
if matches!(prompt.as_bytes().last(), Some(b'\r')) {
568-
prompt.pop();
569-
}
570-
Ok(prompt)
571-
}
572-
Err(err) => {
573-
eyre::bail!("Could not read prompt file at {path:?}; error: {err}");
574-
}
575-
}
558+
std::fs::read_to_string(path)
559+
.wrap_err_with(|| format!("Could not read prompt file at {path:?}"))
576560
}
577561

578562
#[derive(Parser, Debug)]

utils/prompts/alpaca.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Below is an instruction that describes a task. Write a response that appropriate
55
{{PROMPT}}
66

77
### Response:
8+

utils/prompts/pygmalion.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Assistant's Persona: Assistant is a highly intelligent language model trained to comply with user requests.
22
<START>
33
Assistant: How may I help you?
4-
You: {{PROMPT}}
4+
You: {{PROMPT}}

utils/prompts/vicuna.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
A chat between a human ("User") and an AI assistant ("Assistant"). The assistant gives helpful, detailed, and polite answers to the human's questions.
22

33
Assistant: How may I help you?
4-
User: {{PROMPT}}
4+
User: {{PROMPT}}

0 commit comments

Comments
 (0)