Skip to content

Commit cddc9d5

Browse files
committed
feat(xtask): 支持从文件获取 prompt,修正服务中的 bug
Signed-off-by: YdrMaster <[email protected]>
1 parent a06016a commit cddc9d5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

xtask/src/generate.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use crate::{BaseArgs, macros::print_now, progress_bar};
22
use llama_cu::{Message, Received, Service, Session, SessionId, TextBuf};
33
use log::info;
4-
use std::time::{Duration, Instant};
4+
use std::{
5+
path::Path,
6+
time::{Duration, Instant},
7+
};
58

69
#[derive(Args)]
710
pub struct GenerateArgs {
@@ -24,6 +27,9 @@ impl GenerateArgs {
2427
let max_steps = base.max_steps();
2528
let sample_args = base.sample_args();
2629
let mut prompt = prompt.unwrap_or("Once upon a time,".into());
30+
if Path::new(&prompt).is_file() {
31+
prompt = std::fs::read_to_string(&prompt).unwrap();
32+
}
2733

2834
let mut service = Service::new(base.model, &gpus, !base.no_cuda_graph);
2935
progress_bar(&mut service);

xtask/src/service/openai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn chat_completion_response(
4646
) -> CreateChatCompletionResponse {
4747
let choices = vec![CreateChatCompletionResponseChoices {
4848
message: ChatCompletionResponseMessage {
49-
content: answer.unwrap(),
49+
content: answer.unwrap_or_default(),
5050
reasoning_content: think,
5151
..Default::default()
5252
},

0 commit comments

Comments
 (0)