We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fef329e commit 41ee009Copy full SHA for 41ee009
async-openai/src/client.rs
@@ -737,6 +737,11 @@ pub(crate) async fn stream<O>(
737
where
738
O: DeserializeOwned + std::marker::Send + 'static,
739
{
740
+ #[derive(Debug, serde::Deserialize)]
741
+ struct BaseStreamEvent {
742
+ r#type: String,
743
+ }
744
+
745
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
746
747
tokio::spawn(async move {
@@ -763,6 +768,12 @@ where
763
768
break;
764
769
}
765
770
771
+ if let Ok(event) = serde_json::from_str::<BaseStreamEvent>(&message.data) {
772
+ if event.r#type == "keepalive" {
773
+ continue;
774
775
776
766
777
let response = match serde_json::from_str::<O>(&message.data) {
767
778
Err(e) => Err(map_deserialization_error(e, message.data.as_bytes())),
779
Ok(output) => Ok(output),
0 commit comments