메모리가 포함된 채팅 백엔드

·3분 읽기

원문: Koog Documentation — chat-backend-with-memory 이 글은 Koog 공식 문서의 chat-backend-with-memory 페이지를 한국어로 옮긴 번역본입니다. 문서 구조와 링크 의미를 유지하되, MkDocs 전용 UI 문법은 블로그에서 읽기 좋도록 정리했습니다.

메모리가 포함된 채팅 백엔드

ChatMemory 기능의 일반적인 패턴은 백엔드 서비스입니다. 클라이언트를 대신하여 에이전트 상호 작용을 관리합니다. 각 HTTP 요청은 세션 ID를 전달하고 에이전트는 일치하는 대화 기록을 로드합니다. 응답을 생성 및 반환하고 다음 상호 작용을 위해 업데이트된 채팅 기록을 저장합니다.

1// --- Controller ---23@RestController4class ChatController(private val agentService: ChatAgentService) {5    @PostMapping("/chat")6    suspend fun chat(@RequestBody request: ChatRequest): ChatResponse {7        val reply = agentService.chat(request.sessionId, request.message)8        return ChatResponse(reply)9    }10}1112// --- Service ---1314@Service15class ChatAgentService(private val executor: SingleLLMPromptExecutor) {16    private val toolRegistry = ToolRegistry {17        // register your tools here18    }1920    private val agent = AIAgent(21        promptExecutor = executor,22        llmModel = OpenAIModels.Chat.GPT4oMini,23        systemPrompt = "You are a helpful assistant.",24        toolRegistry = toolRegistry,25    ) {26        install(ChatMemory) {27            chatHistoryProvider = MyDatabaseProvider() // persistent storage28            windowSize(50)29        }30    }3132    suspend fun chat(sessionId: String, message: String): String {33        return agent.run(message, sessionId)34    }35}

Spring Boot로 Koog를 설정하는 방법에 대한 전체 가이드는 다음을 참조하세요. Spring Boot integration guide.