1
2
3
4
5
6
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::shared::response_wrapper::OpenAIError;
use derive_builder::Builder;
use serde::{Deserialize, Serialize};
#[derive(Builder, Clone, Debug, Default, Serialize)]
#[builder(name = "CreateEditRequestBuilder")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "OpenAIError"))]
pub struct CreateEditRequest {
/// ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint.
pub model: String,
/// The input text to use as a starting point for the edit.
#[serde(skip_serializing_if = "Option::is_none")]
pub input: Option<String>,
/// The instruction that tells the model how to edit the prompt.
pub instruction: String,
/// How many edits to generate for the input and instruction.
#[serde(skip_serializing_if = "Option::is_none")]
pub n: Option<u8>, // default: 1
/// What sampling temperature to use, between 0 and 2.
/// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
///
/// We generally recommend altering this or `top_p` but not both.
#[serde(skip_serializing_if = "Option::is_none")]
pub temperature: Option<f32>, // min: 0, max: 2, default: 1
/// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
/// So 0.1 means only the tokens comprising the top 10% probability mass are considered.
///
/// We generally recommend altering this or `temperature` but not both.
#[serde(skip_serializing_if = "Option::is_none")]
pub top_p: Option<f32>, // default: 1
}
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct EditResponse {
pub object: String,
pub created: u32,
pub choices: Vec<Choice>,
pub usage: Usage,
}
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct Choice {
pub text: String,
pub index: u32,
}
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct Usage {
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
}