pub struct TaskCompletion<'a> {
pub prompt: Prompt<'a>,
pub stopping: Stopping<'a>,
pub sampling: Sampling,
pub special_tokens: bool,
pub logprobs: Logprobs,
pub echo: bool,
}
Expand description
Completes a prompt. E.g. continues a text.
Fields§
§prompt: Prompt<'a>
The prompt (usually text) to be completed. Unconditional completion can be started with an empty string. The prompt may contain a zero shot or few shot task.
stopping: Stopping<'a>
Controls in which circumstances the model will stop generating new tokens.
sampling: Sampling
Sampling controls how the tokens (“words”) are selected for the completion.
special_tokens: bool
Whether to include special tokens (e.g. <|endoftext|>, <|python_tag|>) in the completion.
logprobs: Logprobs
Wether you are interessted in the probabilities of the sampled tokens, or most likely tokens.
echo: bool
Echo the prompt in the completion. This may be especially helpful when log_probs is set to return logprobs for the prompt.
Implementations§
Source§impl<'a> TaskCompletion<'a>
impl<'a> TaskCompletion<'a>
Sourcepub fn from_text(text: &'a str) -> Self
pub fn from_text(text: &'a str) -> Self
Convenience constructor leaving most setting to default, just completing a given text
pub fn with_maximum_tokens(self, maximum_tokens: u32) -> Self
pub fn with_stop_sequences(self, stop_sequences: &'a [&str]) -> Self
Sourcepub fn with_special_tokens(self) -> Self
pub fn with_special_tokens(self) -> Self
Include special tokens (e.g. <|endoftext|>, <|python_tag|>) in the completion.
pub fn with_logprobs(self, logprobs: Logprobs) -> Self
pub fn with_echo(self) -> Self
Trait Implementations§
Source§impl StreamTask for TaskCompletion<'_>
impl StreamTask for TaskCompletion<'_>
Source§type Output = CompletionEvent
type Output = CompletionEvent
crate::Client::output_of
Source§type ResponseBody = DeserializedCompletionEvent
type ResponseBody = DeserializedCompletionEvent
Source§fn build_request(
&self,
client: &Client,
base: &str,
model: &str,
) -> RequestBuilder
fn build_request( &self, client: &Client, base: &str, model: &str, ) -> RequestBuilder
Source§fn body_to_output(&self, response: Self::ResponseBody) -> Option<Self::Output>
fn body_to_output(&self, response: Self::ResponseBody) -> Option<Self::Output>
None
implies the output should be skipped.Source§fn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>where
Self: Sized,
fn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>where
Self: Sized,
Job
] by annotating it with a model name.Source§impl Task for TaskCompletion<'_>
impl Task for TaskCompletion<'_>
Source§type Output = CompletionOutput
type Output = CompletionOutput
crate::Client::output_of
Source§type ResponseBody = ResponseCompletion
type ResponseBody = ResponseCompletion
Source§fn build_request(
&self,
client: &Client,
base: &str,
model: &str,
) -> RequestBuilder
fn build_request( &self, client: &Client, base: &str, model: &str, ) -> RequestBuilder
Source§fn body_to_output(&self, response: Self::ResponseBody) -> Self::Output
fn body_to_output(&self, response: Self::ResponseBody) -> Self::Output
Auto Trait Implementations§
impl<'a> Freeze for TaskCompletion<'a>
impl<'a> RefUnwindSafe for TaskCompletion<'a>
impl<'a> Send for TaskCompletion<'a>
impl<'a> Sync for TaskCompletion<'a>
impl<'a> Unpin for TaskCompletion<'a>
impl<'a> UnwindSafe for TaskCompletion<'a>
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more