From c6ad5b1b5bbb9914e21ae389ec11c49f6992442f Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Thu, 4 Apr 2024 18:22:40 +0200 Subject: [PATCH] dust-apps: more stability + observability (#4577) * dust-apps: more stability + observability * remove streaming retries --- core/Cargo.lock | 104 ++++---------------------------- core/Cargo.toml | 2 +- core/src/providers/anthropic.rs | 11 ++-- core/src/providers/mistral.rs | 8 +-- core/src/providers/openai.rs | 12 +--- types/src/front/lib/core_api.ts | 2 + types/src/front/lib/dust_api.ts | 4 ++ 7 files changed, 27 insertions(+), 116 deletions(-) diff --git a/core/Cargo.lock b/core/Cargo.lock index 1a1c45cc44d1..c46ab7989caf 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -862,15 +862,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ct-logs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" -dependencies = [ - "sct 0.6.1", -] - [[package]] name = "data-encoding" version = "2.5.0" @@ -1187,13 +1178,13 @@ dependencies = [ [[package]] name = "eventsource-client" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b91e5ec5c794bbec5f639620f0bafe421b6d27dec66ac1ce3fdb6f009db3a6c" +checksum = "4c80c6714d1a380314fcb11a22eeff022e1e1c9642f0bb54e15dc9cb29f37b29" dependencies = [ "futures", "hyper 0.14.28", - "hyper-rustls 0.22.1", + "hyper-rustls", "hyper-timeout", "log", "pin-project", @@ -1701,23 +1692,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" -dependencies = [ - "ct-logs", - "futures-util", - "hyper 0.14.28", - "log", - "rustls 0.19.1", - "rustls-native-certs 0.5.0", - "tokio", - "tokio-rustls 0.22.0", - "webpki", -] - [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1729,9 +1703,9 @@ dependencies = [ "hyper 0.14.28", "log", "rustls 0.21.10", - "rustls-native-certs 0.6.3", + "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", ] [[package]] @@ -2799,7 +2773,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", - "hyper-rustls 0.24.2", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -2818,7 +2792,7 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-util", "tower-service", "url", @@ -2931,19 +2905,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log", - "ring 0.16.20", - "sct 0.6.1", - "webpki", -] - [[package]] name = "rustls" version = "0.21.10" @@ -2953,7 +2914,7 @@ dependencies = [ "log", "ring 0.17.8", "rustls-webpki 0.101.7", - "sct 0.7.1", + "sct", ] [[package]] @@ -2970,18 +2931,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" -dependencies = [ - "openssl-probe", - "rustls 0.19.1", - "schannel", - "security-framework", -] - [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3066,16 +3015,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - [[package]] name = "sct" version = "0.7.1" @@ -3624,17 +3563,6 @@ dependencies = [ "whoami", ] -[[package]] -name = "tokio-rustls" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" -dependencies = [ - "rustls 0.19.1", - "tokio", - "webpki", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -3708,10 +3636,10 @@ dependencies = [ "percent-encoding", "pin-project", "prost", - "rustls-native-certs 0.6.3", + "rustls-native-certs", "rustls-pemfile", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-stream", "tower", "tower-layer", @@ -4182,16 +4110,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - [[package]] name = "webpki-roots" version = "0.25.4" @@ -4424,7 +4342,7 @@ dependencies = [ "futures", "http 0.2.12", "hyper 0.14.28", - "hyper-rustls 0.24.2", + "hyper-rustls", "itertools 0.12.1", "log", "percent-encoding", diff --git a/core/Cargo.toml b/core/Cargo.toml index 7f627eff9369..4eac5a90bf76 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -47,7 +47,7 @@ urlencoding = "2.1" url = "2.3" dns-lookup = "1.0" async-stream = "0.3" -eventsource-client = "0.11" +eventsource-client = "0.12" tera = "1.17" fancy-regex = "0.11" rustc-hash = "1.1" diff --git a/core/src/providers/anthropic.rs b/core/src/providers/anthropic.rs index d501bafff383..4796ed6c54ea 100644 --- a/core/src/providers/anthropic.rs +++ b/core/src/providers/anthropic.rs @@ -541,11 +541,7 @@ impl AnthropicLLM { "Anthropic API Error: {}", event.error.to_string() ), - retryable: Some(ModelErrorRetryOptions { - sleep: Duration::from_millis(500), - factor: 1, - retries: 1, - }), + retryable: None, })?; break 'stream; } @@ -557,7 +553,10 @@ impl AnthropicLLM { } }, Err(error) => { - Err(anyhow!("Error streaming from Anthropic: {:?}", error))?; + Err(anyhow!( + "Error streaming tokens from Anthropic: {:?}", + error + ))?; break 'stream; } } diff --git a/core/src/providers/mistral.rs b/core/src/providers/mistral.rs index 1773333a64fb..6cbe71c19354 100644 --- a/core/src/providers/mistral.rs +++ b/core/src/providers/mistral.rs @@ -331,7 +331,7 @@ impl MistralAPIError { } pub fn retryable_streamed(&self) -> bool { - self.retryable() + false } } @@ -497,11 +497,7 @@ impl MistralAILLM { })?, false => Err(ModelError { message: error.message(), - retryable: Some(ModelErrorRetryOptions { - sleep: Duration::from_millis(500), - factor: 1, - retries: 1, - }), + retryable: None, })?, } break 'stream; diff --git a/core/src/providers/openai.rs b/core/src/providers/openai.rs index 4235c4bf738f..539f3f1cfe02 100644 --- a/core/src/providers/openai.rs +++ b/core/src/providers/openai.rs @@ -280,11 +280,7 @@ pub async fn streamed_completion( })?, false => Err(ModelError { message: error.message(), - retryable: Some(ModelErrorRetryOptions { - sleep: Duration::from_millis(500), - factor: 1, - retries: 1, - }), + retryable: None, })?, } break 'stream; @@ -666,11 +662,7 @@ pub async fn streamed_chat_completion( })?, false => Err(ModelError { message: error.message(), - retryable: Some(ModelErrorRetryOptions { - sleep: Duration::from_millis(500), - factor: 1, - retries: 1, - }), + retryable: None, })?, } break 'stream; diff --git a/types/src/front/lib/core_api.ts b/types/src/front/lib/core_api.ts index caced694c325..39c101a64458 100644 --- a/types/src/front/lib/core_api.ts +++ b/types/src/front/lib/core_api.ts @@ -365,6 +365,8 @@ export class CoreAPI { logger.error( { error: e, + errorStr: JSON.stringify(e), + errorSource: "createRunStream", }, "Error streaming chunks" ); diff --git a/types/src/front/lib/dust_api.ts b/types/src/front/lib/dust_api.ts index 8b4eeca11c46..0fa99af3a936 100644 --- a/types/src/front/lib/dust_api.ts +++ b/types/src/front/lib/dust_api.ts @@ -291,6 +291,8 @@ export async function processStreamedRunResponse( logger.error( { error: e, + errorStr: JSON.stringify(e), + errorSource: "processStreamedRunResponse", }, "Error streaming chunks." ); @@ -670,6 +672,8 @@ export class DustAPI { logger.error( { error: e, + errorStr: JSON.stringify(e), + errorSource: "postUserMessage", }, "Error streaming chunks." );