pub struct GenerateContentResponse {
pub candidates: Vec<Candidate>,
pub prompt_feedback: Option<PromptFeedback>,
pub usage_metadata: Option<UsageMetadata>,
pub model_version: String,
}
Expand description
Response from the model supporting multiple candidate responses.
Safety ratings and content filtering are reported for both
prompt in GenerateContentResponse.prompt_feedback
and for each candidate
in finish_reason
and in safety_ratings
. The API:
- Returns either all requested candidates or none of them
- Returns no candidates at all only if there was something wrong with the
prompt (check
prompt_feedback
) - Reports feedback on each candidate in
finish_reason
andsafety_ratings
.
Fields§
§candidates: Vec<Candidate>
Candidate responses from the model.
prompt_feedback: Option<PromptFeedback>
Returns the prompt’s feedback related to the content filters.
usage_metadata: Option<UsageMetadata>
Output only. Metadata on the generation requests’ token usage.
model_version: String
Output only. The model version used to generate the response.
Implementations§
Source§impl GenerateContentResponse
impl GenerateContentResponse
Sourcepub fn total_tokens(&self) -> i32
pub fn total_tokens(&self) -> i32
Total tokens used in request/response cycle
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Serializes successful content text and inline data parts to bytes
Sourcepub fn try_into_bytes(self) -> Result<Vec<u8>, Error>
pub fn try_into_bytes(self) -> Result<Vec<u8>, Error>
Serializes successful content text parts to String.
returns InvalidContent if it encounters data apart from text and inline data
pub fn try_into_bytes_with( self, m: impl Fn(Option<Data>) -> Result<Vec<u8>, Error>, ) -> Result<Vec<u8>, Error>
Trait Implementations§
Source§impl Clone for GenerateContentResponse
impl Clone for GenerateContentResponse
Source§fn clone(&self) -> GenerateContentResponse
fn clone(&self) -> GenerateContentResponse
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for GenerateContentResponse
impl Debug for GenerateContentResponse
Source§impl Default for GenerateContentResponse
impl Default for GenerateContentResponse
Source§impl Message for GenerateContentResponse
impl Message for GenerateContentResponse
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
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,
Encodes the message to a buffer. Read more
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message to a newly allocated buffer.
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,
Encodes the message with a length-delimiter to a buffer. Read more
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,
Encodes the message with a length-delimiter to a newly allocated buffer.
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes an instance of the message from a buffer. Read more
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,
Decodes a length-delimited instance of the message from the buffer.
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,
Decodes an instance of the message from a buffer, and merges it into
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,
Decodes a length-delimited instance of the message from buffer, and
merges it into
self
.Source§impl PartialEq for GenerateContentResponse
impl PartialEq for GenerateContentResponse
impl StructuralPartialEq for GenerateContentResponse
Auto Trait Implementations§
impl Freeze for GenerateContentResponse
impl RefUnwindSafe for GenerateContentResponse
impl Send for GenerateContentResponse
impl Sync for GenerateContentResponse
impl Unpin for GenerateContentResponse
impl UnwindSafe for GenerateContentResponse
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Wrap the input message
T
in a tonic::Request