Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support VertexAI for Claude #1138

Merged
merged 10 commits into from
Feb 12, 2025
Merged

Conversation

yukukotani
Copy link
Contributor

Add support for Vertex AI.

I've added only Claude sonnet 3.5 in this PR but we can expand it to Gemini or other models later.

@michaelneale
Copy link
Collaborator

very cool thanks @yukukotani - Vertex is to google what bedrock is to aws!

async fn post(&self, payload: Value) -> Result<Value, ProviderError> {
let url = format!(
"https://{}/v1/projects/{}/locations/{}/publishers/anthropic/models/{}:streamRawPredict",
self.host, self.project_id, self.region, self.model.model_name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some validation to the host? right now if the VERTEXAI_API_HOST has the prefix "https" then we will have the invalid url

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


async fn post(&self, payload: Value) -> Result<Value, ProviderError> {
let url = format!(
"https://{}/v1/projects/{}/locations/{}/publishers/anthropic/models/{}:streamRawPredict",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to make it as a variable so we can change it to others, like mistral and lllam, both of these models are also supported in vertex: https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/mistral

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -82,6 +86,7 @@ export const supported_providers = [
'Ollama',
'OpenRouter',
'Azure OpenAI',
'Vertex AI',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ui codebase requires more changes as right now we have a new provider and we need to ask user to input the vertex ai project and region. https://github.com/block/goose/tree/main/ui/desktop/src/components/settings/providers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yukukotani yukukotani force-pushed the vertex-ai branch 2 times, most recently from d1d94d6 to d2dc136 Compare February 8, 2025 06:08
@yukukotani
Copy link
Contributor Author

@yingjiehe-xyz Thank you for reviewing! I've added some fixes.

messages: &[Message],
tools: &[Tool],
) -> Result<Value> {
let mut request = anthropic::create_request(model_config, system, messages, tools)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add one more check whether it is anthropic model? By checking the model_config name, we can let the user know right now, only anthropic model is support via vertex ai

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match status {
reqwest::StatusCode::OK => Ok(response_json),
reqwest::StatusCode::UNAUTHORIZED | reqwest::StatusCode::FORBIDDEN => {
Err(ProviderError::Authentication(format!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yukukotani
Copy link
Contributor Author

ready for getting merged I believe

@yingjiehe-xyz yingjiehe-xyz merged commit 58c9eeb into block:main Feb 12, 2025
5 checks passed
baxen added a commit that referenced this pull request Feb 13, 2025
This appears to be causing failing builds. We think it's
because the gcp-sdk-auth depend on reqwest with non native tls
but need more time to investigate
baxen added a commit that referenced this pull request Feb 13, 2025
laanak08 pushed a commit that referenced this pull request Feb 13, 2025
laanak08 pushed a commit that referenced this pull request Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants