-
Notifications
You must be signed in to change notification settings - Fork 1
AI 프롬프트 DB로 관리 #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
AI 프롬프트 DB로 관리 #34
Conversation
1) GPT CONFIG 추가 2) OPENAI 의존성 추가 3) API-KEY .env로 분리
1) GPT CONFIG 추가 2) OPENAI 의존성 추가 3) API-KEY .env로 분리
…nd into feat/ai-chat
- GPT 관련 설정(CONFIG) 추가 - OpenAI 의존성 추가 - API KEY를 .env 파일로 분리하여 관리 - Security Config에서 ChatBot 관련 설정 임시 해제
…nd into feat/ai-chat # Conflicts: # src/main/java/kr/swyp/backend/chatbot/controller/ChatController.java # src/main/java/kr/swyp/backend/chatbot/domain/ChatHistory.java # src/main/java/kr/swyp/backend/chatbot/repository/ChatHistoryRepository.java # src/main/java/kr/swyp/backend/chatbot/service/ChatService.java # src/main/java/kr/swyp/backend/chatbot/service/ChatServiceImpl.java # src/main/resources/application-local.yml
…nd into feat/ai-chat
Feature/chatclient
Summary of ChangesHello @seungwoo-project, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 백엔드 시스템에 AI 챗봇 기능을 통합하기 위한 초기 구현을 담고 있습니다. AI 프롬프트를 데이터베이스에서 관리하여 유연성을 확보하고, OpenAI API를 활용하여 사용자에게 대화형 메시지 추천 및 세션 기반의 연속적인 챗봇 경험을 제공합니다. 이를 위해 필요한 데이터 모델, 서비스 로직, API 엔드포인트 및 관련 설정들이 전반적으로 추가 및 업데이트되었습니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
안녕하세요. AI 프롬프트를 DB로 관리하도록 변경하고 챗봇 기능을 구현한 PR 잘 보았습니다. 전체적으로 채팅 세션 관리, 대화 기록 저장, OpenAI 연동 등 많은 기능이 추가되었네요. 코드 구조도 계층별로 잘 분리되어 있고, 테스트 코드도 충실하게 작성해주셔서 리뷰하기 좋았습니다.
몇 가지 개선점을 제안드립니다.
SecurityConfig에서 채팅 관련 경로의 권한 설정을 수정하여 인증된 사용자만 접근하도록 해야 합니다. 현재 설정은NullPointerException을 유발할 수 있는 심각한 문제입니다.- OpenAI API URL, 모델명,
temperature등 주요 설정값들이 코드에 하드코딩되어 있습니다. 이 값들을application.yml설정 파일로 옮겨 유연성을 높이는 것이 좋겠습니다. messageType과 같이 정해진 문자열을 사용하는 경우,Enum을 도입하여 타입 안정성을 높이는 것을 고려해볼 수 있습니다.- 그 외에 매직 넘버/스트링을 상수로 대체하고, API 응답 처리 시 방어적인 코드를 추가하는 등 코드의 유지보수성과 안정성을 높일 수 있는 부분들에 대해 몇 가지 의견을 남겼습니다.
자세한 내용은 각 파일의 리뷰 코멘트를 참고해주세요. 수고하셨습니다!
| .requestMatchers("/error").permitAll() | ||
| .requestMatchers("/error/**").permitAll() | ||
| .requestMatchers("/actuator/**").permitAll() | ||
| .requestMatchers("/chat/**").permitAll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/chat/** 경로에 permitAll()을 사용하면 인증되지 않은 요청도 허용됩니다. 하지만 ChatController에서는 @AuthenticationPrincipal을 사용하여 인증된 사용자 정보를 필요로 합니다. 인증되지 않은 사용자가 이 엔드포인트를 호출하면 memberDetails가 null이 되어 NullPointerException이 발생합니다. 이 경로는 인증된 사용자만 접근할 수 있도록 해야 합니다. /chat/**에 대한 규칙을 제거하여 anyRequest().authenticated() 규칙이 적용되도록 하는 것이 좋습니다.
| @Column(name = "MESSAGE_TYPE") | ||
| @Comment("메시지 타입 (USER/BOT)") | ||
| private String messageType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageType 필드가 String으로 선언되어 있습니다. "USER", "BOT"과 같이 정해진 값만 들어가는 경우, Enum 타입을 사용하는 것이 타입 안정성을 높이고 실수를 방지하는 데 도움이 됩니다. MessageType이라는 Enum을 만들고, 필드 타입을 MessageType으로 변경한 뒤 @Enumerated(EnumType.STRING) 어노테이션을 추가하여 DB에 문자열로 저장하도록 하는 것을 권장합니다.
@Enumerated(EnumType.STRING)
@Column(name = "MESSAGE_TYPE")
@Comment("메시지 타입 (USER/BOT)")
private MessageType messageType;이렇게 변경하면 ChatServiceImpl 등에서 문자열로 비교하던 로직도 타입 안전하게 변경할 수 있습니다.
|
|
||
| // DB에서 프롬프트 조회 | ||
| ChatPrompt prompt = chatPromptRepository | ||
| .findByPromptKeyAndIsActiveTrue("MESSAGE_EXTRACTION") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
작업 내용 ⚒️
리뷰어 참고 사항 🤔
DDL
-- 없음