package com.theokanning.openai;

import com.theokanning.openai.edit.EditRequest;
import com.theokanning.openai.edit.EditResult;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class EditTest {

    String token = System.getenv("OPENAI_TOKEN");
    OpenAiService service = new OpenAiService(token);

    @Test
    void edit() {
        EditRequest request = EditRequest.builder()
                .model("text-davinci-edit-001")
                .input("What day of the wek is it?")
                .instruction("Fix the spelling mistakes")
                .build();

        EditResult result = service.createEdit( request);

        assertNotNull(result.getChoices().get(0).getText());
    }

    @Test
    void editDeprecated() {
        EditRequest request = EditRequest.builder()
                .input("What day of the wek is it?")
                .instruction("Fix the spelling mistakes")
                .build();

        EditResult result = service.createEdit("text-davinci-edit-001", request);

        assertNotNull(result.getChoices().get(0).getText());
    }
}

com.theokanning.openai.edit.EditRequest.builder
[((415, 620), 'com.theokanning.openai.edit.EditRequest.builder'), ((415, 595), 'com.theokanning.openai.edit.EditRequest.builder'), ((415, 537), 'com.theokanning.openai.edit.EditRequest.builder'), ((415, 484), 'com.theokanning.openai.edit.EditRequest.builder'), ((818, 975), 'com.theokanning.openai.edit.EditRequest.builder'), ((818, 950), 'com.theokanning.openai.edit.EditRequest.builder'), ((818, 892), 'com.theokanning.openai.edit.EditRequest.builder')]