pub struct EditArgs {
    pub model: String,
    pub input: String,
    pub instruction: String,
    pub n: usize,
    pub temperature: f64,
    pub top_p: f64,
}

Fields§

§model: String§input: String§instruction: String§n: usize§temperature: f64§top_p: f64

Implementations§

source§

impl EditArgs

source

pub fn model(&mut self, model: EditModels) -> &mut Self

Set the model to use for the edit

Examples found in repository?
examples/edit.rs (line 27)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
async fn main() {
    let mut prompt = String::new();
    let mut instruction = String::new();

    print!("Enter a prompt: ");
    let _ = stdout().flush();

    stdin().read_line(&mut prompt).unwrap();

    print!("Enter the instruction: ");
    let _ = stdout().flush();

    stdin().read_line(&mut instruction).unwrap();

    let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());

    let resp = client
        .create_edit(|args| {
            args.input(prompt)
                .instruction(instruction)
                .model(EditModels::TextDavinciEdit1)
                .n(1)
                .temperature(1.0)
        })
        .await
        .unwrap();

    let text = resp.get_content(0).unwrap();

    println!("{}", text);
}
source

pub fn input<T>(&mut self, input: T) -> &mut Selfwhere T: ToString,

Set the input for the edit

Examples found in repository?
examples/edit.rs (line 25)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
async fn main() {
    let mut prompt = String::new();
    let mut instruction = String::new();

    print!("Enter a prompt: ");
    let _ = stdout().flush();

    stdin().read_line(&mut prompt).unwrap();

    print!("Enter the instruction: ");
    let _ = stdout().flush();

    stdin().read_line(&mut instruction).unwrap();

    let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());

    let resp = client
        .create_edit(|args| {
            args.input(prompt)
                .instruction(instruction)
                .model(EditModels::TextDavinciEdit1)
                .n(1)
                .temperature(1.0)
        })
        .await
        .unwrap();

    let text = resp.get_content(0).unwrap();

    println!("{}", text);
}
source

pub fn instruction<T>(&mut self, instruction: T) -> &mut Selfwhere T: ToString,

Set the instruction for the edit

Examples found in repository?
examples/edit.rs (line 26)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
async fn main() {
    let mut prompt = String::new();
    let mut instruction = String::new();

    print!("Enter a prompt: ");
    let _ = stdout().flush();

    stdin().read_line(&mut prompt).unwrap();

    print!("Enter the instruction: ");
    let _ = stdout().flush();

    stdin().read_line(&mut instruction).unwrap();

    let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());

    let resp = client
        .create_edit(|args| {
            args.input(prompt)
                .instruction(instruction)
                .model(EditModels::TextDavinciEdit1)
                .n(1)
                .temperature(1.0)
        })
        .await
        .unwrap();

    let text = resp.get_content(0).unwrap();

    println!("{}", text);
}
source

pub fn n(&mut self, n: usize) -> &mut Self

Set the number of edits to return

Examples found in repository?
examples/edit.rs (line 28)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
async fn main() {
    let mut prompt = String::new();
    let mut instruction = String::new();

    print!("Enter a prompt: ");
    let _ = stdout().flush();

    stdin().read_line(&mut prompt).unwrap();

    print!("Enter the instruction: ");
    let _ = stdout().flush();

    stdin().read_line(&mut instruction).unwrap();

    let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());

    let resp = client
        .create_edit(|args| {
            args.input(prompt)
                .instruction(instruction)
                .model(EditModels::TextDavinciEdit1)
                .n(1)
                .temperature(1.0)
        })
        .await
        .unwrap();

    let text = resp.get_content(0).unwrap();

    println!("{}", text);
}
source

pub fn temperature(&mut self, temperature: f64) -> &mut Self

Set the temperature for the edit

Examples found in repository?
examples/edit.rs (line 29)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
async fn main() {
    let mut prompt = String::new();
    let mut instruction = String::new();

    print!("Enter a prompt: ");
    let _ = stdout().flush();

    stdin().read_line(&mut prompt).unwrap();

    print!("Enter the instruction: ");
    let _ = stdout().flush();

    stdin().read_line(&mut instruction).unwrap();

    let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());

    let resp = client
        .create_edit(|args| {
            args.input(prompt)
                .instruction(instruction)
                .model(EditModels::TextDavinciEdit1)
                .n(1)
                .temperature(1.0)
        })
        .await
        .unwrap();

    let text = resp.get_content(0).unwrap();

    println!("{}", text);
}
source

pub fn top_p(&mut self, top_p: f64) -> &mut Self

Set the top_p for the edit

Trait Implementations§

source§

impl Debug for EditArgs

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for EditArgs

source§

fn default() -> Self

Create a new EditArgs struct with default values

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more