Skip to content

#601 vLLM 기반 문제 힌트 스트리밍 API 초안 구현#608

Merged
Neibce merged 2 commits into
developfrom
601/llm-hint-backend-init
Apr 7, 2026
Merged

#601 vLLM 기반 문제 힌트 스트리밍 API 초안 구현#608
Neibce merged 2 commits into
developfrom
601/llm-hint-backend-init

Conversation

@Neibce
Copy link
Copy Markdown
Member

@Neibce Neibce commented Apr 7, 2026

Changelog

  • 공개 문제 상세 페이지에서 AI 힌트를 스트리밍으로 받아볼 수 있도록 vLLM 연동 API를 추가했습니다.
  • 로그인한 사용자만 공개 문제에 대해 AI 힌트를 요청할 수 있도록 제한했습니다.
  • 문제 본문을 그대로 신뢰하지 않도록 system/user prompt를 보강해 프롬프트 인젝션 방어 문구를 추가했습니다.
  • SSE 응답이 프록시에서 버퍼링되지 않도록 nginx 라우팅에 전용 location을 추가하고 timeout을 조정했습니다.

Testing

  • 백엔드 테스트코드 작성, 실행 완료

Ops Impact

  • 프록시에서 SSE buffering 방지를 위한 nginx location 설정이 포함됩니다.

Version Compatibility

N/A

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

공개 문제 상세 페이지에서 vLLM 기반 AI 힌트를 SSE(Streaming) 로 제공하기 위한 백엔드 API/프롬프트 구성/프록시 설정과 테스트를 추가한 PR입니다.

Changes:

  • 공개 문제에 대해 로그인 사용자만 접근 가능한 GET /api/problem/llm_hint SSE API 추가
  • vLLM 스트리밍 응답을 파싱해 chunk 단위로 SSE 이벤트로 전달하는 모듈(llm_hint.py) 구현
  • SSE 버퍼링 방지/타임아웃 조정을 위한 nginx location 추가 및 관련 백엔드 테스트 추가

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/deploy/kube_nginx/locations.conf SSE 스트림이 프록시에서 버퍼링되지 않도록 전용 location 및 timeout/gzip 설정 추가
backend/problem/views/oj.py 로그인/공개 문제 제한이 있는 SSE 힌트 스트리밍 API 엔드포인트 추가
backend/problem/urls/oj.py LLM 힌트 API 라우팅 추가
backend/problem/tests.py LLM 힌트 SSE 응답/권한/에러 케이스 및 URL 선택 로직 테스트 추가
backend/problem/llm_hint.py vLLM 호출 payload 구성, 문제 본문 정규화, vLLM SSE 스트림 파싱 및 텍스트 청크 yield 구현

Comment thread backend/problem/views/oj.py Outdated
Comment thread backend/problem/llm_hint.py
Comment thread backend/problem/tests.py Outdated
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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread backend/problem/tests.py
resp = self.client.get(f"{self.url}?problem_id={self.problem._id}")
body = self._streaming_body(resp)

self.assertEqual(resp["Content-Type"], "text/event-stream")
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

StreamingHttpResponse(content_type="text/event-stream")는 Django 3.2에서 기본 charset이 자동으로 붙어 text/event-stream; charset=utf-8 형태가 될 수 있습니다. 현재 테스트는 Content-Type를 정확히 text/event-stream로 단정하고 있어 환경에 따라 실패할 수 있으니, startswith("text/event-stream") 또는 assertIn("text/event-stream", ...) 형태로 완화하거나 뷰에서 charset까지 명시적으로 맞춰주세요.

Suggested change
self.assertEqual(resp["Content-Type"], "text/event-stream")
self.assertTrue(resp["Content-Type"].startswith("text/event-stream"))

Copilot uses AI. Check for mistakes.
@Neibce Neibce merged commit 6c67ac3 into develop Apr 7, 2026
4 checks passed
@Neibce Neibce deleted the 601/llm-hint-backend-init branch April 7, 2026 01:35
@Neibce Neibce restored the 601/llm-hint-backend-init branch April 7, 2026 01:48
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.

2 participants