#601 vLLM 기반 문제 힌트 스트리밍 API 초안 구현#608
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
공개 문제 상세 페이지에서 vLLM 기반 AI 힌트를 SSE(Streaming) 로 제공하기 위한 백엔드 API/프롬프트 구성/프록시 설정과 테스트를 추가한 PR입니다.
Changes:
- 공개 문제에 대해 로그인 사용자만 접근 가능한
GET /api/problem/llm_hintSSE 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 구현 |
| 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") |
There was a problem hiding this comment.
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")) |
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
Version Compatibility
N/A