Skip to content

Commit

Permalink
Add FinishReason.LANGUAGE enum value. (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Jul 8, 2024
1 parent e23e99a commit 05b8631
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gentle-kangaroos-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": minor
---

Add FinishReason.LANGUAGE enum value.
2 changes: 2 additions & 0 deletions common/api-review/generative-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ export enum FinishReason {
// (undocumented)
FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED",
// (undocumented)
LANGUAGE = "LANGUAGE",
// (undocumented)
MAX_TOKENS = "MAX_TOKENS",
// (undocumented)
OTHER = "OTHER",
Expand Down
1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.finishreason.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export declare enum FinishReason
| Member | Value | Description |
| --- | --- | --- |
| FINISH\_REASON\_UNSPECIFIED | <code>&quot;FINISH_REASON_UNSPECIFIED&quot;</code> | |
| LANGUAGE | <code>&quot;LANGUAGE&quot;</code> | |
| MAX\_TOKENS | <code>&quot;MAX_TOKENS&quot;</code> | |
| OTHER | <code>&quot;OTHER&quot;</code> | |
| RECITATION | <code>&quot;RECITATION&quot;</code> | |
Expand Down
6 changes: 5 additions & 1 deletion packages/main/src/requests/response-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ export function getFunctionCalls(
}
}

const badFinishReasons = [FinishReason.RECITATION, FinishReason.SAFETY];
const badFinishReasons = [
FinishReason.RECITATION,
FinishReason.SAFETY,
FinishReason.LANGUAGE,
];

function hadBadFinishReason(candidate: GenerateContentCandidate): boolean {
return (
Expand Down
2 changes: 2 additions & 0 deletions packages/main/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export enum FinishReason {
SAFETY = "SAFETY",
// The candidate content was flagged for recitation reasons.
RECITATION = "RECITATION",
// The candidate content was flagged for using an unsupported language.
LANGUAGE = "LANGUAGE",
// Unknown reason.
OTHER = "OTHER",
}
Expand Down

0 comments on commit 05b8631

Please sign in to comment.