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
use crate::{
    error::OpenAIError,
    types::{CreateEditRequest, CreateEditResponse},
    Client,
};

/// Given a prompt and an instruction, the model will return
/// an edited version of the prompt.
pub struct Edits<'c> {
    client: &'c Client,
}

impl<'c> Edits<'c> {
    pub fn new(client: &'c Client) -> Self {
        Self { client }
    }

    /// Creates a new edit for the provided input, instruction, and parameters
    pub async fn create(
        &self,
        request: CreateEditRequest,
    ) -> Result<CreateEditResponse, OpenAIError> {
        self.client.post("/edits", request).await
    }
}