Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
18 changes: 9 additions & 9 deletions src/main/java/com/team4/giftidea/controller/GptController.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private String generatePrompt(List<String> processedMessages, String relation, S
}

private String generateText(String prompt) {
GptRequestDTO request = new GptRequestDTO(gptConfig.getModel(), prompt);
GptRequestDTO request = new GptRequestDTO(gptConfig.getModel(), prompt, 110);
try {
ObjectMapper mapper = new ObjectMapper();
GptResponseDTO response = restTemplate.postForObject(gptConfig.getApiUrl(), request, GptResponseDTO.class);
Expand Down Expand Up @@ -268,7 +268,7 @@ private String generateText(String prompt) {

private String extractKeywordsAndReasonsCoupleMan(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 남자 애인이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 남자 애인이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 남성 지갑, 남성 스니커즈, 백팩, 토트백, 크로스백, 벨트, 선글라스, 향수, 헬스가방, 무선이어폰, 스마트워치, 맨투맨, 마우스, 키보드, 전기면도기, 게임기

텍스트: %s
Expand All @@ -285,7 +285,7 @@ private String extractKeywordsAndReasonsCoupleMan(String theme, String message)

private String extractKeywordsAndReasonsCoupleWoman(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 여자 애인이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 여자 애인이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 여성 지갑, 여성 스니커즈, 숄더백, 토트백, 크로스백, 향수, 목걸이, 무선이어폰, 스마트워치, 에어랩

텍스트: %s
Expand All @@ -302,7 +302,7 @@ private String extractKeywordsAndReasonsCoupleWoman(String theme, String message

private String extractKeywordsAndReasonsDad(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 부모님이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 부모님이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 현금 박스, 안마기기, 아버지 신발, 시계

텍스트: %s
Expand All @@ -319,7 +319,7 @@ private String extractKeywordsAndReasonsDad(String theme, String message) {

private String extractKeywordsAndReasonsMom(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 부모님이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 부모님이 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 현금 박스, 안마기기, 어머니 신발, 건강식품, 스카프

텍스트: %s
Expand All @@ -336,7 +336,7 @@ private String extractKeywordsAndReasonsMom(String theme, String message) {

private String extractKeywordsAndReasonsFriend(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 친구가 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 친구가 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
제시된 카테고리에 없는 추천 선물이 있다면 3개에 포함해주세요.
카테고리: 핸드크림, 텀블러, 립밤, 머플러, 비타민, 입욕제, 블루투스 스피커

Expand All @@ -354,7 +354,7 @@ private String extractKeywordsAndReasonsFriend(String theme, String message) {

private String extractKeywordsAndReasonsHousewarming(String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 집들이에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 집들이에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 조명, 핸드워시, 식기, 디퓨저, 오설록 티세트, 휴지, 파자마세트, 무드등, 디퓨저, 수건, 전기포트, 에어프라이기

텍스트: %s
Expand All @@ -371,7 +371,7 @@ private String extractKeywordsAndReasonsHousewarming(String message) {

private String extractKeywordsAndReasonsSeasonalMan(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 초콜릿, 수제 초콜릿 키트, 파자마세트, 남자 화장품

텍스트: %s
Expand All @@ -388,7 +388,7 @@ private String extractKeywordsAndReasonsSeasonalMan(String theme, String message

private String extractKeywordsAndReasonsSeasonalWoman(String theme, String message) {
String prompt = String.format("""
다음 텍스트를 참고하여 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 제공해주세요.
다음 텍스트를 참고하여 %s에 선물로 받으면 좋아할 카테고리 3개와 판단에 참고한 대화를 100토큰 내로 제공해주세요.
카테고리: 초콜릿, 수제 초콜릿 키트, 립밤, 파자마세트, 립스틱

텍스트: %s
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/team4/giftidea/dto/GptRequestDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ public class GptRequestDTO {
*/
private List<MessageDTO> messages;

/**
* 최대 토큰 수 제한 (응답 길이 제한)
*/
private int max_tokens; // 🔥 추가된 필드

/**
* 생성자 - 주어진 모델과 프롬프트를 기반으로 GPT 요청을 생성합니다.
*
* @param model 사용할 GPT 모델
* @param prompt 사용자 입력 프롬프트
* @param max_tokens 최대 토큰 제한
*/
public GptRequestDTO(String model, String prompt) {
public GptRequestDTO(String model, String prompt, int max_tokens) {
this.model = model;
this.messages = new ArrayList<>();
this.messages.add(new MessageDTO("user", prompt));
this.max_tokens = max_tokens;
}
}