From 4e545e1bb0f6581068962e32490be6639bb9de62 Mon Sep 17 00:00:00 2001 From: su080915 Date: Thu, 28 Nov 2024 23:14:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20gpt=20=ED=94=84=EB=A1=AC=ED=94=84?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/service/ChatHistoryService.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/project/oof/storage/service/ChatHistoryService.java diff --git a/src/main/java/com/project/oof/storage/service/ChatHistoryService.java b/src/main/java/com/project/oof/storage/service/ChatHistoryService.java new file mode 100644 index 0000000..f7d3991 --- /dev/null +++ b/src/main/java/com/project/oof/storage/service/ChatHistoryService.java @@ -0,0 +1,26 @@ +package com.project.oof.storage.service; + +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Service +public class ChatHistoryService { + + private final List> chatHistory = new ArrayList<>(); + + public void addMessage(String role, String content) { + chatHistory.add(Map.of("role", role, "content", content)); + } + + public List> getChatHistory() { + return new ArrayList<>(chatHistory); // 복사본 반환 + } + + // 대화 기록 초기화 (옵션) + public void clearChatHistory() { + chatHistory.clear(); + } +}