diff --git a/.changeset/gentle-kangaroos-relax.md b/.changeset/gentle-kangaroos-relax.md
new file mode 100644
index 00000000..abfc0aea
--- /dev/null
+++ b/.changeset/gentle-kangaroos-relax.md
@@ -0,0 +1,5 @@
+---
+"@google/generative-ai": minor
+---
+
+Add FinishReason.LANGUAGE enum value.
diff --git a/common/api-review/generative-ai.api.md b/common/api-review/generative-ai.api.md
index 3e77c1a2..83f151fc 100644
--- a/common/api-review/generative-ai.api.md
+++ b/common/api-review/generative-ai.api.md
@@ -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",
diff --git a/docs/reference/main/generative-ai.finishreason.md b/docs/reference/main/generative-ai.finishreason.md
index 2ebaa8f3..1f85f784 100644
--- a/docs/reference/main/generative-ai.finishreason.md
+++ b/docs/reference/main/generative-ai.finishreason.md
@@ -17,6 +17,7 @@ export declare enum FinishReason
| Member | Value | Description |
| --- | --- | --- |
| FINISH\_REASON\_UNSPECIFIED | "FINISH_REASON_UNSPECIFIED"
| |
+| LANGUAGE | "LANGUAGE"
| |
| MAX\_TOKENS | "MAX_TOKENS"
| |
| OTHER | "OTHER"
| |
| RECITATION | "RECITATION"
| |
diff --git a/packages/main/src/requests/response-helpers.ts b/packages/main/src/requests/response-helpers.ts
index 1da81a8b..824e8a40 100644
--- a/packages/main/src/requests/response-helpers.ts
+++ b/packages/main/src/requests/response-helpers.ts
@@ -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 (
diff --git a/packages/main/types/enums.ts b/packages/main/types/enums.ts
index fef01de8..81123182 100644
--- a/packages/main/types/enums.ts
+++ b/packages/main/types/enums.ts
@@ -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",
}