@@ -211,7 +211,6 @@ final class UsageMetadata {
211211
212212/// Response candidate generated from a [GenerativeModel] .
213213final class Candidate {
214- // TODO: token count?
215214 // ignore: public_member_api_docs
216215 Candidate (this .content, this .safetyRatings, this .citationMetadata,
217216 this .finishReason, this .finishMessage,
@@ -1173,15 +1172,15 @@ final class VertexSerialization implements SerializationStrategy {
11731172 _parsePromptFeedback (promptFeedback),
11741173 _ => null ,
11751174 };
1176- final usageMedata = switch (jsonObject) {
1175+ final usageMetadata = switch (jsonObject) {
11771176 {'usageMetadata' : final usageMetadata? } =>
11781177 parseUsageMetadata (usageMetadata),
11791178 {'totalTokens' : final int totalTokens} =>
11801179 UsageMetadata ._(totalTokenCount: totalTokens),
11811180 _ => null ,
11821181 };
11831182 return GenerateContentResponse (candidates, promptFeedback,
1184- usageMetadata: usageMedata );
1183+ usageMetadata: usageMetadata );
11851184 }
11861185
11871186 /// Parse the json to [CountTokensResponse]
@@ -1523,3 +1522,64 @@ SearchEntryPoint _parseSearchEntryPoint(Object? jsonObject) {
15231522 renderedContent: renderedContent,
15241523 );
15251524}
1525+
1526+ /// Supported programming languages for the generated code.
1527+ enum CodeLanguage {
1528+ /// Unspecified status. This value should not be used.
1529+ unspecified ('LANGUAGE_UNSPECIFIED' ),
1530+
1531+ /// Python language.
1532+ python ('PYTHON' );
1533+
1534+ const CodeLanguage (this ._jsonString);
1535+
1536+ final String _jsonString;
1537+
1538+ /// Convert to json format.
1539+ String toJson () => _jsonString;
1540+
1541+ /// Parse the json string to [CodeLanguage] .
1542+ static CodeLanguage parseValue (String jsonObject) {
1543+ return switch (jsonObject) {
1544+ 'LANGUAGE_UNSPECIFIED' => CodeLanguage .unspecified,
1545+ 'PYTHON' => CodeLanguage .python,
1546+ _ => CodeLanguage
1547+ .unspecified, // If backend has new change, return unspecified.
1548+ };
1549+ }
1550+ }
1551+
1552+ /// Represents the result of the code execution.
1553+ enum Outcome {
1554+ /// Unspecified status. This value should not be used.
1555+ unspecified ('OUTCOME_UNSPECIFIED' ),
1556+
1557+ /// Code execution completed successfully.
1558+ ok ('OUTCOME_OK' ),
1559+
1560+ /// Code execution finished but with a failure. `stderr` should contain the
1561+ /// reason.
1562+ failed ('OUTCOME_FAILED' ),
1563+
1564+ /// Code execution ran for too long, and was cancelled. There may or may not
1565+ /// be a partial output present.
1566+ deadlineExceeded ('OUTCOME_DEADLINE_EXCEEDED' );
1567+
1568+ const Outcome (this ._jsonString);
1569+
1570+ final String _jsonString;
1571+
1572+ /// Convert to json format.
1573+ String toJson () => _jsonString;
1574+
1575+ /// Parse the json string to [Outcome] .
1576+ static Outcome parseValue (String jsonObject) {
1577+ return switch (jsonObject) {
1578+ 'OUTCOME_UNSPECIFIED' => Outcome .unspecified,
1579+ 'OUTCOME_OK' => Outcome .ok,
1580+ 'OUTCOME_FAILED' => Outcome .failed,
1581+ 'OUTCOME_DEADLINE_EXCEEDED' => Outcome .deadlineExceeded,
1582+ _ => throw FormatException ('Unhandled Outcome format' , jsonObject),
1583+ };
1584+ }
1585+ }
0 commit comments