Skip to content

[ICC-53] 로깅 + 전역예외처리기 + 한 프롬프트당 생성 개수 조정#16

Merged
ChanJinYeon merged 3 commits intodevelopfrom
ICC-53-quiz-count-per-chunk
Jun 2, 2025
Merged

[ICC-53] 로깅 + 전역예외처리기 + 한 프롬프트당 생성 개수 조정#16
ChanJinYeon merged 3 commits intodevelopfrom
ICC-53-quiz-count-per-chunk

Conversation

@GulSauce
Copy link
Member

@GulSauce GulSauce commented Jun 1, 2025

📢 설명

청크 나누는 로직

코드에 코멘트 달아놓았으니 참조해주세요

타이머

await request_to_bedrock(bedrock_contents)의 수행시간을 로깅합니다
예시: 청크 당 퀴즈 카운트 5개 일 때 소요 시간: 27.2863초

추가) 로깅

심각도를 구분할 수 있습니다 INFO, WARNING, ERROR
원한다면 파일로 저장, 버퍼링을 통한 시스템콜 횟수 절감 등의 기능도 있습니다

추가) 전역 예외처리기

여러 파일에서 일어나는 raise를 한 곳에서 관리할 수 있는 장점이 있습니다

✅ 체크 리스트

  • quiz_count_per_chunk값을 다양하게 조절해보며 API 호출
  • 수행 시간 로그 확인
  • 바뀐 로깅 형식 확인
  • 코드 리뷰

@GulSauce GulSauce requested review from ChanJinYeon and Copilot and removed request for Copilot June 1, 2025 14:12
@GulSauce GulSauce self-assigned this Jun 1, 2025
try:
chunks = []
chunk_count = quiz_count // 5
chunk_count = math.ceil(quiz_count / quiz_count_per_chunk)
Copy link
Member Author

Choose a reason for hiding this comment

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

나누어 떨어지지 않을 때는 청크가 하나 덜 만들어지므로
chunk_count = math.ceil(quiz_count / quiz_count_per_chunk)로 수정합니다

Copy link

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

This PR enhances quiz chunking flexibility and adds timing logs for Bedrock requests.

  • Introduces a quiz_count_per_chunk parameter to control quizzes per chunk with math.ceil logic.
  • Updates the generate service to compute per-chunk counts dynamically and inject into the system prompt.
  • Adds timing measurement around the request_to_bedrock call.

Reviewed Changes

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

File Description
app/util/create_chunks.py Added quiz_count_per_chunk parameter and updated chunk_count logic.
app/service/generate_service.py Implemented dynamic per-chunk quiz counts, f-string prompt update, and timing log.
Comments suppressed due to low confidence (2)

app/service/generate_service.py:64

  • The content field no longer includes the {chunk} placeholder, so the lecture note chunk isn't passed into the prompt. Reintroduce the multi-line string with the {chunk} variable inside.
                                        "",",

app/util/create_chunks.py:4

  • The new quiz_count_per_chunk parameter and updated chunk logic need corresponding unit tests to verify behavior for edge cases (e.g., remainders, exact divides).
async def create_chunks(text: str, quiz_count: int, quiz_count_per_chunk: int) -> list:

chunks = await create_chunks(full_text, quiz_count)

for chunk in chunks:
quiz_count_per_chunk = 5
Copy link

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Hardcoding quiz_count_per_chunk may reduce flexibility; consider sourcing this value from configuration or function parameters.

Copilot uses AI. Check for mistakes.

for chunk in chunks:
quiz_count_per_chunk = 5
if quiz_count % quiz_count_per_chunk == 0:
Copy link
Member Author

Choose a reason for hiding this comment

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

나누어 떨어질 때는 quiz_count % quiz_count_per_chunk가 0이므로
대신 quiz_count_last_chunk = quiz_count_per_chunk로 둡니다

if len(chunks) != i:
cur_quiz_count_per_chunk = quiz_count_per_chunk
else:
cur_quiz_count_per_chunk = quiz_count_last_chunk
Copy link
Member Author

Choose a reason for hiding this comment

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

마지막 청크에 대해서만 quiz_count_last_chunk로 퀴즈 개수를 만들어달라고합니다


start = time.time()
responses = await request_to_bedrock(bedrock_contents)
end = time.time()
Copy link
Member Author

Choose a reason for hiding this comment

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

await request_to_bedrock(bedrock_contents)의 수행시간을 로깅합니다
예시: 청크 당 퀴즈 카운트 5개 일 때 소요 시간: 27.2863초

@GulSauce GulSauce changed the title [ICC-53] 구현 완료 [ICC-53] 로깅 + 전역예외처리기 + 한 프롬프트당 생성 개수 조정 Jun 1, 2025
app.include_router(generate_router)


@app.exception_handler(Exception)
Copy link
Member Author

Choose a reason for hiding this comment

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

추가) 전역 예외처리기
여러 파일에서 일어나는 raise를 한 곳에서 관리할 수 있는 장점이 있습니다

@ChanJinYeon ChanJinYeon merged commit c105ea3 into develop Jun 2, 2025
@GulSauce GulSauce deleted the ICC-53-quiz-count-per-chunk branch June 4, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants