Skip to content

fix: update chat api contract for backend integration#43

Merged
1024andrew merged 1 commit into
devfrom
fix/#37
May 7, 2026
Merged

fix: update chat api contract for backend integration#43
1024andrew merged 1 commit into
devfrom
fix/#37

Conversation

@1024andrew

@1024andrew 1024andrew commented May 7, 2026

Copy link
Copy Markdown
Contributor

유형

  • Feat
  • Fix
  • Design
  • Docs
  • Chore
  • Hotfix

변경 사항

  • 저희 노션 AI페이지->API 명세서->챗봇 백엔드 연동 api에 맞춰 챗봇 질의응답 API(/api/v1/ai/chat)의 request/response 스키마를 수정했습니다.
  • 요청 필드의 dormitorydormitory_name으로 변경했습니다.
  • 요청 필드에 user_id를 추가했습니다.
  • 응답 필드에서 source_url을 제거하고 response_time을 추가했습니다.
  • 내부 답변 생성 및 출처 처리 로직은 유지하고, API 응답 형식만 백엔드 명세에 맞게 변경했습니다.

수정 배경

백엔드와 AI 서버 간 챗봇 연동 API 명세가 변경되어, 기존 AI 서버의 챗봇 API 요청/응답 형식과 백엔드에서 호출할 형식이 달라졌습니다.

이에 따라 백엔드에서 전달하는 dormitory_name, user_id 필드를 받을 수 있도록 요청 스키마를 수정하고, 백엔드가 기대하는 response_time 필드를 응답에 포함하도록 수정했습니다.

참고

  • 채팅 세션 생성 API(/api/v1/ai/chat/sessions)는 기존 명세와 동일하게 유지했습니다.
  • source_url은 API 응답에서는 제거했지만, 답변 본문 내 출처 문구는 기존처럼 유지됩니다.

@1024andrew 1024andrew merged commit 2ce01f3 into dev May 7, 2026
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the chat schema by renaming dormitory to dormitory_name, adding an optional user_id, and replacing source_url with response_time in the response. It also introduces query expansion logic for smoking-related questions. Feedback includes a recommendation to remove the unused source_url parameter from _finalize_chat_log and a request to fix PEP 8 indentation issues for the newly added smoking_triggers list.

answer=answer,
answer_status=answer_status.value,
source_url=source_url,
response_time=response_time_ms,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

ChatResponse 스키마와 update_chat_log_result 레포지토리 메서드에서 source_url 필드가 제거됨에 따라, _finalize_chat_log 함수의 파라미터로 전달되는 source_url은 현재 내부 로직에서 전혀 사용되지 않는 상태입니다. 비록 해당 함수 시그니처와 모든 호출부들이 이번 diff에 포함되어 있지는 않지만, 향후 코드 유지보수를 위해 사용되지 않는 source_url 파라미터를 제거하는 리팩토링을 권장합니다.

Comment on lines +882 to +892


smoking_triggers = [
"담배",
"흡연",
"담배필",
"담배피",
"담배펴",
"흡연구역",
"흡연장",
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

불필요한 빈 줄을 제거하고, smoking_triggers 리스트의 요소들과 닫는 대괄호(])의 들여쓰기를 PEP 8 스타일에 맞춰 조정하는 것이 좋습니다. 현재 닫는 대괄호가 들여쓰기 없이 시작 지점에 위치하여 코드 구조상 어색해 보입니다.

    smoking_triggers = [
        "담배",
        "흡연",
        "담배필",
        "담배피",
        "담배펴",
        "흡연구역",
        "흡연장",
    ]
References
  1. PEP 8에 따르면 리스트의 요소들은 시작 부분보다 더 깊게 들여쓰기되어야 하며, 닫는 괄호는 마지막 요소의 첫 번째 문자와 수직으로 정렬하거나 시작 줄의 첫 번째 문자와 정렬해야 합니다. (link)

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