-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat add support for generation config
- Loading branch information
1 parent
dc78a14
commit 4f31abd
Showing
8 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import 'package:tekartik_firebase_vertex_ai/vertex_ai.dart'; | ||
|
||
/// Configuration options for model generation and outputs. | ||
final class GenerationConfig { | ||
/// Number of generated responses to return. | ||
/// | ||
/// This value must be between [1, 8], inclusive. If unset, this will default | ||
/// to 1. | ||
final int? candidateCount; | ||
|
||
/// The set of character sequences (up to 5) that will stop output generation. | ||
/// | ||
/// If specified, the API will stop at the first appearance of a stop | ||
/// sequence. The stop sequence will not be included as part of the response. | ||
final List<String> stopSequences; | ||
|
||
/// The maximum number of tokens to include in a candidate. | ||
/// | ||
/// If unset, this will default to output_token_limit specified in the `Model` | ||
/// specification. | ||
final int? maxOutputTokens; | ||
|
||
/// Controls the randomness of the output. | ||
/// | ||
/// Note: The default value varies by model. | ||
/// | ||
/// Values can range from `[0.0, infinity]`, inclusive. A value temperature | ||
/// must be greater than 0.0. | ||
final double? temperature; | ||
|
||
/// The maximum cumulative probability of tokens to consider when sampling. | ||
/// | ||
/// The model uses combined Top-k and nucleus sampling. Tokens are sorted | ||
/// based on their assigned probabilities so that only the most likely tokens | ||
/// are considered. Top-k sampling directly limits the maximum number of | ||
/// tokens to consider, while Nucleus sampling limits number of tokens based | ||
/// on the cumulative probability. | ||
/// | ||
/// Note: The default value varies by model. | ||
final double? topP; | ||
|
||
/// The maximum number of tokens to consider when sampling. | ||
/// | ||
/// The model uses combined Top-k and nucleus sampling. Top-k sampling | ||
/// considers the set of `top_k` most probable tokens. Defaults to 40. | ||
/// | ||
/// Note: The default value varies by model. | ||
final int? topK; | ||
|
||
/// Output response mimetype of the generated candidate text. | ||
/// | ||
/// Supported mimetype: | ||
/// - `text/plain`: (default) Text output. | ||
/// - `application/json`: JSON response in the candidates. | ||
final String? responseMimeType; | ||
|
||
/// Output response schema of the generated candidate text. | ||
/// | ||
/// - Note: This only applies when the specified ``responseMIMEType`` supports | ||
/// a schema; currently this is limited to `application/json`. | ||
final Schema? responseSchema; | ||
|
||
/// Constructor | ||
GenerationConfig({ | ||
this.candidateCount, | ||
this.stopSequences = const [], | ||
this.maxOutputTokens, | ||
this.temperature, | ||
this.topP, | ||
this.topK, | ||
this.responseMimeType, | ||
this.responseSchema, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:tekartik_app_json_schema/json_schema.dart'; | ||
|
||
/// Schema | ||
typedef Schema = JsonSchema; | ||
|
||
/// Schema type | ||
typedef SchemaType = JsonSchemaType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters