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

[Vertex GA] Rewrite Schema #8479

Merged
merged 24 commits into from
Sep 24, 2024
Merged

[Vertex GA] Rewrite Schema #8479

merged 24 commits into from
Sep 24, 2024

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Sep 4, 2024

See https://docs.google.com/document/d/1CXRbH7zmKqupD5LWUq8dh3spsGpozfRbOUa5MWi2tVY/edit?tab=t.wiordux8zots (internal)

Rewriting Schema as a class with static methods to enable easier building and some validation.

This is mostly backwards compatible - functionDeclaration.parameters takes an ObjectSchemaInterface which could be the ObjectSchema class or just a JS object that matches the interface. The only breaking change is the FunctionDeclarationSchemaType enum is now named SchemaType.

Keeping validation minimal as (1) TS should handle a lot of it and even if TS checking doesn't extend to JS-only developers, we don't really want to duplicate efforts with TS, (2) not a lot of rules have strong enough confirmation/guarantees from the backend for us to be sure enough to throw errors.

Copy link

changeset-bot bot commented Sep 4, 2024

⚠️ No Changeset found

Latest commit: bd64869

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 4, 2024

Size Report 1

Affected Products

  • @firebase/vertexai

    TypeBase (097bd67)Merge (428218c)Diff
    browser25.4 kB28.0 kB+2.55 kB (+10.0%)
    main26.0 kB28.8 kB+2.77 kB (+10.6%)
    module25.4 kB28.0 kB+2.55 kB (+10.0%)
  • firebase

    TypeBase (097bd67)Merge (428218c)Diff
    firebase-vertexai.js19.6 kB21.6 kB+1.99 kB (+10.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/Gf8p12i7w6.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 4, 2024

Size Analysis Report 1

Affected Products

  • @firebase/vertexai

    • ArraySchema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.02 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • BlockReason

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • BooleanSchema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.03 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • ChatSession

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size14.1 kB14.1 kB-16 B (-0.1%)
      size-with-ext-deps32.6 kB32.5 kB-16 B (-0.0%)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • FinishReason

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • FunctionCallingMode

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • GenerativeModel

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size16.6 kB16.6 kB-16 B (-0.1%)
      size-with-ext-deps35.1 kB35.0 kB-16 B (-0.0%)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • HarmBlockMethod

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • HarmBlockThreshold

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • HarmCategory

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • HarmProbability

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • HarmSeverity

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • IntegerSchema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.03 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • NumberSchema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.03 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • ObjectSchema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.03 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • POSSIBLE_ROLES

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      15 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      POSSIBLE_ROLES
      Task
      VERTEX_TYPE
      name
      version

      15 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      POSSIBLE_ROLES
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • Schema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.02 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • SchemaType

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?2.93 kB? (?)
      size-with-ext-deps?20.7 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
    • StringSchema

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size?5.03 kB? (?)
      size-with-ext-deps?22.8 kB? (?)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      functions?

      registerVertex

      ?
      classes?

      ArraySchema
      BooleanSchema
      IntegerSchema
      NumberSchema
      ObjectSchema
      Schema
      StringSchema
      VertexAIError
      VertexAIService

      ?
      variables?

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (097bd67)Merge (428218c)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/util?

      FirebaseError

      ?
    • VertexAIError

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size3.26 kB3.24 kB-16 B (-0.5%)
      size-with-ext-deps21.0 kB21.0 kB-16 B (-0.1%)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • getGenerativeModel

      Size

      TypeBase (097bd67)Merge (428218c)Diff
      size16.8 kB16.7 kB-16 B (-0.1%)
      size-with-ext-deps35.2 kB35.2 kB-16 B (-0.0%)

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      + SchemaType
      - FunctionDeclarationSchemaType

    • getVertexAI

      Dependency

      TypeBase (097bd67)Merge (428218c)Diff
      variables

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      FunctionDeclarationSchemaType
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      Task
      VERTEX_TYPE
      name
      version

      14 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      + SchemaType
      - FunctionDeclarationSchemaType

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/2TB1zOoGV4.html

}

/** Converts class to a plain JSON object (not a string). */
toJSON(): Record<string, unknown> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we name this toJSON() if it returns a plain JS object? Is this an API requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what the best name is - this is an intermediate object between the very abstract Schema, where all the children are Schemas, and a JSON string - it's a plain JS object or POJO, could call it toPOJO()? I have this instead of going straight to the stringified JSON because it's easier to inspect and debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I was wrong, toJSON() actually should not return a JSON string, it should in fact return a JS symbol that is ready to pass to JSON.stringify(). Changing this back. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior

@hsubox76 hsubox76 changed the title Rewrite Schema Draft: Rewrite Schema Sep 4, 2024
@hsubox76 hsubox76 changed the base branch from main to v11 September 20, 2024 19:59
@hsubox76 hsubox76 marked this pull request as ready for review September 23, 2024 18:04
@hsubox76 hsubox76 requested review from a team as code owners September 23, 2024 18:04
@hsubox76 hsubox76 changed the title Draft: Rewrite Schema [Vertex GA] Rewrite Schema Sep 23, 2024
@@ -34,15 +34,15 @@ export class VertexAIError extends FirebaseError {
*/
constructor(
readonly code: VertexAIErrorCode,
readonly message: string,
message: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I know I reviewed this already, but is there a reason that this isn't readonly anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good question, I was going to mention it in the description. If it's readonly it can't be overwritten by super() which was causing some unexpected behavior. super() at the bottom of the constructor sets message to fullMessage (adds the service name and code) but it simply won't do anything if it's readonly. The next question would be, what about code - it's ok for code to not be overwritten with fullCode because adding the prefix just makes it harder to compare (e.g. error.code === VertexAIErrorCode.SOME_CODE). The formatted fullCode. only needs to go into the message.

@hsubox76 hsubox76 added this to the Vertex GA milestone Sep 23, 2024
@hsubox76 hsubox76 removed the request for review from a team September 24, 2024 17:21
@hsubox76 hsubox76 merged commit 09ba48f into v11 Sep 24, 2024
38 of 40 checks passed
@hsubox76 hsubox76 deleted the ch-schema branch September 24, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants