Adds streaming generation that returns a streaming

- Introducues generate_content_stream that returns a Tokio Steam instead
of a Queue. This allows using the standard stream APIs from
tokio-streams.
- Replace future-utils with tokio-streams, mainly due to better
ergonomics for using the filter_map stream combinator.
This commit is contained in:
2025-04-05 19:18:33 +01:00
parent de9b14b984
commit 51d6a27017
8 changed files with 84 additions and 73 deletions

View File

@@ -14,7 +14,8 @@ pub enum Error {
Serde(serde_json::Error),
VertexError(types::VertexApiError),
NoCandidatesError,
EventSourceError(CannotCloneRequestError),
CannotCloneRequestError(CannotCloneRequestError),
EventSourceError(reqwest_eventsource::Error),
}
impl Display for Error {
@@ -30,6 +31,9 @@ impl Display for Error {
Error::NoCandidatesError => {
write!(f, "No candidates returned for the prompt")
}
Error::CannotCloneRequestError(e) => {
write!(f, "Cannot clone request: {}", e)
}
Error::EventSourceError(e) => {
write!(f, "EventSourrce Error: {}", e)
}
@@ -71,6 +75,12 @@ impl From<types::VertexApiError> for Error {
impl From<CannotCloneRequestError> for Error {
fn from(e: CannotCloneRequestError) -> Self {
Error::CannotCloneRequestError(e)
}
}
impl From<reqwest_eventsource::Error> for Error {
fn from(e: reqwest_eventsource::Error) -> Self {
Error::EventSourceError(e)
}
}