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

Offer Vertex-AI as a provider #706

Closed
hellovai opened this issue Jun 21, 2024 · 7 comments · Fixed by #790
Closed

Offer Vertex-AI as a provider #706

hellovai opened this issue Jun 21, 2024 · 7 comments · Fixed by #790
Labels
enhancement New feature or request

Comments

@hellovai
Copy link
Contributor

hellovai commented Jun 21, 2024

Vertex-ai is another commonly offered interface for speaking to LLMs on-top of gemini directly. It has issues in the way we get the authorization token (needs to be refreshed frequently w/ oauth). We can support this if many people require it.

@hellovai hellovai added the enhancement New feature or request label Jun 21, 2024
@Foxicution
Copy link

We'd like this feature.

@anish-palakurthi
Copy link
Contributor

We'll add support for this by end of the week!

@hellovai
Copy link
Contributor Author

@Foxicution: @anish-palakurthi has got a prototype of this working (in the playground and runtime)! We should be pushing out the PR and merging soon!

To ensure we support what you need, how do you currently do authentication for vertex-ai?

@Foxicution
Copy link

Foxicution commented Jul 15, 2024

Currently we use the google-cloud-sdk to authenticate using account credentials, and then we do

import vertexai

vertexai.init(project="***", location="***")
model = vertexai.generative_models.GenerativeModel("***")

generation_config = {
    "max_output_tokens": 8192,
    "temperature": 1,
    "top_p": 0.95,
}

safety_settings = {
    vertexai.preview.generative_models.HarmCategory.HARM_CATEGORY_HATE_SPEECH: vertexai.preview.generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    vertexai.preview.generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: vertexai.preview.generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    vertexai.preview.generative_models.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: vertexai.preview.generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    vertexai.preview.generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT: vertexai.preview.generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
}
responses = mode.generate_content(["message"], generation_config=generation_config, safety_settings=safety_settings)
@hellovai
Copy link
Contributor Author

We'll confirm and ensure it works!

@anish-palakurthi
Copy link
Contributor

anish-palakurthi commented Jul 15, 2024

@Foxicution
We are getting ready to ship this today!
Take a look and see if this fits your needs!
https://github.com/BoundaryML/baml/blob/vertex-ai/docs/docs/snippets/clients/providers/vertex.mdx

Here is a sample BAML client with your configuration:

client<llm> Vertex {
  provider vertex-ai

  options {
    model gemini-1.5-pro
    project_id my-project-id
    location us-central1
    safetySettings  [
        { 
            category HARM_CATEGORY_HATE_SPEECH
            threshold BLOCK_ONLY_HIGH
        },
        {
            category HARM_CATEGORY_DANGEROUS_CONTENT
            threshold BLOCK_ONLY_HIGH
        },
        {
            category HARM_CATEGORY_SEXUALLY_EXPLICIT
            threshold BLOCK_ONLY_HIGH
        },
        {
            category HARM_CATEGORY_HARASSMENT
            threshold BLOCK_ONLY_HIGH 
        }
      ]
 
    generationConfig {
      maxOutputTokens 10
      temperature 1
      topP 0.95
    }
  }
}
@anish-palakurthi anish-palakurthi linked a pull request Jul 15, 2024 that will close this issue
@Foxicution
Copy link

Read through the docs, looks good I think. Will try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
3 participants