pub struct Session<'m> {
pub history: Vec<Content>,
/* private fields */
}
Expand description
Interactive chat session maintaining conversation history
§Example
let client = Client::new(auth).await?;
let model = client.generative_model("gemini-1.5-pro");
let mut chat = model.start_chat();
let response = chat.send_message("Hello!").await?;
Fields§
§history: Vec<Content>
Implementations§
Source§impl<'m> Session<'m>
impl<'m> Session<'m>
Sourcepub async fn send_message<T>(
&mut self,
contents: T,
) -> Result<GenerateContentResponse, Error>where
T: TryIntoContents,
pub async fn send_message<T>(
&mut self,
contents: T,
) -> Result<GenerateContentResponse, Error>where
T: TryIntoContents,
Sends a message and appends response to history
§Errors
Returns Error::Service
if no valid candidates in response
Sourcepub async fn stream_send_message<'s, T>(
&'s mut self,
contents: T,
) -> Result<ResponseStream<'s, 'm>, Error>where
T: TryIntoContents,
pub async fn stream_send_message<'s, T>(
&'s mut self,
contents: T,
) -> Result<ResponseStream<'s, 'm>, Error>where
T: TryIntoContents,
Starts a streaming response while maintaining session state
NOTE
: response is only added to history if whole message is consumed
Trait Implementations§
Auto Trait Implementations§
impl<'m> Freeze for Session<'m>
impl<'m> !RefUnwindSafe for Session<'m>
impl<'m> Send for Session<'m>
impl<'m> Sync for Session<'m>
impl<'m> Unpin for Session<'m>
impl<'m> !UnwindSafe for Session<'m>
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> 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_veecore::Request