Unverified Commit b5a6b0db authored by Ayush Agarwal's avatar Ayush Agarwal Committed by GitHub
Browse files

fix: vllm default behaviour for generation prompt (#5223)


Signed-off-by: default avatarayushag <ayushag@nvidia.com>
parent 8e3c0d26
...@@ -233,17 +233,19 @@ impl OAIChatLikeRequest for NvCreateChatCompletionRequest { ...@@ -233,17 +233,19 @@ impl OAIChatLikeRequest for NvCreateChatCompletionRequest {
} }
fn should_add_generation_prompt(&self) -> bool { fn should_add_generation_prompt(&self) -> bool {
// Only add generation prompt if the last message was not assistant (default to true when no last message) // Using vLLM default behavior
self.inner true
.messages // // Only add generation prompt if the last message was not assistant (default to true when no last message)
.last() // self.inner
.map(|last| { // .messages
!matches!( // .last()
last, // .map(|last| {
dynamo_async_openai::types::ChatCompletionRequestMessage::Assistant(_) // !matches!(
) // last,
}) // dynamo_async_openai::types::ChatCompletionRequestMessage::Assistant(_)
.unwrap_or(true) // )
// })
// .unwrap_or(true)
} }
fn extract_text(&self) -> Option<TextInput> { fn extract_text(&self) -> Option<TextInput> {
...@@ -1181,9 +1183,6 @@ NORMAL MODE ...@@ -1181,9 +1183,6 @@ NORMAL MODE
fn user() -> Msg { fn user() -> Msg {
Msg::User(Default::default()) Msg::User(Default::default())
} }
fn asst() -> Msg {
Msg::Assistant(Default::default())
}
fn tool() -> Msg { fn tool() -> Msg {
Msg::Tool(Default::default()) Msg::Tool(Default::default())
} }
...@@ -1208,12 +1207,6 @@ NORMAL MODE ...@@ -1208,12 +1207,6 @@ NORMAL MODE
assert!(s.should_add_generation_prompt()); assert!(s.should_add_generation_prompt());
} }
#[test]
fn no_after_assistant() {
let s = dummy_state(vec![asst()]);
assert!(!s.should_add_generation_prompt());
}
#[test] #[test]
fn add_when_empty() { fn add_when_empty() {
let s = dummy_state(vec![]); let s = dummy_state(vec![]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment