캐릭터 챗봇 #338

Merged
klaus merged 119 commits from test into main 2025-09-10 06:08:47 +00:00
8 changed files with 33 additions and 17 deletions
Showing only changes of commit 2dc5a29220 - Show all commits

View File

@ -126,7 +126,7 @@ class AdminChatCharacterController(
memories = request.memories.map { Triple(it.title, it.content, it.emotion) },
personalities = request.personalities.map { Pair(it.trait, it.description) },
backgrounds = request.backgrounds.map { Pair(it.topic, it.description) },
relationships = request.relationships
relationships = request.relationships.map { it.name to it.relationShip }
)
// 3. 이미지 저장 및 ChatCharacter에 이미지 path 설정

View File

@ -20,7 +20,7 @@ data class ChatCharacterDetailResponse(
val hobbies: List<String>,
val values: List<String>,
val goals: List<String>,
val relationships: List<String>,
val relationships: List<RelationshipResponse>,
val personalities: List<PersonalityResponse>,
val backgrounds: List<BackgroundResponse>,
val memories: List<MemoryResponse>
@ -51,7 +51,7 @@ data class ChatCharacterDetailResponse(
hobbies = chatCharacter.hobbyMappings.map { it.hobby.hobby },
values = chatCharacter.valueMappings.map { it.value.value },
goals = chatCharacter.goalMappings.map { it.goal.goal },
relationships = chatCharacter.relationships.map { it.relationShip },
relationships = chatCharacter.relationships.map { RelationshipResponse(it.name, it.relationShip) },
personalities = chatCharacter.personalities.map {
PersonalityResponse(it.trait, it.description)
},
@ -81,3 +81,8 @@ data class MemoryResponse(
val content: String,
val emotion: String
)
data class RelationshipResponse(
val name: String,
val relationShip: String
)

View File

@ -18,6 +18,11 @@ data class ChatCharacterMemoryRequest(
@JsonProperty("emotion") val emotion: String
)
data class ChatCharacterRelationshipRequest(
@JsonProperty("name") val name: String,
@JsonProperty("relationShip") val relationShip: String
)
data class ChatCharacterRegisterRequest(
@JsonProperty("name") val name: String,
@JsonProperty("systemPrompt") val systemPrompt: String,
@ -32,7 +37,7 @@ data class ChatCharacterRegisterRequest(
@JsonProperty("hobbies") val hobbies: List<String> = emptyList(),
@JsonProperty("values") val values: List<String> = emptyList(),
@JsonProperty("goals") val goals: List<String> = emptyList(),
@JsonProperty("relationships") val relationships: List<String> = emptyList(),
@JsonProperty("relationships") val relationships: List<ChatCharacterRelationshipRequest> = emptyList(),
@JsonProperty("personalities") val personalities: List<ChatCharacterPersonalityRequest> = emptyList(),
@JsonProperty("backgrounds") val backgrounds: List<ChatCharacterBackgroundRequest> = emptyList(),
@JsonProperty("memories") val memories: List<ChatCharacterMemoryRequest> = emptyList()
@ -64,7 +69,7 @@ data class ChatCharacterUpdateRequest(
@JsonProperty("hobbies") val hobbies: List<String>? = null,
@JsonProperty("values") val values: List<String>? = null,
@JsonProperty("goals") val goals: List<String>? = null,
@JsonProperty("relationships") val relationships: List<String>? = null,
@JsonProperty("relationships") val relationships: List<ChatCharacterRelationshipRequest>? = null,
@JsonProperty("personalities") val personalities: List<ChatCharacterPersonalityRequest>? = null,
@JsonProperty("backgrounds") val backgrounds: List<ChatCharacterBackgroundRequest>? = null,
@JsonProperty("memories") val memories: List<ChatCharacterMemoryRequest>? = null

View File

@ -14,8 +14,7 @@ class ChatCharacter(
// 캐릭터 이름 (API 키 내에서 유일해야 함)
var name: String,
// 캐릭터 설명
@Column(columnDefinition = "TEXT", nullable = false)
// 캐릭터 한 줄 소개
var description: String,
// AI 시스템 프롬프트
@ -113,8 +112,8 @@ class ChatCharacter(
}
// 관계 추가 헬퍼 메소드
fun addRelationship(relationShip: String) {
val relationship = ChatCharacterRelationship(relationShip, this)
fun addRelationship(name: String, relationShip: String) {
val relationship = ChatCharacterRelationship(name, relationShip, this)
relationships.add(relationship)
}
}

View File

@ -12,6 +12,7 @@ import javax.persistence.ManyToOne
@Entity
class ChatCharacterRelationship(
var name: String,
val relationShip: String,
@ManyToOne(fetch = FetchType.LAZY)

View File

@ -7,6 +7,7 @@ import kr.co.vividnext.sodalive.chat.character.dto.CharacterDetailResponse
import kr.co.vividnext.sodalive.chat.character.dto.CharacterMainResponse
import kr.co.vividnext.sodalive.chat.character.dto.CharacterMemoryResponse
import kr.co.vividnext.sodalive.chat.character.dto.CharacterPersonalityResponse
import kr.co.vividnext.sodalive.chat.character.dto.CharacterRelationshipResponse
import kr.co.vividnext.sodalive.chat.character.dto.CurationSection
import kr.co.vividnext.sodalive.chat.character.dto.RecentCharacter
import kr.co.vividnext.sodalive.chat.character.service.ChatCharacterBannerService
@ -137,7 +138,7 @@ class ChatCharacterController(
)
}
val relationships = character.relationships.map { it.relationShip }
val relationships = character.relationships.map { CharacterRelationshipResponse(it.name, it.relationShip) }
// 응답 생성
ApiResponse.ok(

View File

@ -14,7 +14,7 @@ data class CharacterDetailResponse(
val memories: List<CharacterMemoryResponse> = emptyList(),
val personalities: List<CharacterPersonalityResponse> = emptyList(),
val backgrounds: List<CharacterBackgroundResponse> = emptyList(),
val relationships: List<String> = emptyList(),
val relationships: List<CharacterRelationshipResponse> = emptyList(),
val tags: List<String> = emptyList(),
val values: List<String> = emptyList(),
val hobbies: List<String> = emptyList(),
@ -36,3 +36,8 @@ data class CharacterBackgroundResponse(
val topic: String,
val description: String
)
data class CharacterRelationshipResponse(
val name: String,
val relationShip: String
)

View File

@ -266,8 +266,8 @@ class ChatCharacterService(
* 캐릭터에 관계 추가
*/
@Transactional
fun addRelationshipToChatCharacter(chatCharacter: ChatCharacter, relationShip: String) {
chatCharacter.addRelationship(relationShip)
fun addRelationshipToChatCharacter(chatCharacter: ChatCharacter, name: String, relationShip: String) {
chatCharacter.addRelationship(name, relationShip)
saveChatCharacter(chatCharacter)
}
@ -293,7 +293,7 @@ class ChatCharacterService(
memories: List<Triple<String, String, String>> = emptyList(),
personalities: List<Pair<String, String>> = emptyList(),
backgrounds: List<Pair<String, String>> = emptyList(),
relationships: List<String> = emptyList()
relationships: List<Pair<String, String>> = emptyList()
): ChatCharacter {
val chatCharacter = createChatCharacter(
characterUUID, name, description, systemPrompt, age, gender, mbti,
@ -313,8 +313,8 @@ class ChatCharacterService(
chatCharacter.addBackground(topic, description)
}
relationships.forEach { relationShip ->
chatCharacter.addRelationship(relationShip)
relationships.forEach { (name, relationShip) ->
chatCharacter.addRelationship(name, relationShip)
}
return saveChatCharacter(chatCharacter)
@ -412,7 +412,7 @@ class ChatCharacterService(
if (request.relationships != null) {
chatCharacter.relationships.clear()
request.relationships.forEach { relationship ->
chatCharacter.addRelationship(relationship)
chatCharacter.addRelationship(relationship.name, relationship.relationShip)
}
}