update to use official openai protocol crate (#17710)
This commit is contained in:
@@ -84,6 +84,7 @@ anyhow = "1.0"
|
||||
tokenizers = { version = "0.22.0" }
|
||||
tiktoken-rs = { version = "0.7.0" }
|
||||
reasoning-parser = "1.0.0"
|
||||
openai-protocol = { version = "1.0.0", features = ["axum"] }
|
||||
minijinja = { version = "2.0", features = ["unstable_machinery", "json", "builtins"] }
|
||||
minijinja-contrib = { version = "2.0", features = ["pycompat"] }
|
||||
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
|
||||
|
||||
@@ -99,47 +99,6 @@ impl Job {
|
||||
}
|
||||
}
|
||||
|
||||
impl JobStatus {
|
||||
fn pending(job_type: &str, worker_url: &str) -> Self {
|
||||
Self {
|
||||
job_type: job_type.to_string(),
|
||||
worker_url: worker_url.to_string(),
|
||||
status: "pending".to_string(),
|
||||
message: None,
|
||||
timestamp: SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs(),
|
||||
}
|
||||
}
|
||||
|
||||
fn processing(job_type: &str, worker_url: &str) -> Self {
|
||||
Self {
|
||||
job_type: job_type.to_string(),
|
||||
worker_url: worker_url.to_string(),
|
||||
status: "processing".to_string(),
|
||||
message: None,
|
||||
timestamp: SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs(),
|
||||
}
|
||||
}
|
||||
|
||||
fn failed(job_type: &str, worker_url: &str, error: String) -> Self {
|
||||
Self {
|
||||
job_type: job_type.to_string(),
|
||||
worker_url: worker_url.to_string(),
|
||||
status: "failed".to_string(),
|
||||
message: Some(error),
|
||||
timestamp: SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Job queue configuration
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct JobQueueConfig {
|
||||
|
||||
@@ -4,16 +4,13 @@
|
||||
|
||||
use std::{collections::HashMap, sync::Arc, time::Duration};
|
||||
|
||||
use axum::{
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use futures::{
|
||||
future,
|
||||
stream::{self, StreamExt},
|
||||
};
|
||||
use http::StatusCode;
|
||||
use serde_json::{json, Value};
|
||||
use serde_json::Value;
|
||||
use tokio::{
|
||||
sync::{watch, Mutex},
|
||||
task::JoinHandle,
|
||||
@@ -70,46 +67,6 @@ async fn fan_out(
|
||||
.await
|
||||
}
|
||||
|
||||
impl IntoResponse for FlushCacheResult {
|
||||
fn into_response(self) -> Response {
|
||||
let status = if self.failed.is_empty() {
|
||||
StatusCode::OK
|
||||
} else {
|
||||
StatusCode::PARTIAL_CONTENT
|
||||
};
|
||||
|
||||
let mut body = json!({
|
||||
"status": if self.failed.is_empty() { "success" } else { "partial_success" },
|
||||
"message": self.message,
|
||||
"workers_flushed": self.successful.len(),
|
||||
"total_http_workers": self.http_workers,
|
||||
"total_workers": self.total_workers
|
||||
});
|
||||
|
||||
if !self.failed.is_empty() {
|
||||
body["successful"] = json!(self.successful);
|
||||
body["failed"] = json!(self
|
||||
.failed
|
||||
.into_iter()
|
||||
.map(|(url, err)| json!({"worker": url, "error": err}))
|
||||
.collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
(status, Json(body)).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for WorkerLoadsResult {
|
||||
fn into_response(self) -> Response {
|
||||
let loads: Vec<Value> = self
|
||||
.loads
|
||||
.iter()
|
||||
.map(|info| json!({"worker": &info.worker, "load": info.load}))
|
||||
.collect();
|
||||
Json(json!({"workers": loads})).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum EngineMetricsResult {
|
||||
Ok(String),
|
||||
Err(String),
|
||||
|
||||
@@ -10,7 +10,7 @@ pub mod middleware;
|
||||
pub mod multimodal;
|
||||
pub mod observability;
|
||||
pub mod policies;
|
||||
pub mod protocols;
|
||||
pub use openai_protocol as protocols;
|
||||
pub use reasoning_parser;
|
||||
pub mod routers;
|
||||
pub mod server;
|
||||
|
||||
Reference in New Issue
Block a user