Skip to content

#601 단계별 힌트 제공을 위한 변경#618

Merged
wlsgur11 merged 1 commit into
developfrom
stage-hint
Apr 28, 2026
Merged

#601 단계별 힌트 제공을 위한 변경#618
wlsgur11 merged 1 commit into
developfrom
stage-hint

Conversation

@wlsgur11
Copy link
Copy Markdown
Contributor

  • 이전 힌트를 llm요청 인자에 포함 하여 이전 힌트를 참고하여 힌트를 제공하도록 수정
  • 시스템 프롬프트 변경
    • 이전 힌트에 기반해서 한단계 발전한 힌트 제공하도록 수정

Changelog

  • 단계별 힌트 제공을 위해 이전 힌트를 llm 요청 시 인자로 포함시켜 단계별 힌트를 구현하였습니다.
  • 시스템 프롬프트를 이전힌트를 참고하여 제공하라고 변경하였습니다.

Testing

배포하여 테스트를 진행할 예정입니다.

Ops Impact

N/A

Version Compatibility

N/A

- 이전 힌트를 llm요청 인자에 포함 하여 이전 힌트를 참고하여 힌트를 제공하도록 수정
- 시스템 프롬프트 변경
  - 이전 힌트에 기반해서 한단계 발전한 힌트 제공하도록 수정
@wlsgur11 wlsgur11 requested review from Neibce and taekoong April 28, 2026 05:20
@Neibce Neibce requested a review from Copilot April 28, 2026 05:21
@wlsgur11 wlsgur11 merged commit 1570cf4 into develop Apr 28, 2026
@wlsgur11 wlsgur11 deleted the stage-hint branch April 28, 2026 05:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants