Skip to content

Commit

Permalink
Reduce all info re-query gap to 500 ms.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryscan committed May 20, 2024
1 parent 4bc4cc9 commit 24e79f2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ itertools = "0.13"
memmap2 = "0.9"
safetensors = "0.4"

[workspace.dependencies.ai00-core]
path = "crates/ai00-core"

[workspace.dependencies.web-rwkv]
# path = "../web-rwkv"
default-features = false
Expand Down
6 changes: 3 additions & 3 deletions crates/ai00-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ tokio = { version = "1", features = ["full"] }
toml = "0.8.6"
zip-extract = "0.1"

[dependencies.ai00-core]
workspace = true

[dependencies.anyhow]
workspace = true

Expand Down Expand Up @@ -61,6 +64,3 @@ features = [
"sse",
]
version = "0.67"

[dependencies.ai00-core]
path = "../ai00-core"
4 changes: 2 additions & 2 deletions crates/ai00-server/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ pub async fn request_info(sender: Sender<ThreadRequest>, sleep: Duration) -> Run

pub async fn request_info_stream(
sender: Sender<ThreadRequest>,
info_sender: Sender<RuntimeInfo>,
stream: Sender<RuntimeInfo>,
sleep: Duration,
) {
loop {
if let Ok(_info) = try_request_info(sender.clone()).await {
if info_sender.send(_info).is_err() {
if stream.send(_info).is_err() {
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/ai00-server/src/api/oai/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ struct PartialChatResponse {

async fn respond_one(depot: &mut Depot, request: ChatRequest, res: &mut Response) {
let ThreadState { sender, .. } = depot.obtain::<ThreadState>().unwrap();
let info = request_info(sender.clone(), Duration::from_secs(1)).await;
let info = request_info(sender.clone(), Duration::from_millis(500)).await;
let model_name = info.reload.model_path.to_string_lossy().into_owned();

let (token_sender, token_receiver) = flume::unbounded();
Expand Down Expand Up @@ -233,7 +233,7 @@ async fn respond_one(depot: &mut Depot, request: ChatRequest, res: &mut Response

async fn respond_stream(depot: &mut Depot, request: ChatRequest, res: &mut Response) {
let ThreadState { sender, .. } = depot.obtain::<ThreadState>().unwrap();
let info = request_info(sender.clone(), Duration::from_secs(1)).await;
let info = request_info(sender.clone(), Duration::from_millis(500)).await;
let model_name = info.reload.model_path.to_string_lossy().into_owned();

let (token_sender, token_receiver) = flume::unbounded();
Expand Down
4 changes: 2 additions & 2 deletions crates/ai00-server/src/api/oai/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub struct PartialCompletionResponse {

async fn respond_one(depot: &mut Depot, request: CompletionRequest, res: &mut Response) {
let ThreadState { sender, .. } = depot.obtain::<ThreadState>().unwrap();
let info = request_info(sender.clone(), Duration::from_secs(1)).await;
let info = request_info(sender.clone(), Duration::from_millis(500)).await;
let model_name = info.reload.model_path.to_string_lossy().into_owned();

let (token_sender, token_receiver) = flume::unbounded();
Expand Down Expand Up @@ -177,7 +177,7 @@ async fn respond_one(depot: &mut Depot, request: CompletionRequest, res: &mut Re

async fn respond_stream(depot: &mut Depot, request: CompletionRequest, res: &mut Response) {
let ThreadState { sender, .. } = depot.obtain::<ThreadState>().unwrap();
let info = request_info(sender.clone(), Duration::from_secs(1)).await;
let info = request_info(sender.clone(), Duration::from_millis(500)).await;
let model_name = info.reload.model_path.to_string_lossy().into_owned();

let (token_sender, token_receiver) = flume::unbounded();
Expand Down
2 changes: 1 addition & 1 deletion crates/ai00-server/src/api/oai/embedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub async fn embeddings(
) -> Json<EmbeddingResponse> {
let request = req.to_owned(); // req.parse_json::<EmbeddingRequest>().await.unwrap();
let ThreadState { sender, .. } = depot.obtain::<ThreadState>().unwrap();
let info = request_info(sender.clone(), Duration::from_secs(1)).await;
let info = request_info(sender.clone(), Duration::from_millis(500)).await;
let model_name = info.reload.model_path.to_string_lossy().into_owned();

let (token_sender, token_receiver) = flume::unbounded();
Expand Down
2 changes: 1 addition & 1 deletion crates/ai00-server/src/api/oai/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct ModelResponse {
#[endpoint]
pub async fn models(depot: &mut Depot) -> Json<ModelResponse> {
let ThreadState { sender, .. } = depot.obtain::<ThreadState>().unwrap();
let info = request_info(sender.to_owned(), Duration::from_secs(1)).await;
let info = request_info(sender.to_owned(), Duration::from_millis(500)).await;
let model_name = info
.reload
.model_path
Expand Down

0 comments on commit 24e79f2

Please sign in to comment.