#601 단계별 힌트 제공을 위한 변경#618
Merged
Merged
Conversation
- 이전 힌트를 llm요청 인자에 포함 하여 이전 힌트를 참고하여 힌트를 제공하도록 수정 - 시스템 프롬프트 변경 - 이전 힌트에 기반해서 한단계 발전한 힌트 제공하도록 수정
Neibce
approved these changes
Apr 28, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
이 PR은 문제 AI 힌트 생성 시 이전 힌트 로그를 LLM 요청 컨텍스트에 포함하여, 같은 내용 반복 없이 “단계적으로 발전하는 힌트”를 제공하도록 백엔드 로직과 시스템 프롬프트를 조정합니다.
Changes:
- 문제별 이전 힌트 로그를 조회해
stream_problem_hint호출 시previous_hints로 전달 - LLM payload 메시지 구성을 이전 힌트(assistant role) + 추가 user 트리거 메시지 형태로 변경
- 시스템 프롬프트를 “이전 힌트를 확인하고 한 단계 더 나아간 단 하나의 실마리 제공” 방향으로 수정
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| backend/problem/views/oj.py | 힌트 생성 API에서 이전 힌트를 조회해 LLM 스트리밍 호출에 컨텍스트로 전달 |
| backend/problem/llm_hint.py | 시스템 프롬프트/요청 payload 구조 변경 및 previous_hints 지원 추가 |
Comment on lines
+97
to
+116
| messages = [ | ||
| {"role": "system", "content": SYSTEM_PROMPT}, | ||
| {"role": "user", "content": build_problem_prompt(problem)} | ||
| ] | ||
|
|
||
| # 이전 힌트들을 assistant 롤로 추가하여 대화 맥락(Context) 유지 | ||
| for hint in previous_hints: | ||
| messages.append({"role": "assistant", "content": hint}) | ||
|
|
||
| # 이전 힌트가 있다면, 점진적 힌트를 유도하는 사용자 메시지 트리거 추가 | ||
| if previous_hints: | ||
| messages.append({ | ||
| "role": "user", | ||
| "content": f"이전에 {len(previous_hints)}번의 힌트를 받았습니다. 이전 힌트들을 참고하여 내용이 겹치지 않게, 그 다음 단계로 나아갈 수 있는 구체적인 힌트를 한두 문장으로만 제시해 주세요. 정답이나 전체 로직은 절대 노출하지 마세요." | ||
| }) | ||
| else: | ||
| messages.append({ | ||
| "role": "user", | ||
| "content": "위 정보를 바탕으로 문제 접근을 시작할 수 있는 가장 첫 번째 힌트 하나만 한두 문장으로 작성해 주세요. 마크다운과 정답 코드는 제외하세요." | ||
| }) |
Comment on lines
+25
to
+29
| - 사용자가 정답에 도달하는 모든 과정을 한 번에 설명하지 마세요. | ||
| - 대화 내역에 있는 당신의 '이전 힌트'들을 반드시 확인하세요. | ||
| - 이전 힌트와 똑같은 내용을 반복하지 마세요. | ||
| - 이전 힌트에서 한 단계 더 나아간, 다음 추론을 유도하는 '단 하나의 실마리'만 제공하세요. | ||
| - 너무 추상적인 조언은 피하고 문제의 특정 조건이나 구조에서 출발하세요. |
Comment on lines
+102
to
+111
| # 이전 힌트들을 assistant 롤로 추가하여 대화 맥락(Context) 유지 | ||
| for hint in previous_hints: | ||
| messages.append({"role": "assistant", "content": hint}) | ||
|
|
||
| # 이전 힌트가 있다면, 점진적 힌트를 유도하는 사용자 메시지 트리거 추가 | ||
| if previous_hints: | ||
| messages.append({ | ||
| "role": "user", | ||
| "content": f"이전에 {len(previous_hints)}번의 힌트를 받았습니다. 이전 힌트들을 참고하여 내용이 겹치지 않게, 그 다음 단계로 나아갈 수 있는 구체적인 힌트를 한두 문장으로만 제시해 주세요. 정답이나 전체 로직은 절대 노출하지 마세요." | ||
| }) |
Comment on lines
+177
to
180
| # 어드민인 경우에도 이전 힌트 컨텍스트는 유지하도록 조회 | ||
| previous_logs = ProblemAIHintLog.objects.filter(user=request.user, problem=problem).order_by("created_at") | ||
| previous_hints = [log.hint_content for log in previous_logs if log.hint_content.strip()] | ||
| hint_log = ProblemAIHintLog.objects.create(user=request.user, problem=problem, hint_content="") |
Comment on lines
182
to
186
| def generator(): | ||
| full_text_chunks = [] | ||
| try: | ||
| for chunk in stream_problem_hint(problem): | ||
| for chunk in stream_problem_hint(problem, previous_hints=previous_hints): | ||
| full_text_chunks.append(chunk) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Testing
배포하여 테스트를 진행할 예정입니다.
Ops Impact
N/A
Version Compatibility
N/A