Skip to content

계승 v 2.1.1#116

Merged
GulSauce merged 2 commits intodevelopfrom
main
Feb 1, 2026
Merged

계승 v 2.1.1#116
GulSauce merged 2 commits intodevelopfrom
main

Conversation

@GulSauce
Copy link
Member

@GulSauce GulSauce commented Feb 1, 2026

📢 설명

해당 Pull Request에 대해 간략하게 설명해주세요!

✅ 체크 리스트

  • 리뷰어가 체크할 내용을 작성해주세요!

Summary by CodeRabbit

  • New Features

    • Quiz generation endpoint now streams results incrementally, improving responsiveness for large documents.
    • Standardized error response format with detailed status codes and messages.
  • Improvements

    • Concurrent chunk processing accelerates quiz generation performance.
    • Optimized API request timeout handling with reduced latency.
    • Enhanced PDF chunking strategy with improved page allocation and lookahead optimization.

✏️ Tip: You can customize this high-level summary in your review settings.

GulSauce and others added 2 commits February 1, 2026 21:02
* [ICC-25] 구성 완료

* [ICC-29] 구현 완료

* [ICC-29] 응답 구조 수정

* [ICC-30] 작성 완료

* [ICC-31] 레디스 구독 패턴 구현 완료

* [ICC-31] 레디스 클라이언트를 각 생성마다 생성되게함

* [ICC-31] 필요 없는 의존성 제거

* [ICC-31] requirements.txt 등록

* [ICC-31] 베드락에 요청하는 코드 분리

* [ICC-31] 타입아웃 설정

* [ICC-32] 첫번째 시도

* [ICC-32] 두번째 시도

* [ICC-32] 세번째 시도

* [ICC-32] 네번째 시도

* [ICC-32] 다섯번째 시도

* [ICC-32] 성공

* [ICC-32] 리모트환경에서는 바로 SQS를 보게함

* [ICC-32] 임시 수정

* [ICC-32] boto3 의존성 추가

* [ICC-32] 리전 추가

* [ICC-32] 반응 브랜치 변경

* [ICC-39] 구현 완료

* [ICC-47] quiz parsing (#13)

* [ICC-35] Create 5 Quiz

* ICC-38 json 객체 테스트

* [ICC-47] Redis 주석 처리 해제

---------

Co-authored-by: Oh YoungJe <pine7420@naver.com>

* [ICC-49] Dependency 해결

* [ICC-50] API서버 연결 간 문제 해결 (#15)

* [ICC-50] generation으로 엔드포인트 변경

* [ICC-50] api와 연결간 오류 해결

* [ICC-53] 구현 완료

* [ICC-53] 로거, 전역 예외처리기 추가

* [ICC-53] 일부 수정

* [ICC-57] 구현 완료

* [ICC-67] 응답 구조 수정 완료

* [ICC-63] Webb's DOK

# Conflicts:
#	app/service/generate_service.py

* [ICC-63] 추가 코드 작성

* [ICC-70] api 수정

* [ICC-48] MCP 기능 구현  완료

* [ICC-48] MCP 리서치

* [ICC-48] 엔드포인트 분리

* [ICC-74] 요청 dto 변경

* [ICC-74] 페이지 일부만 가져오기 구현 완료

* [ICC-74] 파워포인트도 적용 완료

* [ICC-74] 불필요한 로그출력 제거

* [ICC-74] 페이지 선택 방식 변경

* [ICC-76] 발생한 문제 해결

* [ICC-76] 코드 수정

* [ICC-80] 프롬프트 추가

* [ICC-80] 프롬프트 추가

* [ICC-80] 롤백

* [ICC-80] 롤백

* [ICC-87] 최대 청크 개수 증가

* [ICC-87] 기본 구조 작성

* [ICC-87] 레디스 분산락 구현

* [ICC-87] 필요 없는  레디스 함수 제거:

* [ICC-87] 한번에 데이터를 넣게 함

* [ICC-99] generate dto 변경

* [ICC-99] 구현 완료

* [ICC-99] generate dto 변경

* [ICC-99] 구현 완료

* [ICC-94] specific explanation 서비스 추가

* [ICC-94] 구현완료

* ICC-112 OX 프롬프트 수정

* [ICC-112] 리팩터링 + BLANK 타입 추가

* [ICC-134] 필요한 프롬프트 추가

* [ICC-164] 작성 완료

* [ICC-167] 프롬프트 수정

* [ICC-167] 프롬프트 변경

* [ICC-167] 프롬프트 변경

* [ICC-167] 프롬프트 변경

* [ICC-167] 프롬프트 변경

* [ICC-167] 프롬프트 변경

* [ICC-167] 프롬프트 수정

* [ICC-167] 프롬프트 수정

* [ICC-167] 프롬프트 수정

* [ICC-167] 잘못된 프롬프트 반환 수정

* [ICC-167] 잘못된 프롬프트 반환 수정

* [ICC-167] 모델 변경

* [ICC-167] 리팩터링 완료

* [ICC-167] 코드 포맷팅

* [ICC-167] 제약사항 반영

* [ICC-167] 프롬프트 수정

* [ICC-167] 리팩터링

* [ICC-175] 도커 컴포즈 제거

* [ICC-175] 개발 깃허브 액션 스크립터 제거

* [ICC-180] 셔플 로직 추가

* [ICC-180] CD 브랜치명 올바르게 변경

* [ICC-189] 타임아웃시 전체 실패가 아닌 일부라도 반환하게함

* [ICC-192] 로직변경완료

* [ICC-194] 선지를 밝히지 말라는 문구 추가

* [ICC-196] 마이그레이션 완료

* [ICC-196] 프롬프트 롤백

* [ICC-196] min quiz size todo에 추가

* [ICC-196] 개행 문구 추가

* [ICC-200] 타입에 따라 셔플하도록 함

* Refactor quiz generation and explanation services; remove unused Bedrock adapter and integrate GPT for specific explanations. Update router to utilize new explanation service.

* [ICC-212] 커서를 통한 1차 리팩터링 완료

* [ICC-212] 어댑터 단순화

* [ICC-212] 블랙 포맷팅 적용

* [ICC-212] 기능 동작하게 수정 완료

* [ICC-212] 개행 프롬프트 추가

* [ICC-212] 구성 완료

* [ICC-215] 수정 완료

* [ICC-216] 구현 코드 작성 완료

* [ICC-216] 객관식 프롬프트 개선

* [ICC-220] 타임아웃 시 해당 문제만 실패하게 조정

* [ICC-221] env 중복참조 수정

* [ICC-220] 환경변수를 없애고 스레드 관점에서 타임아웃으로 조정

* [ICC-220] 불필요한 참조 제거

* [ICC-220] 불필요한 참조 제거

* v 1.5.5 (#97) (#98)

* [ICC-235] 비동기 클라이언트로 변경 완료 (#99)

* v 1.6.0 (#100) (#101)

* [ICC-229] 분리 완료 (#102)

* [ICC-233] 파일 텍스트 부족시 반환 (#103)

* [ICC-233] 구현 완료

* [ICC-230] 페이지 제한 환경변수화

* 계승: v1.6.1 (#105)

* v 1.6.0 (#100)

* v 1.6.1 (#104)

* [ICC-237] OCR로 변경 완료 (#106)

* [ICC-238]  수정 완료 (#108)

* [ICC-238] 수정 완료

* [ICC-241] 구현 완료

* [ICC-241] 최소 3개의 청크는 빨리 응답하도록 함

* [ICC-245] 응답구조 수정

* Hotfixgit add . import 누락 추가

---------

Co-authored-by: 이찬우 <105221020+ChanJinYeon@users.noreply.github.com>
Co-authored-by: Adansonia <lcw061145@gmail.com>
Co-authored-by: lhoju0158 <lhoju0158@gmail.com>
@GulSauce GulSauce merged commit f6b4308 into develop Feb 1, 2026
1 of 2 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Consolidates OpenAI client management by removing duplicate singleton implementations, eliminates batch processing wrapper, refactors quiz generation to support streaming responses with concurrent chunk processing, and introduces standardized error response models.

Changes

Cohort / File(s) Summary
GPT Client & Adapter Consolidation
app/adapter/request_batch.py, app/client/oepn_ai.py, app/adapter/request_to_gpt.py
Removed batch processing module and duplicate singleton client. Replaced with cached get_gpt_client() returning AsyncOpenAI and new request_to_gpt_returning_text() function that applies per-call timeout via OpenAI's with_options method instead of external timeout handling.
Response Data Models
app/dto/response/error_response.py, app/dto/response/generate_response.py, app/dto/model/problem_set.py
Added new ErrorResponse DTO for standardized error payloads. Refactored GenerateResponse to inherit from new ProblemSetDTO base, renamed ProblemResponse to ProblemDTO, added type: Literal["quiz"] field. Minor formatting adjustment to Selection.correct description.
Service Layer Refactor
app/service/generate_service.py, app/service/explanation_service.py
Major streaming refactor in GenerateService.generate: introduced async chunk processing, concurrent task creation, per-chunk streaming results as JSONL, and error response streaming. Added process_single_chunk() helper. Migrated to new GPT function, reduced explanation timeout from 60 to 30 seconds.
Chunking & Utility Updates
app/util/create_chunks.py, app/util/gpt_utils.py
Simplified chunk distribution logic in create_chunks.py: replaced specialized handlers with unified approach accepting page_numbers list, added gpt_content field to ChunkInfo. Added new enforce_additional_properties_false() utility to recursively enforce schema constraints for GPT responses.
Router & Endpoint Changes
app/router/generate_router.py
Removed FastAPI dependency injection; endpoints now call service methods directly as static/class methods. generate endpoint now returns StreamingResponse wrapping JSONL output instead of single GenerateResponse object.

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Router as Router Handler
    participant Service as GenerateService
    participant Chunk as process_single_chunk
    participant GPT as GPT Client
    participant Stream as StreamingResponse

    Client->>Router: POST /generate (GenerateRequest)
    Router->>Service: GenerateService.generate(request)
    
    Service->>Service: Create page chunks<br/>with gpt_content

    par Concurrent Chunk Processing
        Service->>Chunk: Task 1: process_single_chunk()
        Chunk->>GPT: request_to_gpt_returning_text()
        GPT-->>Chunk: Response (text)
        Chunk->>Chunk: Parse & validate response
        Chunk-->>Service: ProblemSetDTO
        
        Service->>Chunk: Task N: process_single_chunk()
        Chunk->>GPT: request_to_gpt_returning_text()
        GPT-->>Chunk: Response (text)
        Chunk-->>Service: ProblemSetDTO
    end

    Service->>Service: Stream results as JSONL<br/>on task completion
    Service-->>Stream: Emit ProblemSetDTO lines
    alt Task Failure
        Service->>Stream: Emit ErrorResponse line
    end
    Stream-->>Router: JSONL Stream
    Router-->>Client: StreamingResponse
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • [ICC-237] OCR로 변경 완료 #106: Adds request_responses_output_text and request_responses_batch functions to app/adapter/request_batch.py — directly inverse to this PR's removal of the same module and functions.
  • [ICC-241] 비동기 퀴즈 응답 #112: Modifies the same adapter and client code paths, removing app/client/oepn_ai.py and refactoring app/adapter/request_to_gpt.py with cached get_gpt_client and new request function.
  • 계승: v 1.5.3 (#87) #88: Updates batch request timeout handling and singleton OpenAI client implementation in the same adapter/client layers affected by this PR.

Poem

🐰 Hop-hop, streaming quiz chunks through the air!
Concurrent tasks dance without a care,
No more batches—just nimble flows,
Error schemas locked down in a row,
The client's cached, the chunks are neat,
Generation's refactor—a hoppy treat!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch main

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant