[Rust Frontend] add repetition_detection support to sampling params (#46684)
Co-authored-by: Bugen Zhao <i@bugenzhao.com> Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
co-authored by
Bugen Zhao
parent
fbc9ba6d30
commit
6429d5f527
@@ -69,7 +69,7 @@ pub enum FinishReason {
|
||||
/// A retryable request-level internal error occurred.
|
||||
Error,
|
||||
/// A repetitive token pattern was detected.
|
||||
Repetition,
|
||||
Repetition(Option<StopReason>),
|
||||
}
|
||||
|
||||
impl FinishReason {
|
||||
@@ -87,7 +87,7 @@ impl FinishReason {
|
||||
Self::Length => "length",
|
||||
Self::Abort => "abort",
|
||||
Self::Error => "error",
|
||||
Self::Repetition => "repetition",
|
||||
Self::Repetition(_) => "repetition",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ impl FinishReason {
|
||||
pub fn as_stop_reason(&self) -> Option<&StopReason> {
|
||||
match self {
|
||||
Self::Stop(stop_reason) => stop_reason.as_ref(),
|
||||
Self::Repetition(stop_reason) => stop_reason.as_ref(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -105,6 +106,7 @@ impl FinishReason {
|
||||
pub fn into_stop_reason(self) -> Option<StopReason> {
|
||||
match self {
|
||||
Self::Stop(stop_reason) => stop_reason,
|
||||
Self::Repetition(stop_reason) => stop_reason,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -119,7 +121,7 @@ fn finish_reason_from_engine(
|
||||
EngineCoreFinishReason::Length => FinishReason::Length,
|
||||
EngineCoreFinishReason::Abort => FinishReason::Abort,
|
||||
EngineCoreFinishReason::Error => FinishReason::Error,
|
||||
EngineCoreFinishReason::Repetition => FinishReason::Repetition,
|
||||
EngineCoreFinishReason::Repetition => FinishReason::Repetition(stop_reason),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user