Struct google_api_proto::google::ai::generativelanguage::v1beta2::GenerateTextRequest
source · pub struct GenerateTextRequest {
pub model: String,
pub prompt: Option<TextPrompt>,
pub temperature: Option<f32>,
pub candidate_count: Option<i32>,
pub max_output_tokens: Option<i32>,
pub top_p: Option<f32>,
pub top_k: Option<i32>,
pub safety_settings: Vec<SafetySetting>,
pub stop_sequences: Vec<String>,
}
Expand description
Request to generate a text completion response from the model.
Fields§
§model: String
Required. The model name to use with the format name=models/{model}.
prompt: Option<TextPrompt>
Required. The free-form input text given to the model as a prompt.
Given a prompt, the model will generate a TextCompletion response it predicts as the completion of the input text.
temperature: Option<f32>
Controls the randomness of the output.
Note: The default value varies by model, see the Model.temperature
attribute of the Model
returned the getModel
function.
Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model.
candidate_count: Option<i32>
Number of generated responses to return.
This value must be between [1, 8], inclusive. If unset, this will default to 1.
max_output_tokens: Option<i32>
The maximum number of tokens to include in a candidate.
If unset, this will default to 64.
top_p: Option<f32>
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 liekly 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, see the Model.top_p
attribute of the Model
returned the getModel
function.
top_k: Option<i32>
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, see the Model.top_k
attribute of the Model
returned the getModel
function.
safety_settings: Vec<SafetySetting>
A list of unique SafetySetting
instances for blocking unsafe content.
that will be enforced on the GenerateTextRequest.prompt
and
GenerateTextResponse.candidates
. There should not be more than one
setting for each SafetyCategory
type. The API will block any prompts and
responses that fail to meet the thresholds set by these settings. This list
overrides the default settings for each SafetyCategory
specified in the
safety_settings. If there is no SafetySetting
for a given
SafetyCategory
provided in the list, the API will use the default safety
setting for that category.
stop_sequences: Vec<String>
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.
Implementations§
source§impl GenerateTextRequest
impl GenerateTextRequest
sourcepub fn temperature(&self) -> f32
pub fn temperature(&self) -> f32
Returns the value of temperature
, or the default value if temperature
is unset.
sourcepub fn candidate_count(&self) -> i32
pub fn candidate_count(&self) -> i32
Returns the value of candidate_count
, or the default value if candidate_count
is unset.
sourcepub fn max_output_tokens(&self) -> i32
pub fn max_output_tokens(&self) -> i32
Returns the value of max_output_tokens
, or the default value if max_output_tokens
is unset.
Trait Implementations§
source§impl Clone for GenerateTextRequest
impl Clone for GenerateTextRequest
source§fn clone(&self) -> GenerateTextRequest
fn clone(&self) -> GenerateTextRequest
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GenerateTextRequest
impl Debug for GenerateTextRequest
source§impl Default for GenerateTextRequest
impl Default for GenerateTextRequest
source§impl Message for GenerateTextRequest
impl Message for GenerateTextRequest
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moresource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.source§impl PartialEq for GenerateTextRequest
impl PartialEq for GenerateTextRequest
source§fn eq(&self, other: &GenerateTextRequest) -> bool
fn eq(&self, other: &GenerateTextRequest) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for GenerateTextRequest
Auto Trait Implementations§
impl Freeze for GenerateTextRequest
impl RefUnwindSafe for GenerateTextRequest
impl Send for GenerateTextRequest
impl Sync for GenerateTextRequest
impl Unpin for GenerateTextRequest
impl UnwindSafe for GenerateTextRequest
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request