first commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
"""Default L1/L2/L3 prompt templates."""
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.prompts.service import PromptService
|
||||
|
||||
DEFAULT_TEMPLATES = {
|
||||
("code_review", "L1"): {
|
||||
"body": """You are a code reviewer. Review the following code diff and identify any potential bugs or issues.
|
||||
Only list what is wrong; do not provide locations or fixes.
|
||||
|
||||
Language: {{ language }}
|
||||
Diff:
|
||||
```
|
||||
{{ diff }}
|
||||
```
|
||||
|
||||
Report issues as a plain list.""",
|
||||
"variables_schema": {
|
||||
"language": {"type": "string"},
|
||||
"diff": {"type": "string"},
|
||||
},
|
||||
},
|
||||
("code_review", "L2"): {
|
||||
"body": """You are a code reviewer. Review the following code diff and identify potential bugs or issues.
|
||||
For each issue, provide:
|
||||
1. The defect type (one line)
|
||||
2. The line number range where it occurs
|
||||
3. A brief explanation
|
||||
|
||||
Language: {{ language }}
|
||||
Diff:
|
||||
```
|
||||
{{ diff }}
|
||||
```
|
||||
|
||||
Format each issue as:
|
||||
- Type: <type>
|
||||
Lines: <start>-<end>
|
||||
Explanation: <explanation>""",
|
||||
"variables_schema": {
|
||||
"language": {"type": "string"},
|
||||
"diff": {"type": "string"},
|
||||
},
|
||||
},
|
||||
("code_review", "L3"): {
|
||||
"body": """You are a code reviewer. Review the following code diff and identify potential bugs or issues.
|
||||
For each issue, provide:
|
||||
1. The defect type (one line)
|
||||
2. The line number range where it occurs
|
||||
3. A brief explanation
|
||||
4. A concrete fix suggestion
|
||||
|
||||
Language: {{ language }}
|
||||
Diff:
|
||||
```
|
||||
{{ diff }}
|
||||
```
|
||||
|
||||
Format each issue as:
|
||||
- Type: <type>
|
||||
Lines: <start>-<end>
|
||||
Explanation: <explanation>
|
||||
Fix: <fix>""",
|
||||
"variables_schema": {
|
||||
"language": {"type": "string"},
|
||||
"diff": {"type": "string"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def seed_default_templates(db: Session) -> None:
|
||||
service = PromptService(db)
|
||||
for (strategy_id, level), data in DEFAULT_TEMPLATES.items():
|
||||
existing = service.list_versions(strategy_id, level)
|
||||
if existing:
|
||||
continue
|
||||
service.create_version(
|
||||
strategy_id=strategy_id,
|
||||
level=level,
|
||||
body=data["body"],
|
||||
variables_schema=data["variables_schema"],
|
||||
)
|
||||
Reference in New Issue
Block a user