[Frontend] Add /abort_requests to the RLHF dev API router (#47173)
Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
a02984ed47
commit
83762b77b0
@@ -64,6 +64,13 @@ impl InflightRequests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Collect the internal engine ids of every in-flight request. Used to
|
||||
/// abort all outstanding requests when no external ids are given.
|
||||
pub(crate) fn all_internal_ids(&self) -> Vec<String> {
|
||||
let map = self.map.lock();
|
||||
map.values().flat_map(|internal_ids| internal_ids.keys()).cloned().collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn is_empty(&self) -> bool {
|
||||
self.map.lock().is_empty()
|
||||
|
||||
@@ -122,7 +122,12 @@ impl Llm {
|
||||
/// tracking entries themselves are removed when the corresponding output
|
||||
/// streams are dropped, not here.
|
||||
pub async fn abort(&self, external_ids: &[String]) -> Result<()> {
|
||||
let internal_ids = self.inflight.resolve(external_ids);
|
||||
// Empty `external_ids` means abort every in-flight request.
|
||||
let internal_ids = if external_ids.is_empty() {
|
||||
self.inflight.all_internal_ids()
|
||||
} else {
|
||||
self.inflight.resolve(external_ids)
|
||||
};
|
||||
if internal_ids.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user