-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Feature: create prompt #22
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package simplerag.ragback.domain.prompt.controller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import jakarta.validation.Valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.http.HttpStatus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.domain.prompt.dto.PromptCreateRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.domain.prompt.dto.PromptPreviewResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.domain.prompt.service.PromptService | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.global.response.ApiResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RestController | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequestMapping("/api/v1/prompts") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class PromptController( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private val promptService: PromptService | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @PostMapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @ResponseStatus(HttpStatus.CREATED) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fun createPrompt( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequestBody @Valid promptCreateRequest: PromptCreateRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): ApiResponse<PromptPreviewResponse> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val savedPrompt = promptService.createPrompt(promptCreateRequest) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ApiResponse.ok(savedPrompt) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Optional: set Location header for the created resource If Example (illustrative): -import org.springframework.http.HttpStatus
+import org.springframework.http.HttpStatus
+import org.springframework.http.ResponseEntity
+import org.springframework.http.HttpHeaders
+import org.springframework.web.util.UriComponentsBuilder
@@
- @ResponseStatus(HttpStatus.CREATED)
- fun createPrompt(
+ fun createPrompt(
@RequestBody @Valid promptCreateRequest: PromptCreateRequest
- ): ApiResponse<PromptPreviewResponse> {
- val savedPrompt = promptService.createPrompt(promptCreateRequest)
- return ApiResponse.ok(savedPrompt)
+ ): ResponseEntity<ApiResponse<PromptPreviewResponse>> {
+ val savedPrompt = promptService.createPrompt(promptCreateRequest)
+ val location = UriComponentsBuilder.fromPath("/api/v1/prompts/{id}")
+ .buildAndExpand(savedPrompt.id)
+ .toUri()
+ return ResponseEntity
+ .status(HttpStatus.CREATED)
+ .header(HttpHeaders.LOCATION, location.toString())
+ .body(ApiResponse.ok(savedPrompt))
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package simplerag.ragback.domain.prompt.dto | ||
|
|
||
| import jakarta.validation.constraints.Size | ||
| import simplerag.ragback.domain.prompt.entity.enums.PreSet | ||
|
|
||
|
|
||
| data class PromptCreateRequest( | ||
| @field:Size(max = 100) | ||
| val name: String, | ||
|
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Align DTO with DB non-null constraint for name; add @notblank The DB declares name NOT NULL with length 100. Add @notblank in addition to @SiZe to block all-whitespace names. Apply the 🤖 Prompt for AI Agents |
||
| val preSet: PreSet, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider renaming preSet → preset for consistent, idiomatic naming The mixed-case “PreSet” leaks into the API as 🤖 Prompt for AI Agents |
||
| @field:Size(max = 20000) | ||
| val systemPrompt: String, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| package simplerag.ragback.domain.prompt.dto | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.domain.prompt.entity.Prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Import PreSet if exposing it in the response If you include preset in the preview, add the missing import. Apply this diff if you adopt the response changes below: -import simplerag.ragback.domain.prompt.entity.Prompt
+import simplerag.ragback.domain.prompt.entity.Prompt
+import simplerag.ragback.domain.prompt.entity.enums.PreSet📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| data class PromptPreviewResponse( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val id: Long, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| companion object { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| fun from( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt: Prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ): PromptPreviewResponse { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return PromptPreviewResponse(prompt.id) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Return minimally useful metadata in the preview (id, name, preset) Returning only Apply this diff: -data class PromptPreviewResponse(
- val id: Long,
-) {
- companion object {
- fun from(
- prompt: Prompt
- ): PromptPreviewResponse {
- return PromptPreviewResponse(prompt.id)
- }
- }
-}
+data class PromptPreviewResponse(
+ val id: Long,
+ val name: String,
+ val preSet: PreSet,
+) {
+ companion object {
+ fun from(prompt: Prompt): PromptPreviewResponse =
+ PromptPreviewResponse(
+ id = prompt.id,
+ name = prompt.name,
+ preSet = prompt.preSet,
+ )
+ }
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,8 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package simplerag.ragback.domain.prompt.entity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import jakarta.persistence.* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.domain.prompt.entity.enums.PreSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import jakarta.persistence.* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.domain.prompt.dto.PromptCreateRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import simplerag.ragback.global.entity.BaseEntity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Entity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -19,8 +20,31 @@ class Prompt( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Lob | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val systemPrompt: String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : BaseEntity() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : BaseEntity() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Column(name = "prompts_id") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val id: Long = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
24
to
26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify your Kotlin JPA configuration if keeping Hibernate must set this generated id on a Run this quick check: 🏁 Script executed: #!/bin/bash
# Verify Kotlin JPA/all-open is enabled
rg -nP 'kotlin\("plugin\.jpa"\)|allOpen|kotlin-jpa' -g 'build.gradle*' -C2 || trueLength of output: 267 🏁 Script executed: #!/bin/bash
# Display the first 50 lines of build.gradle* to inspect plugin declarations
head -n 50 build.gradle build.gradle.kts || trueLength of output: 1683 Verify Kotlin JPA compiler plugin setup – confirms ID handling Your Gradle configuration already applies the necessary Kotlin compiler plugins to support JPA entities:
Given this setup, Hibernate will correctly set the generated val id: Long? = nulland update any DTO mappings accordingly to use 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| companion object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fun from( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest: PromptCreateRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): Prompt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val prompt = if (promptCreateRequest.preSet == PreSet.CUSTOM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Prompt( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest.preSet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest.systemPrompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Prompt( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest.preSet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptCreateRequest.preSet.defaultSystemPrompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Normalize inputs, enforce invariants, and fail fast if presets are not configured
Apply this diff within the factory: companion object {
fun from(
promptCreateRequest: PromptCreateRequest
): Prompt {
-
- val prompt = if (promptCreateRequest.preSet == PreSet.CUSTOM) {
- Prompt(
- promptCreateRequest.name,
- promptCreateRequest.preSet,
- promptCreateRequest.systemPrompt
- )
- } else {
- Prompt(
- promptCreateRequest.name,
- promptCreateRequest.preSet,
- promptCreateRequest.preSet.defaultSystemPrompt
- )
- }
-
- return prompt
+ val name = promptCreateRequest.name.trim()
+ require(name.isNotBlank()) { "Prompt name must not be blank." }
+
+ val resolvedSystemPrompt = when (promptCreateRequest.preSet) {
+ PreSet.CUSTOM -> (promptCreateRequest.systemPrompt ?: "").trim()
+ else -> promptCreateRequest.preSet.defaultSystemPrompt.trim()
+ }
+
+ require(resolvedSystemPrompt.isNotBlank()) {
+ "systemPrompt must not be blank. For non-CUSTOM presets, defaultSystemPrompt must be configured."
+ }
+ if (promptCreateRequest.preSet != PreSet.CUSTOM &&
+ resolvedSystemPrompt.startsWith("TODO", ignoreCase = true)
+ ) {
+ throw IllegalStateException("Preset ${promptCreateRequest.preSet} defaultSystemPrompt is not configured.")
+ }
+
+ return Prompt(
+ name = name,
+ preSet = promptCreateRequest.preSet,
+ systemPrompt = resolvedSystemPrompt,
+ )
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,65 @@ | ||
| package simplerag.ragback.domain.prompt.entity.enums | ||
|
|
||
| enum class PreSet { | ||
| NONE | ||
| enum class PreSet( | ||
| val description: String, | ||
| val defaultSystemPrompt: String | ||
| ) { | ||
|
Comment on lines
+3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Future-proof the enum API by decoupling data from code Hardcoding large prompt bodies in an enum couples deployments to copy updates. If you keep the current shape, at least document that 🤖 Prompt for AI Agents |
||
| CUSTOM( | ||
| "User-defined custom prompt", | ||
| "TODO: custom system prompt here" | ||
| ), | ||
|
|
||
| // Retrieval / Q&A | ||
| RAG_QA( | ||
| "Question Answering with retrieved context", | ||
| "TODO: system prompt for RAG_QA" | ||
| ), | ||
| RAG_SUMMARIZER( | ||
| "Summarize documents retrieved via RAG", | ||
| "TODO: system prompt for RAG_SUMMARIZER" | ||
| ), | ||
|
|
||
| // Code related | ||
| CODE_REVIEW_BACKEND( | ||
| "Backend code review (Java/Kotlin/Spring)", | ||
| "TODO: system prompt for CODE_REVIEW_BACKEND" | ||
| ), | ||
| CODE_REVIEW_GENERAL( | ||
| "General code review and best practices", | ||
| "TODO: system prompt for CODE_REVIEW_GENERAL" | ||
| ), | ||
|
|
||
| // Language tasks | ||
| TRANSLATION_EN_KO( | ||
| "English ↔ Korean translation", | ||
| "TODO: system prompt for TRANSLATION_EN_KO" | ||
| ), | ||
| TRANSLATION_MULTI( | ||
| "Multi-language translation", | ||
| "TODO: system prompt for TRANSLATION_MULTI" | ||
| ), | ||
| PROOFREAD_KR( | ||
| "Korean proofreading / grammar correction", | ||
| "TODO: system prompt for PROOFREAD_KR" | ||
| ), | ||
|
|
||
| // Content tasks | ||
| TEXT_SUMMARIZER( | ||
| "General text summarization", | ||
| "TODO: system prompt for TEXT_SUMMARIZER" | ||
| ), | ||
| DATA_CLEANER( | ||
| "Text cleaning and preprocessing", | ||
| "TODO: system prompt for DATA_CLEANER" | ||
| ), | ||
| EMAIL_WRITER( | ||
| "Email / message generation", | ||
| "TODO: system prompt for EMAIL_WRITER" | ||
| ), | ||
|
|
||
| // Safety / Guardrails | ||
| SAFETY_FILTERED( | ||
| "Safe response (avoid harmful or unsafe outputs)", | ||
| "TODO: system prompt for SAFETY_FILTERED" | ||
| ) | ||
|
Comment on lines
+7
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Do not ship with “TODO” default prompts — this violates requirements and will persist placeholders Per PR objectives (“Add OpenSource Prompt Set”), every non-CUSTOM preset currently writes “TODO …” into the database via Pick one of the following immediately:
Minimal, immediate fix (replace only the string literals below): @@
CUSTOM(
"User-defined custom prompt",
- "TODO: custom system prompt here"
+ "" // Not used — CUSTOM comes from request
),
@@
RAG_QA(
"Question Answering with retrieved context",
- "TODO: system prompt for RAG_QA"
+ "You are a grounded QA assistant. Use ONLY the provided CONTEXT to answer. If the answer is not in CONTEXT, say \"I don't know\". Cite sources by title or id."
),
RAG_SUMMARIZER(
"Summarize documents retrieved via RAG",
- "TODO: system prompt for RAG_SUMMARIZER"
+ "Summarize the provided CONTEXT for a busy reader. Use bullet points, keep facts verifiable, avoid speculation, and include key entities, dates, and numbers."
),
@@
CODE_REVIEW_BACKEND(
"Backend code review (Java/Kotlin/Spring)",
- "TODO: system prompt for CODE_REVIEW_BACKEND"
+ "Review backend code (Kotlin/Java/Spring). Focus on correctness, concurrency, security, input validation, performance, error handling, transactions, and testability. Output concise action items with code snippets."
),
CODE_REVIEW_GENERAL(
"General code review and best practices",
- "TODO: system prompt for CODE_REVIEW_GENERAL"
+ "Perform a pragmatic code review. Identify bugs, edge cases, readability issues, dead code, and missing tests. Propose minimal diffs to fix critical issues."
),
@@
TRANSLATION_EN_KO(
"English ↔ Korean translation",
- "TODO: system prompt for TRANSLATION_EN_KO"
+ "Translate between English and Korean. Preserve meaning, tone, and formatting. Provide only the translation without additional commentary."
),
TRANSLATION_MULTI(
"Multi-language translation",
- "TODO: system prompt for TRANSLATION_MULTI"
+ "Translate between the user’s source and target languages. Maintain tone and formatting. Do not add explanations unless asked."
),
PROOFREAD_KR(
"Korean proofreading / grammar correction",
- "TODO: system prompt for PROOFREAD_KR"
+ "Proofread Korean text. Fix grammar, spacing, and style while preserving meaning. Output only the corrected text."
),
@@
TEXT_SUMMARIZER(
"General text summarization",
- "TODO: system prompt for TEXT_SUMMARIZER"
+ "Summarize the text in 5–7 bullet points. Be faithful, concise, and include critical facts (who/what/when/where/why)."
),
DATA_CLEANER(
"Text cleaning and preprocessing",
- "TODO: system prompt for DATA_CLEANER"
+ "Normalize whitespace, remove boilerplate, fix common encoding issues, and standardize quotes and dashes. Preserve semantic content."
),
EMAIL_WRITER(
"Email / message generation",
- "TODO: system prompt for EMAIL_WRITER"
+ "Draft a clear, polite email given purpose, audience, and key points. Include subject and body. Keep it concise and actionable."
),
@@
SAFETY_FILTERED(
"Safe response (avoid harmful or unsafe outputs)",
- "TODO: system prompt for SAFETY_FILTERED"
+ "Follow safety best practices. Refuse requests involving illegal, harmful, or sensitive content. Offer safe alternatives when declining."
)Longer-term architecture (recommended):
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package simplerag.ragback.domain.prompt.repository | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import simplerag.ragback.domain.prompt.entity.Prompt | ||
|
|
||
| interface PromptRepository: JpaRepository<Prompt, Long> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Style nit + add helper to prevent duplicate names
Apply this diff: -interface PromptRepository: JpaRepository<Prompt, Long>
+interface PromptRepository : JpaRepository<Prompt, Long> {
+ fun existsByName(name: String): Boolean
+}And add a unique constraint on @Table(
name = "prompts",
uniqueConstraints = [UniqueConstraint(name = "uk_prompts_name", columnNames = ["name"])]
)🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package simplerag.ragback.domain.prompt.service | ||
|
|
||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
| import simplerag.ragback.domain.prompt.dto.PromptCreateRequest | ||
| import simplerag.ragback.domain.prompt.dto.PromptPreviewResponse | ||
| import simplerag.ragback.domain.prompt.entity.Prompt | ||
| import simplerag.ragback.domain.prompt.repository.PromptRepository | ||
|
|
||
| @Service | ||
| @Transactional(readOnly = true) | ||
| class PromptService( | ||
| private val promptRepository: PromptRepository | ||
| ) { | ||
|
|
||
| @Transactional | ||
| fun createPrompt( | ||
| promptCreateRequest: PromptCreateRequest | ||
| ): PromptPreviewResponse { | ||
| val prompt = Prompt.from(promptCreateRequest) | ||
| val savedPrompt = promptRepository.save(prompt) | ||
| return PromptPreviewResponse.from(savedPrompt) | ||
| } | ||
|
Comment on lines
+16
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider guarding against duplicate names and clarifying default system prompt behavior
Example (outside this file): // PromptRepository.kt
interface PromptRepository : JpaRepository<Prompt, Long> {
fun existsByName(name: String): Boolean
}// PromptService.kt (inside createPrompt)
if (promptRepository.existsByName(promptCreateRequest.name)) {
// throw your domain exception, e.g., DuplicateResourceException("Prompt name already exists")
}If a DB-level guarantee is desired, also add a unique constraint on the 🤖 Prompt for AI Agents |
||
| } | ||
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.
💡 Verification agent
🧩 Analysis chain
Return HTTP 201 for creation and enable bean validation on the request
Consistent with your Index/DataFile controllers, mark the POST as 201 Created and enable validation.
@RestController @RequestMapping("/api/v1/prompts") -class PromptController( +@Validated +class PromptController( private val promptService: PromptService ) { @PostMapping + @ResponseStatus(HttpStatus.CREATED) fun createPrompt( - @RequestBody promptCreateRequest: PromptCreateRequest + @RequestBody @Valid promptCreateRequest: PromptCreateRequest ): ApiResponse<PromptPreviewResponse> { val savedPrompt = promptService.createPrompt(promptCreateRequest) return ApiResponse.ok(savedPrompt) }To confirm consistency across controllers, you can run:
Also applies to: 18-23
🏁 Script executed:
Length of output: 153
To ensure we correctly mirror the behavior of your existing controllers, let’s re-scan all controller classes for
@PostMappingand check whether they already declare@ResponseStatus(HttpStatus.CREATED)and@Valid. Please run:🏁 Script executed:
Length of output: 1791
To confirm the exact annotations on your existing POST endpoints, let’s extract the relevant snippets from both controllers:
🏁 Script executed:
Length of output: 3599
PromptController: mark POST create as 201 Created and enable bean validation
To stay consistent with your other controllers, please update
PromptControlleras follows:• File:
src/main/kotlin/simplerag/ragback/domain/prompt/controller/PromptController.kt• Add
@Validatedat the class level• Annotate the
createPromptmethod with@ResponseStatus(HttpStatus.CREATED)• Add
@Validto the@RequestBodyparameter@RestController @RequestMapping("/api/v1/prompts") -@Validated -class PromptController( +@Validated +class PromptController( private val promptService: PromptService ) { @PostMapping + @ResponseStatus(HttpStatus.CREATED) fun createPrompt( - @RequestBody promptCreateRequest: PromptCreateRequest + @RequestBody @Valid promptCreateRequest: PromptCreateRequest ): ApiResponse<PromptPreviewResponse> { val savedPrompt = promptService.createPrompt(promptCreateRequest) return ApiResponse.ok(savedPrompt) }📝 Committable suggestion
🤖 Prompt for AI Agents