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 to_text(&self) -> String
pub fn to_text(&self) -> String
Serializes successful content text parts to String without consuming the response
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serializes successful content text and inline data parts to bytes without consuming the response
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Serializes successful content text and inline data parts to bytes
Prefer to_bytes
Sourcepub fn try_to_bytes(&self) -> Result<Vec<u8>, Error>
pub fn try_to_bytes(&self) -> Result<Vec<u8>, Error>
Serializes successful content text and inline data parts to bytes without consuming the response.
returns InvalidContent if it encounters data apart from text and inline data
Sourcepub fn try_into_bytes(self) -> Result<Vec<u8>, Error>
pub fn try_into_bytes(self) -> Result<Vec<u8>, Error>
Serializes successful content text and inline data parts to bytes.
returns InvalidContent if it encounters data apart from text and inline data
Prefer try_to_bytes
pub fn try_into_bytes_with( self, m: impl Fn(Option<Data>) -> Result<Vec<u8>, Error>, ) -> Result<Vec<u8>, Error>
Source§impl GenerateContentResponse
impl GenerateContentResponse
Sourcepub fn total_tokens(&self) -> f64
pub fn total_tokens(&self) -> f64
Total tokens used in request/response cycle
Trait Implementations§
Source§impl Clone for GenerateContentResponse
impl Clone for GenerateContentResponse
Source§fn clone(&self) -> GenerateContentResponse
fn clone(&self) -> GenerateContentResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
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 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
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>
T
in a tonic_veecore::Request