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

Support GCP Vertex AI as inference provider #141

Closed
4 tasks
mmurad2 opened this issue Nov 4, 2024 · 9 comments · Fixed by #194
Closed
4 tasks

Support GCP Vertex AI as inference provider #141

mmurad2 opened this issue Nov 4, 2024 · 9 comments · Fixed by #194
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mmurad2
Copy link
Member

mmurad2 commented Nov 4, 2024

Description
Add GCP Vertex AI as a supported inference provider

Tasks

@Tomas2D Tomas2D added the enhancement New feature or request label Nov 5, 2024
@Tomas2D
Copy link
Contributor

Tomas2D commented Nov 5, 2024

@Tomas2D Tomas2D added the good first issue Good for newcomers label Nov 5, 2024
@akihikokuroda
Copy link
Contributor

HI! I would like try this. Would you assign to me? Thanks!

@mmurad2
Copy link
Member Author

mmurad2 commented Nov 5, 2024

Awesome! just assigned you @akihikokuroda

@akihikokuroda
Copy link
Contributor

Thanks!

@akihikokuroda
Copy link
Contributor

I need some guidance here.

I'm trying to serialize VertexAI class from "@google-cloud/vertexai". This class has a member type of GoogleAuth from "google-auth-library" class. I can register both classes to the serializer. So these are OK.
The issue is that the VertexAI has another member type of VertexAIPreview that is a class defined in the same package as VertexAI class but it is not exposed so I can not register it to the serializer.

How can I workaround this?
Thanks!

Here is the class definitions : https://github.com/googleapis/nodejs-vertexai/blob/31de0e92bb7e0efd5afca2728d6175095175be04/src/vertex_ai.ts#L43

export class VertexAI {
  public readonly preview: VertexAIPreview;
  private readonly project: string;
  private readonly location: string;
  private readonly googleAuth: GoogleAuth;
  private readonly apiEndpoint?: string;
 ......
}

class VertexAIPreview {
  private readonly project: string;
  private readonly location: string;
  private readonly googleAuth: GoogleAuth;
  private readonly apiEndpoint?: string;

  private readonly apiClient: Resources.ApiClient;
  readonly cachedContents: Resources.CachedContents;
.....
}

@Tomas2D
Copy link
Contributor

Tomas2D commented Nov 8, 2024

Actually, you don't want to do that. It is okay to do something like this.

static {
    this.register();

    // you register top class, not its children
    Serializer.register(Client, {
      toPlain: (value) => ({
        options: getPropStrict(value, "_options") as ClientOptions,
      }),
      fromPlain: (value) => new Client(value.options),
    });
  }

and then add that Client class to verifyDeserialization.ignoredClasses in tests/e2e/utils.ts.

If you get stuck, no worries, just create a PR without serialization, and I will help.

@Tomas2D
Copy link
Contributor

Tomas2D commented Nov 26, 2024

Released in v0.0.43

@Tomas2D Tomas2D closed this as completed Nov 26, 2024
@mmurad2 mmurad2 reopened this Nov 26, 2024
@mmurad2
Copy link
Member Author

mmurad2 commented Nov 26, 2024

@akihikokuroda thanks for the contribution! could you also complete the following so that our docs and examples folders follow suite:

@Tomas2D
Copy link
Contributor

Tomas2D commented Nov 26, 2024

I added examples because I wanted to try it with my GCP credentials.

However, the implementation needs to be fixed, and the following updates are needed.

  • The parameters property is not used and is not typed; ideally, they should correspond or map to `BaseModelParams.
  • hence, you should completely rework the utility function createModel
  • your code contains expressions like for await (const chunk of await response.stream) {, rewrite to just for await (const chunk of response.stream) {

Tomas2D added a commit that referenced this issue Nov 26, 2024
Ref: #141
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants