Skip to content

Conversation

@GulSauce
Copy link
Member

@GulSauce GulSauce commented Jan 21, 2026

📢 설명

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

✅ 체크 리스트

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

Summary by CodeRabbit

  • Documentation

    • Enhanced README with detailed explanations of endpoint behavior
  • Bug Fixes

    • Removed PPTX file support
    • Updated PDF validation to enforce minimum content length requirements
  • Improvements

    • Rate limiting is now configurable via environment variables
    • Request timeout handling is now configurable via environment variables

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

@GulSauce GulSauce merged commit 2440cbc into develop Jan 21, 2026
2 of 3 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The application's GPT request handling transitions from synchronous to asynchronous operations, replacing the blocking OpenAI client with AsyncOpenAI and removing thread-pool-based processing. Environment-based configuration is added for request timeouts and rate-limiting parameters. PDF parsing logic is refactored to remove PPTX support and enforce content length validation instead of page-count limits.

Changes

Cohort / File(s) Summary
Async Client & Batch Request Processing
app/adapter/request_batch.py, app/client/oepn_ai.py
Converts request_chat_completion_text to async and replaces synchronous to_thread pattern with coroutine-based batch processing. Switches OpenAI client from synchronous to AsyncOpenAI; updates type hints and singleton initialization. Introduces asyncio task management with timeout handling and explicit cancellation for timed-out requests.
Service Layer & Configuration
app/service/generate_service.py, app/util/rate_limiter.py
Integrates rate-limiter check before GPT batch processing and parameterizes timeout via GPT_REQUEST_TIMEOUT environment variable. Replaces hard-coded rate-limiter defaults with environment-driven configuration (RATE_LIMIT_WINDOW_SECONDS and RATE_LIMIT_MAX_REQUESTS); requires explicit environment variable reads at initialization.
File Parsing
app/util/parsing.py
Removes PPTX file handling and page-count validation; introduces content length validation for PDFs using MIN_TEXT_LENGTH environment variable. Returns HTTP 400 if text content is insufficient. Restructures page selection logic and modifies empty-page prefixing behavior.
Documentation
README.md
Adds detailed Korean explanation of FastAPI async vs. def endpoint behavior, including control flow differences, event loop usage, and implications of blocking operations on main vs. worker threads.

Sequence Diagram

sequenceDiagram
    participant Service as Generate Service
    participant RateLim as Rate Limiter
    participant Batch as Request Batch
    participant OpenAI as AsyncOpenAI Client
    
    Service->>RateLim: check_rate(quiz_count)
    alt Rate limit exceeded
        RateLim-->>Service: Raise error
    else Rate limit OK
        RateLim-->>Service: Allow
        Service->>Batch: request_text_batch(requests, timeout)
        Batch->>Batch: Create async tasks for each request
        loop Per request handler
            Batch->>OpenAI: await request_chat_completion_text(gpt_request)
            OpenAI-->>Batch: content response
        end
        Batch->>Batch: asyncio.wait(tasks, timeout=GPT_REQUEST_TIMEOUT)
        alt Timeout occurred
            Batch->>Batch: Cancel pending tasks
            Batch-->>Service: Return partial results
        else Completed within timeout
            Batch-->>Service: Return all results
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Async hops through the threadless night,
No blocking calls will slow my flight!
With AsyncOpenAI and env config,
Rate limits check before I knock.
PDFs measured by their words' delight,
The rabbit's code runs ever bright! 🚀

✨ Finishing touches
  • 📝 Generate docstrings

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.

@coderabbitai coderabbitai bot mentioned this pull request Jan 25, 2026
1 task
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