Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d63c940
:sparkles: feature: 시간 자동 생성 로직
catturtle123 Aug 17, 2025
b342d3c
:sparkles: feature: datafile 관련 엔티티 수
catturtle123 Aug 17, 2025
79115f7
:sparkles: feature: 프롬프트 관련 엔티티 생성
catturtle123 Aug 17, 2025
31c2465
:sparkles: feature: 인덱스 관련 엔티티 생성
catturtle123 Aug 17, 2025
6e43a37
:sparkles: feature: 모델 엔티티 생성
catturtle123 Aug 17, 2025
4ca3f09
:bug: fix: 인덱스 심볼 생성
catturtle123 Aug 17, 2025
66c5f14
:bug: fix: 엔티티 명명 규칙 수
catturtle123 Aug 17, 2025
0c0ea96
:bug: fix: 엔티티 오류 수
catturtle123 Aug 17, 2025
625a91e
:bug: fix: size check 로직 추가
catturtle123 Aug 17, 2025
cbdf1dd
:bug: fix: enum 저장 규칙 추가
catturtle123 Aug 17, 2025
6669cb5
:recycle: refactor: Lob 추가로 멀티 밴더 확보
catturtle123 Aug 17, 2025
e929732
:rocket: chore: 엔티티 수
catturtle123 Aug 17, 2025
db5816f
:rocket: chore: 엔티티 수정
catturtle123 Aug 17, 2025
4671e1a
:rocket: chore: 엔티티 수정
catturtle123 Aug 17, 2025
8b9bf46
:rocket: chore: 인덱스 id 수정
catturtle123 Aug 17, 2025
8eeb524
:rocket: chore: 프롬프트 엔티티 Lob 수정
catturtle123 Aug 17, 2025
1b6cb96
:bug: fix: convertToDatabaseColumn 수정
catturtle123 Aug 17, 2025
b39b21c
:bug: fix: convertToEntityAttribute 디버깅 용이성
catturtle123 Aug 17, 2025
de7c5a6
:rocket: chore: ddl-auto 수정
catturtle123 Aug 17, 2025
75c51bd
:rocket: chore: unique 제약 조건 추가
catturtle123 Aug 17, 2025
1f1aefa
:bug: fix: 임베딩 사이즈 제
catturtle123 Aug 17, 2025
6579334
:recycle: refactor: pgvector 입력에 NaN/Infinity 값 유입 차단
catturtle123 Aug 17, 2025
28a397a
:recycle: refactor: converter 명 변경
catturtle123 Aug 17, 2025
1349b69
:bug: fix: 파생 매핑 제
catturtle123 Aug 17, 2025
b2c0a18
:bug: fix: JPA init 제거 (NPE) 방지
catturtle123 Aug 17, 2025
4b0f303
:zap: perf: 배치 저장 N + 1 문제 해결
catturtle123 Aug 17, 2025
90ada31
:bug: fix: 역직렬화 검증 로직 추가
catturtle123 Aug 17, 2025
ccbfcf0
:sparkles: feature: 모델 이름 추가
catturtle123 Aug 17, 2025
a2db08a
:bug: fix: 모델 관계 수정
catturtle123 Aug 17, 2025
3811cbc
:rocket: chore: 모델 정리
catturtle123 Aug 17, 2025
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
2 changes: 2 additions & 0 deletions src/main/kotlin/simplerag/ragback/RagBackApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package simplerag.ragback

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.data.jpa.repository.config.EnableJpaAuditing

@SpringBootApplication
@EnableJpaAuditing
class RagBackApplication

fun main(args: Array<String>) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package simplerag.ragback.domain.chat.entity

import jakarta.persistence.*
import simplerag.ragback.domain.index.entity.Index
import simplerag.ragback.domain.prompt.entity.Prompt
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(name = "models")
class Model(

@Column(name = "name", nullable = false, unique = true, length = 100)
val name: String,

@Column(name = "llm_model", nullable = false)
val llmModel: String,
Comment on lines +12 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

입력 유효성 보강 제안 — @notblank로 공백 문자열 방지(옵셔널)

DB 제약만으로는 빈 문자열을 막지 못합니다. Bean Validation을 추가하면 API/서비스 레이어에서 조기에 검증 가능합니다.

예시 diff:

 import jakarta.persistence.*
+import jakarta.validation.constraints.NotBlank
@@
-    @Column(name = "name", nullable = false, unique = true, length = 100)
+    @field:NotBlank
+    @Column(name = "name", nullable = false, unique = true, length = 100)
     val name: String,
@@
-    @Column(name = "llm_model", nullable = false)
+    @field:NotBlank
+    @Column(name = "llm_model", nullable = false)
     val llmModel: String,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Column(name = "name", nullable = false, unique = true, length = 100)
val name: String,
@Column(name = "llm_model", nullable = false)
val llmModel: String,
// at the top of src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt
import jakarta.persistence.*
import jakarta.validation.constraints.NotBlank
@field:NotBlank
@Column(name = "name", nullable = false, unique = true, length = 100)
val name: String,
@field:NotBlank
@Column(name = "llm_model", nullable = false)
val llmModel: String,
🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt around lines 12
to 16, the String fields lack Bean Validation to prevent blank values; add
Kotlin field-level NotBlank annotations to both properties (use @field:NotBlank
on name and llmModel), import the appropriate NotBlank class
(jakarta.validation.constraints.NotBlank or
javax.validation.constraints.NotBlank matching the project), and ensure Bean
Validation is enabled on the application so blank strings are rejected before
hitting the DB.


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "indexes_id")
val index: Index,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "prompts_id")
val prompt: Prompt,
Comment on lines +18 to +24
Copy link

@coderabbitai coderabbitai bot Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

FK 컬럼이 NULL 허용 상태 — DB 무결성 보장을 위해 optional=false + nullable=false 지정 권장

ManyToOne의 기본 optional=true, @joincolumn의 기본 nullable=true라 DB에서 NULL을 허용합니다. 모델이 항상 Index/Prompt를 가져야 한다면 명시적으로 비허용으로 바꿔 무결성을 보장하세요.

적용 diff:

-    @ManyToOne(fetch = FetchType.LAZY)
-    @JoinColumn(name = "indexes_id")
+    @ManyToOne(fetch = FetchType.LAZY, optional = false)
+    @JoinColumn(name = "indexes_id", nullable = false)
     val index: Index,

-    @ManyToOne(fetch = FetchType.LAZY)
-    @JoinColumn(name = "prompts_id")
+    @ManyToOne(fetch = FetchType.LAZY, optional = false)
+    @JoinColumn(name = "prompts_id", nullable = false)
     val prompt: Prompt,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "indexes_id")
val index: Index,
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "prompts_id")
val prompt: Prompt,
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "indexes_id", nullable = false)
val index: Index,
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "prompts_id", nullable = false)
val prompt: Prompt,
🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt around lines 18
to 24, the ManyToOne associations for index and prompt default to optional=true
and the JoinColumn defaults to nullable=true which allows NULLs in the FK
columns; update each association to declare non-optional and non-nullable by
setting @ManyToOne(optional = false) and @JoinColumn(name = "...", nullable =
false) so the ORM and DB enforce presence of Index and Prompt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프롬프트랑 인덱스가 없는 경우도 고려하려구요

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!


@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "models_id")
val id: Long? = null,
): BaseEntity()
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package simplerag.ragback.domain.document.entity

import jakarta.persistence.*
import simplerag.ragback.global.entity.BaseEntity
import java.time.LocalDateTime

@Entity
@Table(
name = "data_file",
name = "data_files",
uniqueConstraints = [UniqueConstraint(columnNames = ["sha256"])]
)
class DataFile(
Expand All @@ -22,15 +23,10 @@ class DataFile(
@Column(nullable = false, length = 64)
val sha256: String,

@Column(nullable = false, length = 2048)
@Column(nullable = false, length = 2048, name = "file_url")
val fileUrl: String,

@Column(nullable = false)
val updatedAt: LocalDateTime,

@Column(nullable = false)
val createdAt: LocalDateTime,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "data_files_id")
val id: Long? = null,
)
) : BaseEntity()
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package simplerag.ragback.domain.document.entity

import jakarta.persistence.*
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(
name = "data_file_tags",
uniqueConstraints = [UniqueConstraint(columnNames = ["data_file_id", "tag_id"])]
name = "data_files_tags",
uniqueConstraints = [UniqueConstraint(columnNames = ["data_files_id", "tags_id"])]
)
class DataFileTag(

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", nullable = false)
@JoinColumn(name = "tags_id", nullable = false)
var tag: Tag,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "data_file_id", nullable = false)
@JoinColumn(name = "data_files_id", nullable = false)
var dataFile: DataFile,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "data_files_tags_id")
val id: Long? = null,
)
): BaseEntity()
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package simplerag.ragback.domain.document.entity

import jakarta.persistence.*
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(
Expand All @@ -13,5 +14,6 @@ class Tag(
val name: String,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "tags_id")
val id: Long? = null,
Comment on lines +17 to 18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

id 컬럼명을 "tags_id"로 커스텀하면 기존 FK 매핑(특히 DataFileTag)이 깨질 수 있습니다

다른 엔티티가 기본 조인 규칙(tag_id -> 참조 테이블의 기본키 컬럼명 id)을 가정하고 있을 가능성이 큽니다. Tag의 PK 컬럼명을 tags_id로 바꾸면, @JoinColumn을 모두 맞춰 수정하지 않는 이상 런타임 매핑 오류(컬럼 미존재, FK 불일치)가 발생할 수 있습니다. 확실한 이유가 없다면 기본 컬럼명(id)을 유지하는 편이 안전합니다.

제안(기본 컬럼명으로 복구):

     @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name = "tags_id")
     val id: Long? = null,

검증 스크립트: DataFileTag 등에서의 조인 컬럼을 점검하세요.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) Tag 엔티티의 PK 컬럼 커스텀 여부 확인"
rg -n -C2 'class\s+Tag\b|@Column\s*\(\s*name\s*=\s*"tags?_id"' src/main/kotlin

echo
echo "2) DataFileTag 등 Tag를 참조하는 엔티티에서 JoinColumn 확인"
fd DataFileTag.kt -a | while read -r f; do
  echo "---- $f ----"
  rg -n -C4 '@ManyToOne|@JoinColumn|Tag\b|tags_id|tag_id' "$f" || true
done

echo
echo "3) 전역적으로 tags_id/tag_id 문자열 사용처 확인"
rg -n -C2 '\btags?_id\b' src/main/kotlin

Length of output: 3796


Tag 엔티티 PK 컬럼명 커스텀으로 인한 매핑 불일치 확인 및 수정 필요

Tag.kt에서 PK 컬럼명을 tags_id로 변경했으나, DataFileTag.kt 등에서 여전히 @JoinColumn(name = "tag_id")를 사용하고 있어 런타임 매핑 오류가 발생할 수 있습니다.
기본 컬럼명(id)으로 복구하거나, 참조 측 @JoinColumn 이름을 모두 tags_id로 통일해야 합니다.

수정이 필요한 위치:

  • src/main/kotlin/simplerag/ragback/domain/document/entity/Tag.kt:17
  • src/main/kotlin/simplerag/ragback/domain/document/entity/DataFileTag.kt:14

제안 1) Tag 엔티티를 기본 컬럼명으로 복구

 @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
-@Column(name = "tags_id")
 val id: Long? = null,

제안 2) 만약 tags_id를 유지하려면 DataFileTag.kt 수정

 @ManyToOne(fetch = FetchType.LAZY)
-@JoinColumn(name = "tag_id", nullable = false)
+@JoinColumn(name = "tags_id", nullable = false)
 var tag: Tag,
🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/document/entity/Tag.kt around lines
17-18 and
src/main/kotlin/simplerag/ragback/domain/document/entity/DataFileTag.kt around
line 14, the Tag primary key column was renamed to "tags_id" causing a mismatch
with DataFileTag which still uses @JoinColumn(name = "tag_id"); fix by either
reverting Tag.kt to use the default column name "id" (restore @Column or remove
custom name) or, if you intend to keep "tags_id", update the @JoinColumn in
DataFileTag.kt to name = "tags_id" (and adjust any other references) so both
sides use the exact same column name.

)
): BaseEntity()
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class DataFileService(
throw CustomException(ErrorCode.INVALID_INPUT)
}

val now = LocalDateTime.now()
val uploadedUrls = mutableListOf<String>()

registerRollbackCleanup(uploadedUrls)
Expand All @@ -63,7 +62,7 @@ class DataFileService(
uploadedUrls += fileUrl

val dataFile = try {
dataFileRepository.save(DataFile(meta.title, type, sizeBytes, sha256, fileUrl, now, now))
dataFileRepository.save(DataFile(meta.title, type, sizeBytes, sha256, fileUrl))
} catch (ex: DataIntegrityViolationException) {
throw FileException(ErrorCode.ALREADY_FILE, sha256)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package simplerag.ragback.domain.index.entity

import jakarta.persistence.*
import simplerag.ragback.global.entity.BaseEntity
import simplerag.ragback.global.util.FloatArrayToPgVectorStringConverter

// 임베딩 크기를 서비스단에서 검증을 해줘야함
@Entity
@Table(name = "chunk_embeddings")
class ChunkEmbedding(
Comment on lines +9 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

쿼리 성능 대비: 인덱스 전략 제안

  • FK 인덱스: chunk_embeddings(indexes_id)에 보조 인덱스를 생성해 Index 단위 조회/삭제 성능을 보장하세요.
  • pgvector 사용 시: embedding 컬럼에 IVFFlat/HNSW 인덱스 생성(적절한 lists/efConstruction 튜닝).

원하시면 Flyway/Liquibase용 마이그레이션 스니펫을 제공하겠습니다.


@Column(name = "content", nullable = false)
@Lob
val content: String,

@Convert(converter = FloatArrayToPgVectorStringConverter::class)
@Column(name = "embedding", nullable = false)
private var _embedding: FloatArray,

@Column(name = "embedding_dim", nullable = false)
val embeddingDim: Int,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "indexes_id", nullable = false)
val index: Index,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "chunk_embeddings_id")
val id: Long? = null,
): BaseEntity() {

@get:Transient
val embedding: FloatArray get() = _embedding.copyOf()

fun updateEmbedding(newVec: FloatArray) {
require(newVec.size == embeddingDim) {
"Embedding dimension mismatch: expected=$embeddingDim, got=${newVec.size}"
}
_embedding = newVec.copyOf()
}

}
Comment on lines +35 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

초기 생성 시 차원/유한성 불변식 보강: 영속화 훅 추가 권장

주석대로 서비스단 검증을 하더라도, 엔티티 차원에서 한 번 더 방어하면 데이터 오염을 원천 차단할 수 있습니다. LAZY FK 접근 없이 embeddingDim만 사용하면 안전합니다.

적용 diff:

     fun updateEmbedding(newVec: FloatArray) {
         require(newVec.size == embeddingDim) {
             "Embedding dimension mismatch: expected=$embeddingDim, got=${newVec.size}"
         }
         _embedding = newVec.copyOf()
     }
 
+    @PrePersist
+    @PreUpdate
+    private fun verifyBeforeSave() {
+        require(_embedding.size == embeddingDim) {
+            "Embedding dimension mismatch: expected=$embeddingDim, got=${_embedding.size}"
+        }
+        require(_embedding.isNotEmpty()) { "Embedding must not be empty" }
+        require(_embedding.all { it.isFinite() }) {
+            "Embedding must not contain NaN/Infinity"
+        }
+    }
 }
🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/ChunkEmbedding.kt
around lines 35 to 42, add defensive validation on the entity itself (not just
service-level) by introducing a persistence hook method (e.g., annotated
@PrePersist and @PreUpdate) that verifies the _embedding array length equals
embeddingDim and that every element is finite (no NaN or infinite values); throw
an IllegalArgumentException if checks fail; keep using newVec.copyOf() on
updates and avoid relying on lazy FK access — read embeddingDim directly so the
entity enforces its own invariants before being persisted or updated.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package simplerag.ragback.domain.index.entity

import jakarta.persistence.*
import simplerag.ragback.domain.document.entity.DataFile
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(name = "data_files_indexes")
class DataFileIndex(

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "data_files_id", nullable = false)
val dataFile: DataFile,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "indexes_id", nullable = false)
val index: Index,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "data_files_indexes_id")
val id: Long? = null,
): BaseEntity()
42 changes: 42 additions & 0 deletions src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package simplerag.ragback.domain.index.entity

import jakarta.persistence.*
import jakarta.validation.constraints.Min
import simplerag.ragback.domain.index.entity.enums.EmbeddingModel
import simplerag.ragback.domain.index.entity.enums.SimilarityMetric
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(name = "indexes")
class Index(

@Column(name = "snapshot_name", length = 255, nullable = false)
val snapshotName: String,

@Column(name = "chunking_size", nullable = false)
@Min(1)
val chunkingSize: Int,

@Column(name = "overlap_size", nullable = false)
@Min(0)
val overlapSize: Int,
Comment on lines +16 to +22
Copy link

@coderabbitai coderabbitai bot Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

교차 필드 제약 추가: overlapSize ≤ chunkingSize

일반적으로 overlap은 청킹 크기를 초과할 수 없습니다. Bean Validation으로 빠르게 실패시키고, 스키마에도 CHECK 제약을 고려하세요.

예시(클래스 내부에 추가):

import jakarta.validation.constraints.AssertTrue

@get:AssertTrue(message = "overlapSize must be <= chunkingSize")
val isValidOverlap: Boolean
    get() = overlapSize <= chunkingSize

Also applies to: 28-31

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt around lines
16-22 (and also apply the same change around lines 28-31), add a Bean Validation
cross-field check to ensure overlapSize ≤ chunkingSize by introducing a
read-only boolean property annotated with @get:AssertTrue that returns
overlapSize <= chunkingSize; also update the DB schema to include a CHECK
constraint (e.g., CHECK (overlap_size <= chunking_size)) so the constraint is
enforced at the database level as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 나중에 서비스 단에서 검증해도 되겠죠?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catturtle123 네, 맞습니다! 서비스 레이어에서 검증하는 것도 충분히 좋은 접근법입니다. 서비스 레이어에서 검증하면 더 구체적인 에러 메시지를 제공할 수 있고, 비즈니스 로직과 함께 관리하기도 편하죠.

엔티티 레벨 검증은 선택사항이니까 나중에 필요하다고 느끼시면 그때 추가하셔도 됩니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 나중에 제가 chunking embedding 저장 관련 PR 올렸을때 언질해주세요

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catturtle123 네, 알겠습니다! chunking embedding 저장 관련 PR에서 overlapSize ≤ chunkingSize 검증 로직을 서비스 레이어에 추가하는 것을 잊지 않고 언급해드리겠습니다.


✏️ Learnings added
Learnt from: catturtle123
PR: Simple-RAG/BACK#6
File: src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt:16-22
Timestamp: 2025-08-17T13:12:02.200Z
Learning: catturtle123이 Index 엔티티의 overlapSize ≤ chunkingSize 검증을 엔티티 레벨이 아닌 서비스 레이어에서 구현하기로 결정했으며, chunking embedding 저장 관련 PR에서 이 검증 로직을 추가할 예정이므로 해당 PR에서 언급해야 함 (Simple-RAG/BACK 프로젝트)

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: catturtle123
PR: Simple-RAG/BACK#6
File: src/main/kotlin/simplerag/ragback/domain/index/entity/ChunkEmbedding.kt:6-22
Timestamp: 2025-08-17T07:14:26.887Z
Learning: ChunkEmbedding 엔티티에서 embedding 필드는 벡터 임베딩 저장용이고, content 필드는 원본 파일/텍스트 청크 저장용으로 설계됨 (catturtle123 프로젝트)


@Column(name = "similarity_metric", nullable = false)
@Enumerated(EnumType.STRING)
val similarityMetric: SimilarityMetric,

@Column(name = "top_k", nullable = false)
@Min(1)
val topK: Int,

@Column(name = "embedding_model", nullable = false, length = 255)
@Enumerated(EnumType.STRING)
val embeddingModel: EmbeddingModel,

@Column(name = "reranker", nullable = false)
val reranker: Boolean,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "indexes_id")
val id: Long? = null,
Comment on lines +39 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

id 컬럼 명시는 선택 사항 — 컨벤션 일관성 검토

다른 엔티티(Tag/DataFile)는 기본 컬럼명(id)을 사용합니다. 여기서만 indexes_id를 유지할 특별한 이유가 없다면 기본값으로 단순화(또는 프로젝트 전반 동일 네이밍 채택)해 컨벤션 일관성을 맞추는 것을 고려해 주세요.

예시(선택):

-    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name = "indexes_id")
-    val id: Long? = null,
+    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
+    val id: Long? = null,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "indexes_id")
val id: Long? = null,
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null,
🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt around lines
37 to 39, the explicit @Column(name = "indexes_id") breaks naming consistency
with other entities using the default "id"; remove the explicit name (or rename
other entities to the same convention) so the field uses the default column name
`id`, and if your database schema must keep the existing column, update the
mapping consistently or add a migration to rename the column to `id` to maintain
project-wide naming consistency.

): BaseEntity()
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package simplerag.ragback.domain.index.entity.enums

enum class EmbeddingModel(
val dim: Int,
val modelId: String
) {
Comment on lines +3 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

toString 오버라이드로 로깅/표시 안정성 향상 (선택)

운영 로그/에러 메시지 가독성을 위해 override fun toString() = modelId를 고려해 보세요. 외부 노출 시에도 공급자 식별자가 직접 보여 가독성이 좋아집니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 3 to 6, add an override of toString that returns the modelId to
improve logging/readability; implement override fun toString() = modelId inside
the enum so when instances are logged or displayed the provider identifier is
shown directly.

🧹 Nitpick (assertive)

Provider 메타데이터 추가를 고려해 주세요 (OPENAI/HF/MISTRAL 등)

API 라우팅, 레이트리밋/자격증명 분리, 로깅 필터링을 위해 provider 필드를 enum에 추가하는 것을 권장합니다. 예: enum class EmbeddingProvider { OPENAI, HUGGING_FACE, MISTRAL, LOCAL }val provider: EmbeddingProvider를 각 상수에 채워두면 클라이언트 선택이 단순해집니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 3 to 6, the enum lacks provider metadata which makes routing,
rate-limiting and credential handling harder; add a new enum EmbeddingProvider
(e.g., OPENAI, HUGGING_FACE, MISTRAL, LOCAL) and add a provider:
EmbeddingProvider property to EmbeddingModel, then update each enum constant to
supply the appropriate provider value and adjust usages/constructors throughout
the codebase to accept the new parameter.

🧹 Nitpick (assertive)

JPA 저장 전략 재검토 — Enum 이름 변경 리스크 완화

AI 요약에 따르면 Index 엔티티에서 @Enumerated(EnumType.STRING)으로 저장 중입니다. enum 상수명을 바꾸면(이번 distiluse 케이스처럼) 기존 데이터가 깨집니다. Enum 대신 modelId를 영속화하도록 AttributeConverter를 도입하는 방식을 권장합니다.

다음 예시는 Converter 스켈레톤입니다:

import jakarta.persistence.AttributeConverter
import jakarta.persistence.Converter
import simplerag.ragback.domain.index.entity.enums.EmbeddingModel

@Converter(autoApply = false)
class EmbeddingModelConverter : AttributeConverter<EmbeddingModel, String> {
    override fun convertToDatabaseColumn(attribute: EmbeddingModel?): String? =
        attribute?.modelId

    override fun convertToEntityAttribute(dbData: String?): EmbeddingModel? =
        dbData?.let { EmbeddingModel.findByModelId(it) }
}

엔티티 필드에 @Convert(converter = EmbeddingModelConverter::class)를 부여하면 enum 상수명 변경에도 DB 값은 안정적으로 유지됩니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 3 to 6, the enum is currently persisted via its constant name which
breaks when you rename constants; replace this by implementing a JPA
AttributeConverter that persists the modelId string instead, add a companion
lookup method on EmbeddingModel (e.g., findByModelId) to map DB values back to
enum instances, update the Index entity field to use @Convert(converter =
EmbeddingModelConverter::class) (and remove/stop using
@Enumerated(EnumType.STRING) for that field), and ensure the converter handles
nulls safely so existing DB values remain valid when enum constant names change.

Comment on lines +1 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

JPA 영속 안정성 강화: enum 이름 대신 modelId로 저장하도록 Converter 전환 권장

AI 요약상 Index 엔티티에서 @Enumerated(EnumType.STRING)으로 저장 중이라면, 상수명 변경 시 기존 데이터가 깨집니다. modelId를 DB에 저장하도록 AttributeConverter로 전환하면 리네이밍 리스크를 제거할 수 있습니다.

예시 Converter:

import jakarta.persistence.AttributeConverter
import jakarta.persistence.Converter

@Converter(autoApply = false)
class EmbeddingModelConverter : AttributeConverter<EmbeddingModel, String> {
    override fun convertToDatabaseColumn(attribute: EmbeddingModel?): String? =
        attribute?.modelId

    override fun convertToEntityAttribute(dbData: String?): EmbeddingModel? =
        dbData?.let { EmbeddingModel.findByModelId(it) }
}

엔티티 필드 적용 예시:

@Convert(converter = EmbeddingModelConverter::class)
@Column(name = "embedding_model", nullable = false)
var embeddingModel: EmbeddingModel

이후에는 enum 상수명을 정리(예: MPNET 표기)하더라도 DB 값(=modelId)은 변하지 않아 안전합니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 1 to 6, switch persistence from storing enum names to storing the
stable modelId by implementing a Jakarta Persistence AttributeConverter that
maps EmbeddingModel ⇄ String using modelId (convertToDatabaseColumn returns
attribute?.modelId, convertToEntityAttribute looks up EmbeddingModel by modelId
via a findByModelId function), then annotate the entity field with
@Convert(converter = EmbeddingModelConverter::class) and set the @Column to use
the existing embedding_model column; ensure the converter handles nulls and that
EmbeddingModel exposes a lookup method to find an enum by modelId.

// OpenAI
TEXT_EMBEDDING_3_SMALL(1536, "text-embedding-3-small"),
TEXT_EMBEDDING_3_LARGE(3072, "text-embedding-3-large"),

// SBERT / HuggingFace
ALL_MINILM_L6_V2(384, "sentence-transformers/all-MiniLM-L6-v2"),
ALL_MP_NET_BASE_V2(768, "sentence-transformers/all-mpnet-base-v2"),
MULTI_QA_MP_NET_BASE_DOT_V1(768, "sentence-transformers/multi-qa-mpnet-base-dot-v1"),
Comment on lines +12 to +14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

상수명 일관성(Nit): MPNET 철자 통일 고려

ALL_MP_NET_BASE_V2, MULTI_QA_MP_NET_BASE_DOT_V1는 보통 “MPNET”로 붙여 표기합니다. 신규 파일이고 아직 DB에 enum 문자열이 저장되지 않았다면 ALL_MPNET_BASE_V2, MULTI_QA_MPNET_BASE_DOT_V1로의 리네이밍을 검토해 주세요. 만약 이미 JPA로 문자열이 저장된다면 마이그레이션이 필요합니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 13 to 15, the enum constant names use inconsistent spelling
“MP_NET” vs common “MPNET”; rename ALL_MP_NET_BASE_V2 to ALL_MPNET_BASE_V2 and
MULTI_QA_MP_NET_BASE_DOT_V1 to MULTI_QA_MPNET_BASE_DOT_V1, then update all
references/usages (imports, switch/when branches, tests, serializers)
accordingly; if enum names are persisted as strings via JPA/DB, do not rename
without adding a migration that maps old stored values to the new names (or keep
@EnumValue/explicit persisted strings) and verify serialization/deserialization
and API contract after the change.

DISTILUSE_BASE_MULTILINGUAL_CASED_V2(512, "sentence-transformers/distiluse-base-multilingual-cased-v2"),
PARAPHRASE_MULTILINGUAL_MINILM_L12_V2(384, "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"),
KO_SBERT_V1(768, "jhgan/ko-sbert-v1"),
KOR_SROBERTA(768, "jhgan/ko-sroberta-medium-nli"),

// Korean specific
BM_KO_SMALL(512, "bespin-global/klue-sroberta-base-continue-learning-by-mnr"),

// Instructor / Mistral
INSTRUCTOR_BASE(768, "hkunlp/instructor-base"),
INSTRUCTOR_XL(1024, "hkunlp/instructor-xl"),
MISTRAL_EMBED(1024, "mistral-embed"),

// BGE / E5 etc
BGE_SMALL_EN(384, "BAAI/bge-small-en-v1.5"),
BGE_BASE_EN(768, "BAAI/bge-base-en-v1.5"),
BGE_LARGE_EN(1024, "BAAI/bge-large-en-v1.5"),
BGE_M3(1024, "BAAI/bge-m3"),
E5_SMALL(384, "intfloat/e5-small-v2"),
E5_BASE(768, "intfloat/e5-base-v2"),
E5_LARGE(1024, "intfloat/e5-large-v2"),
Comment on lines +28 to +35
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

차원 수(dimension) 정확성 교차 검증 자동화 제안

HF 모델의 config에서 hidden_size를 읽어 현재 enum의 dim과 비교해 일관성을 점검하세요. 일부 모델은 구조가 달라(예: T5류의 d_model) 수동 검토가 필요할 수 있습니다.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

declare -A EXPECTED=(
  ["BAAI/bge-small-en-v1.5"]=384
  ["BAAI/bge-base-en-v1.5"]=768
  ["BAAI/bge-large-en-v1.5"]=1024
  ["BAAI/bge-m3"]=1024
  ["intfloat/e5-small-v2"]=384
  ["intfloat/e5-base-v2"]=768
  ["intfloat/e5-large-v2"]=1024
)

echo "Model,Field,ConfigValue,Expected,OK"
for m in "${!EXPECTED[@]}"; do
  cfg=$(curl -fsSL "https://huggingface.co/${m}/resolve/main/config.json" || true)
  if [ -z "$cfg" ]; then
    echo "${m},(no-config),-,${EXPECTED[$m]},false"
    continue
  fi
  # 우선 hidden_size, 없으면 d_model 시도
  hidden=$(printf '%s' "$cfg" | jq -r 'select(.hidden_size)!=null | .hidden_size' 2>/dev/null || true)
  field="hidden_size"
  val="$hidden"
  if [ -z "$hidden" ] || [ "$hidden" = "null" ]; then
    dmodel=$(printf '%s' "$cfg" | jq -r 'select(.d_model)!=null | .d_model' 2>/dev/null || true)
    field="d_model"
    val="$dmodel"
  fi
  ok="false"
  if [ "$val" = "${EXPECTED[$m]}" ]; then ok="true"; fi
  echo "${m},${field},${val},${EXPECTED[$m]},${ok}"
done

Length of output: 23128


자동 차원 검증 테스트/CI 스크립트 추가 권장

현재 EmbeddingModel enum에 정의된 차원 값은 Hugging Face 모델의 config.json에 명시된 hidden_size(또는 d_model)과 모두 일치합니다. 하지만 유지 보수성을 높이고, 새로운 모델 추가 시 실수를 방지하기 위해 아래와 같이 자동 교차 검증을 도입하세요.

  • HF 모델의 config.json(https://huggingface.co/{repo}/resolve/main/config.json)에서
    • 우선 .hidden_size 필드를 조회
    • 없으면 .d_model 필드를 조회
  • 조회한 값과 enum에 정의된 차원 값 비교
  • 실패할 경우 CI에서 에러를 발생시켜 수정 유도

예시 스크립트:

#!/usr/bin/env bash
set -euo pipefail

declare -A EXPECTED=( 
  [BAAI/bge-small-en-v1.5]=384 
  [BAAI/bge-base-en-v1.5]=768 
  # …생략… 
)

for m in "${!EXPECTED[@]}"; do
  cfg_url="https://huggingface.co/${m}/resolve/main/config.json"
  dim=$(curl -fsSL "$cfg_url" \
    | jq -r 'if has("hidden_size") then .hidden_size else .d_model end')
  if [ "$dim" -ne "${EXPECTED[$m]}" ]; then
    echo "ERROR: $m expected=${EXPECTED[$m]} actual=$dim"
    exit 1
  fi
done

참고: T5 계열처럼 d_model만 제공하는 경우는 위 스크립트 로직으로도 검증됩니다.
이 자동화는 향후 모델 추가·업데이트 시 실수를 방지하는 데 도움이 됩니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 32 to 39, add an automated cross-check in CI that validates each
enum's declared dimension against the model's Hugging Face config.json (check
.hidden_size first, fallback to .d_model) and fail the build on mismatch;
implement this by creating a simple CI script or test that holds a map of
repo->expected_dim, fetches
https://huggingface.co/{repo}/resolve/main/config.json, reads hidden_size or
d_model, compares to the enum value, and exits non‑zero (or throws an assertion)
when any mismatch is found so future model additions/updates are validated
automatically.


// Old word vectors
FASTTEXT_KO(300, "fasttext-ko-300d");

companion object {
fun findByModelId(modelId: String): EmbeddingModel? {
return entries.find { it.modelId == modelId }
}

fun getAllModelIds(): List<String> {
return entries.map { it.modelId }
}
Comment on lines +40 to +47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

O(n) 선형 탐색 제거 및 Kotlin 버전 호환성 보강 (entries 의존 제거)

entries.find { ... }는 빈번 호출 시 비용이 누적되고, Kotlin < 1.9 환경에선 entries 미지원 이슈가 발생합니다. 정적 맵으로 O(1) 조회 + values() 기반으로 호환성 확보를 권장합니다. 또한 모델 ID 목록은 선언 순서를 유지하도록 values()를 사용하세요.

-    companion object {
-        fun findByModelId(modelId: String): EmbeddingModel? {
-            return entries.find { it.modelId == modelId }
-        }
-
-        fun getAllModelIds(): List<String> {
-            return entries.map { it.modelId }
-        }
-    }
+    companion object {
+        private val ALL: Array<EmbeddingModel> = values()
+        private val BY_MODEL_ID: Map<String, EmbeddingModel> = ALL.associateBy { it.modelId }
+
+        @JvmStatic
+        fun findByModelId(modelId: String): EmbeddingModel? = BY_MODEL_ID[modelId]
+
+        @JvmStatic
+        fun getAllModelIds(): List<String> = ALL.map { it.modelId }
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
companion object {
fun findByModelId(modelId: String): EmbeddingModel? {
return entries.find { it.modelId == modelId }
}
fun getAllModelIds(): List<String> {
return entries.map { it.modelId }
}
companion object {
private val ALL: Array<EmbeddingModel> = values()
private val BY_MODEL_ID: Map<String, EmbeddingModel> = ALL.associateBy { it.modelId }
@JvmStatic
fun findByModelId(modelId: String): EmbeddingModel? = BY_MODEL_ID[modelId]
@JvmStatic
fun getAllModelIds(): List<String> = ALL.map { it.modelId }
}
🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 44 to 51, replace the current entries-based linear search and
entries dependency with a static lookup map built from values() for O(1) lookup
and use values() to produce the model-id list to preserve declaration order and
ensure Kotlin <1.9 compatibility; add a private val MODEL_BY_ID =
values().associateBy { it.modelId } in the companion object and change
findByModelId to return MODEL_BY_ID[modelId], and change getAllModelIds to
return values().map { it.modelId } so you no longer rely on entries and get
constant-time lookups and stable ordering.

}
Comment on lines +40 to +48
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

간단한 단위 테스트 추가 제안

  • 모든 상수에 대해 findByModelId(modelId) == constant 보장
  • getAllModelIds()가 중복 없이 전체를 포괄하고 선언 순서를 유지

원하시면 테스트 템플릿 생성해 드리겠습니다.

🤖 Prompt for AI Agents
In src/main/kotlin/simplerag/ragback/domain/index/entity/enums/EmbeddingModel.kt
around lines 44 to 52, add unit tests that (1) iterate every enum entry and
assert findByModelId(entry.modelId) == entry to guarantee the lookup maps to the
exact constant, and (2) assert getAllModelIds() returns a list equal to
entries.map { it.modelId } (no duplicates, covers all entries and preserves
declaration order); implement these tests using the project test framework
(e.g., JUnit + Kotest/assertJ) and include clear failure messages for easier
debugging.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package simplerag.ragback.domain.index.entity.enums

enum class SimilarityMetric(
val description: String
) {
COSINE("코사인 유사도"),
EUCLIDEAN("유클리드 거리"),
DOT_PRODUCT("내적 유사도")
}
Comment on lines +3 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

유사도 메트릭 enum 추가는 적절하나, 도메인 계층에 사용자 노출 문자열을 하드코딩하면 i18n/문구 변경에 취약

라벨을 바로 한글로 포함하기보다, 메시지 키를 함께 보관하고 표현 계층에서 국제화 리소스로 치환하는 방식을 권장합니다. 하위 호환에 주의하여 적용하세요.

예시(메시지 키 추가):

-enum class SimilarityMetric(
-    val description: String
-) {
-    COSINE("코사인 유사도"),
-    EUCLIDEAN("유클리드 거리"),
-    DOT_PRODUCT("내적 유사도")
-}
+enum class SimilarityMetric(
+    val description: String,
+    val messageKey: String
+) {
+    COSINE("코사인 유사도", "similarity.cosine"),
+    EUCLIDEAN("유클리드 거리", "similarity.euclidean"),
+    DOT_PRODUCT("내적 유사도", "similarity.dotProduct")
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enum class SimilarityMetric(
val description: String
) {
COSINE("코사인 유사도"),
EUCLIDEAN("유클리드 거리"),
DOT_PRODUCT("내적 유사도")
}
enum class SimilarityMetric(
val description: String,
val messageKey: String
) {
COSINE("코사인 유사도", "similarity.cosine"),
EUCLIDEAN("유클리드 거리", "similarity.euclidean"),
DOT_PRODUCT("내적 유사도", "similarity.dotProduct")
}
🤖 Prompt for AI Agents
In
src/main/kotlin/simplerag/ragback/domain/index/entity/enums/SimilarityMetric.kt
around lines 3 to 9, the enum currently hardcodes a Korean label in the domain
layer which is fragile for i18n and copy changes; change the enum to store a
stable message key (e.g. messageKey: String) instead of a presentation string
and keep the existing description field behavior via a deprecated secondary
property or a mapping function to preserve backward compatibility; update usages
to resolve the message key in the presentation layer using resource
bundles/localization utilities so text rendering is done outside the domain
layer.

28 changes: 28 additions & 0 deletions src/main/kotlin/simplerag/ragback/domain/prompt/entity/FewShot.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package simplerag.ragback.domain.prompt.entity

import jakarta.persistence.*
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(name = "few_shots")
class FewShot(

@Column(name = "question", nullable = false, length = 255)
val question: String,

@Column(name = "answer", nullable = false)
@Lob
val answer: String,

@Column(name = "evidence", nullable = false)
@Lob
val evidence: String,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "prompts_id", nullable = false)
val prompt: Prompt,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "few_shots_id")
val id: Long? = null,
): BaseEntity()
25 changes: 25 additions & 0 deletions src/main/kotlin/simplerag/ragback/domain/prompt/entity/Prompt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package simplerag.ragback.domain.prompt.entity

import jakarta.persistence.*
import simplerag.ragback.domain.prompt.entity.enums.PreSet
import simplerag.ragback.global.entity.BaseEntity

@Entity
@Table(name = "prompts")
class Prompt(

@Column(name = "name", length = 100, nullable = false)
val name: String,

@Enumerated(EnumType.STRING)
@Column(name = "pre_set", nullable = false)
val preSet: PreSet,

@Column(name = "system_prompt", nullable = false)
@Lob
val systemPrompt: String,

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "prompts_id")
val id: Long? = null,
): BaseEntity()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package simplerag.ragback.domain.prompt.entity.enums

enum class PreSet {
NONE
}
Loading