google_ai: Remove unused extract_text_from_events
function (#28723)
This PR removes the `extract_text_from_events` function from `google_ai`, as it was not used anywhere. Release Notes: - N/A
This commit is contained in:
parent
c8ccc472b5
commit
a8b1ef3531
1 changed files with 1 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
||||||
mod supported_countries;
|
mod supported_countries;
|
||||||
|
|
||||||
use anyhow::{Result, anyhow, bail};
|
use anyhow::{Result, anyhow, bail};
|
||||||
use futures::{AsyncBufReadExt, AsyncReadExt, Stream, StreamExt, io::BufReader, stream::BoxStream};
|
use futures::{AsyncBufReadExt, AsyncReadExt, StreamExt, io::BufReader, stream::BoxStream};
|
||||||
use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};
|
use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -455,24 +455,3 @@ impl std::fmt::Display for Model {
|
||||||
write!(f, "{}", self.id())
|
write!(f, "{}", self.id())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extract_text_from_events(
|
|
||||||
events: impl Stream<Item = Result<GenerateContentResponse>>,
|
|
||||||
) -> impl Stream<Item = Result<String>> {
|
|
||||||
events.filter_map(|event| async move {
|
|
||||||
match event {
|
|
||||||
Ok(event) => event.candidates.and_then(|candidates| {
|
|
||||||
candidates.into_iter().next().and_then(|candidate| {
|
|
||||||
candidate.content.parts.into_iter().next().and_then(|part| {
|
|
||||||
if let Part::TextPart(TextPart { text }) = part {
|
|
||||||
Some(Ok(text))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
Err(error) => Some(Err(error)),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue