Trait Task

Source
pub trait Task {
    type Output;
    type ResponseBody: for<'de> Deserialize<'de>;

    // Required methods
    fn build_request(
        &self,
        client: &Client,
        base: &str,
        model: &str,
    ) -> RequestBuilder;
    fn body_to_output(&self, response: Self::ResponseBody) -> Self::Output;

    // Provided method
    fn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>
       where Self: Sized { ... }
}
Expand description

A task send to the Aleph Alpha Api using the http client. Requires to specify a model before it can be executed.

Required Associated Types§

Source

type Output

Output returned by crate::Client::output_of

Source

type ResponseBody: for<'de> Deserialize<'de>

Expected answer of the Aleph Alpha API

Required Methods§

Source

fn build_request( &self, client: &Client, base: &str, model: &str, ) -> RequestBuilder

Prepare the request for the Aleph Alpha API. Authentication headers can be assumed to be already set.

Source

fn body_to_output(&self, response: Self::ResponseBody) -> Self::Output

Parses the response of the server into higher level structs for the user.

Provided Methods§

Source

fn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>
where Self: Sized,

Turn your task into Job by annotating it with a model name.

Implementors§

Source§

impl Task for TaskChat<'_>

Source§

impl Task for TaskCompletion<'_>

Source§

type Output = CompletionOutput

Source§

type ResponseBody = ResponseCompletion

Source§

impl Task for TaskDetokenization<'_>

Source§

type Output = DetokenizationOutput

Source§

type ResponseBody = ResponseDetokenization

Source§

impl Task for TaskExplanation<'_>

Source§

type Output = ExplanationOutput

Source§

type ResponseBody = ResponseExplanation

Source§

impl Task for TaskSemanticEmbedding<'_>

Source§

type Output = SemanticEmbeddingOutput

Source§

type ResponseBody = SemanticEmbeddingOutput

Source§

impl Task for TaskSemanticEmbeddingWithInstruction<'_>

Source§

type Output = SemanticEmbeddingOutput

Source§

type ResponseBody = SemanticEmbeddingOutput

Source§

impl Task for TaskTokenization<'_>

Source§

type Output = TokenizationOutput

Source§

type ResponseBody = ResponseTokenization