Skip to content

Commit

Permalink
fix(webserver): update health check logic for completion model (#3375)
Browse files Browse the repository at this point in the history
* fix(webserver): update health check logic for completion model

* update

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
wsxiaoys and autofix-ci[bot] authored Nov 6, 2024
1 parent 141051b commit ea118c2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ee/tabby-schema/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl Query {
ctx: &Context,
backend: ModelHealthBackend,
) -> Result<ModelBackendHealthInfo, TestModelConnectionError> {
check_user_allow_auth_token(ctx).await?;
check_admin(ctx).await?;

// count request time in milliseconds
let start = Instant::now();
Expand All @@ -741,16 +741,15 @@ impl Query {
.expect("Failed to build completion options");

let (first, _) = completion
.generate("hello Tabby", options)
.generate("def fib(n):\n", options)
.await
.into_future()
.await;
if let Some(first) = first {
if !first.is_empty() {
return Ok(ModelBackendHealthInfo {
latency_ms: start.elapsed().as_millis() as i32,
});
}

if first.is_some() {
return Ok(ModelBackendHealthInfo {
latency_ms: start.elapsed().as_millis() as i32,
});
}

Err(TestModelConnectionError::FailedToConnect(
Expand Down

0 comments on commit ea118c2

Please sign in to comment.