package com.wy.chatting.domain.chatgpt.service.dto.request;

import java.util.List;

import com.theokanning.openai.completion.chat.ChatCompletionRequest;
import com.theokanning.openai.completion.chat.ChatMessage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class GPTCompletionChatRequest {

    private String model;

    private String role;

    private String message;

    private Integer maxTokens;


    public static ChatCompletionRequest of(GPTCompletionChatRequest request) {
        return ChatCompletionRequest.builder()
                .model(request.getModel())
                .messages(convertChatMessage(request))
                .maxTokens(request.getMaxTokens())
                .build();
    }

    private static List<ChatMessage> convertChatMessage(GPTCompletionChatRequest request) {
        return List.of(new ChatMessage(request.getRole(), request.getMessage()));
    }
}
com.theokanning.openai.completion.chat.ChatCompletionRequest.builder
[((600, 805), 'com.theokanning.openai.completion.chat.ChatCompletionRequest.builder'), ((600, 780), 'com.theokanning.openai.completion.chat.ChatCompletionRequest.builder'), ((600, 729), 'com.theokanning.openai.completion.chat.ChatCompletionRequest.builder'), ((600, 674), 'com.theokanning.openai.completion.chat.ChatCompletionRequest.builder')]