Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions crates/goose/src/providers/formats/gcpvertexai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ use serde_json::Value;

use std::fmt;

pub type StreamingMessageStream = std::pin::Pin<
Box<
dyn futures::Stream<
Item = anyhow::Result<(
Option<Message>,
Option<crate::providers::base::ProviderUsage>,
)>,
> + Send
+ 'static,
>,
>;

/// Sensible default values of Google Cloud Platform (GCP) locations for model deployment.
///
/// Each variant corresponds to a specific GCP region where models can be hosted.
Expand Down Expand Up @@ -367,6 +379,21 @@ pub fn get_usage(data: &Value, request_context: &RequestContext) -> Result<Usage
}
}

pub fn response_to_streaming_message<S>(
stream: S,
request_context: &RequestContext,
) -> StreamingMessageStream
where
S: futures::Stream<Item = anyhow::Result<String>> + Unpin + Send + 'static,
{
match request_context.provider() {
ModelProvider::Anthropic => Box::pin(anthropic::response_to_streaming_message(stream)),
ModelProvider::Google | ModelProvider::MaaS(_) => {
Box::pin(google::response_to_streaming_message(stream))
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading