Skip to content

Commit

Permalink
We can't use an enum for tree shaking reasons, as per @jacoblee93. Us…
Browse files Browse the repository at this point in the history
…e plain object instead.
  • Loading branch information
afirstenberg committed Nov 11, 2024
1 parent 9a9248f commit ff28f04
Showing 1 changed file with 57 additions and 48 deletions.
105 changes: 57 additions & 48 deletions libs/langchain-google-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,54 +57,63 @@ export interface GoogleConnectionParams<AuthOptions>
platformType?: GooglePlatformType;
}

export enum GoogleAISafetyCategory {
Harassment = "HARM_CATEGORY_HARASSMENT",
HARASSMENT = Harassment,
HARM_CATEGORY_HARASSMENT = Harassment,

HateSpeech = "HARM_CATEGORY_HATE_SPEECH",
HATE_SPEECH = HateSpeech,
HARM_CATEGORY_HATE_SPEECH = HateSpeech,

SexuallyExplicit = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
SEXUALLY_EXPLICIT = SexuallyExplicit,
HARM_CATEGORY_SEXUALLY_EXPLICIT = SexuallyExplicit,

Dangerous = "HARM_CATEGORY_DANGEROUS",
DANGEROUS = Dangerous,
HARM_CATEGORY_DANGEROUS = Dangerous,

CivicIntegrity = "HARM_CATEGORY_CIVIC_INTEGRITY",
CIVIC_INTEGRITY = CivicIntegrity,
HARM_CATEGORY_CIVIC_INTEGRITY = CivicIntegrity,
}

export enum GoogleAISafetyThreshold {
None = "BLOCK_NONE",
NONE = None,
BLOCK_NONE = None,

Few = "BLOCK_ONLY_HIGH",
FEW = Few,
BLOCK_ONLY_HIGH = Few,

Some = "BLOCK_MEDIUM_AND_ABOVE",
SOME = Some,
BLOCK_MEDIUM_AND_ABOVE = Some,

Most = "BLOCK_LOW_AND_ABOVE",
MOST = Most,
BLOCK_LOW_AND_ABOVE = Most,

Off = "OFF",
OFF = Off,
BLOCK_OFF = Off,
}

export enum GoogleAISafetyMethod {
Severity = "SEVERITY",
Probability = "PROBABILITY",
}
export const GoogleAISafetyCategory = {
Harassment: "HARM_CATEGORY_HARASSMENT",
HARASSMENT: "HARM_CATEGORY_HARASSMENT",
HARM_CATEGORY_HARASSMENT: "HARM_CATEGORY_HARASSMENT",

HateSpeech: "HARM_CATEGORY_HATE_SPEECH",
HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH",
HARM_CATEGORY_HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH",

SexuallyExplicit: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
HARM_CATEGORY_SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT",

Dangerous: "HARM_CATEGORY_DANGEROUS",
DANGEROUS: "HARM_CATEGORY_DANGEROUS",
HARM_CATEGORY_DANGEROUS: "HARM_CATEGORY_DANGEROUS",

CivicIntegrity: "HARM_CATEGORY_CIVIC_INTEGRITY",
CIVIC_INTEGRITY: "HARM_CATEGORY_CIVIC_INTEGRITY",
HARM_CATEGORY_CIVIC_INTEGRITY: "HARM_CATEGORY_CIVIC_INTEGRITY",
} as const;

export type GoogleAISafetyCategory =
(typeof GoogleAISafetyCategory)[keyof typeof GoogleAISafetyCategory];

export const GoogleAISafetyThreshold = {
None: "BLOCK_NONE",
NONE: "BLOCK_NONE",
BLOCK_NONE: "BLOCK_NONE",

Few: "BLOCK_ONLY_HIGH",
FEW: "BLOCK_ONLY_HIGH",
BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH",

Some: "BLOCK_MEDIUM_AND_ABOVE",
SOME: "BLOCK_MEDIUM_AND_ABOVE",
BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE",

Most: "BLOCK_LOW_AND_ABOVE",
MOST: "BLOCK_LOW_AND_ABOVE",
BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE",

Off: "OFF",
OFF: "OFF",
BLOCK_OFF: "OFF",
} as const;

export type GoogleAISafetyThreshold =
(typeof GoogleAISafetyThreshold)[keyof typeof GoogleAISafetyThreshold];

export const GoogleAISafetyMethod = {
Severity: "SEVERITY",
Probability: "PROBABILITY",
} as const;

export type GoogleAISafetyMethod =
(typeof GoogleAISafetyMethod)[keyof typeof GoogleAISafetyMethod];

export interface GoogleAISafetySetting {
category: GoogleAISafetyCategory | string;
Expand Down

0 comments on commit ff28f04

Please sign in to comment.