Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5a5407a
feat: integrate korean book metadata and UI citations
SanghunYun95 Mar 2, 2026
8a01e1d
fix: apply coderabbit review suggestions
SanghunYun95 Mar 2, 2026
133442a
fix(backend): apply coderabbit review feedback for db and mapping scr…
SanghunYun95 Mar 2, 2026
43d1722
fix(backend): address additional coderabbit PR inline comments
SanghunYun95 Mar 2, 2026
0dd84a4
refactor(backend): use shared env parser and HTTPS for API
SanghunYun95 Mar 3, 2026
3057ad7
fix(backend): allow key rotation for all errors in book mapping
SanghunYun95 Mar 3, 2026
fc24774
feat: implement dynamic chat title and dynamic philosopher highlighting
SanghunYun95 Mar 3, 2026
cdbc817
fix: apply CodeRabbit PR review feedback
SanghunYun95 Mar 3, 2026
6c7566d
fix(pr): address CodeRabbit review feedback on backend tools and DB s…
SanghunYun95 Mar 3, 2026
78fc51a
chore: resolve merge conflicts
SanghunYun95 Mar 3, 2026
9de894d
fix(pr): address additional CodeRabbit comments
SanghunYun95 Mar 3, 2026
3d773d7
style: update welcome messages and input placeholder to be more gener…
SanghunYun95 Mar 3, 2026
4335bee
fix(pr): address additional CodeRabbit feedback for title truncation …
SanghunYun95 Mar 3, 2026
7298aac
UI: Remove redundant buttons (useful, copy, regenerate) from MessageList
SanghunYun95 Mar 3, 2026
30dd215
Merge branch 'main' into feat/book-metadata
SanghunYun95 Mar 3, 2026
ce91d6a
Refactor: apply CodeRabbit review suggestions
SanghunYun95 Mar 3, 2026
0bd1fcd
docs: rewrite README for interviewers
SanghunYun95 Mar 3, 2026
1196e30
docs, refactor: refine README and MessageList observer logic per PR c…
SanghunYun95 Mar 3, 2026
1b31b83
refactor: resolve observer unmount leak, Biome formatting, exhaustive…
SanghunYun95 Mar 3, 2026
e1ec3fc
fix: clear visibleMessages on unmount & use targeted eslint disable
SanghunYun95 Mar 3, 2026
36bd572
docs, refactor: disable philosopher filtering & update README examples
SanghunYun95 Mar 3, 2026
f13f327
refactor: apply PR refinements for mapping script and observers
SanghunYun95 Mar 3, 2026
1a9358b
Merge origin/main into feat/book-metadata (Resolve conflicts)
SanghunYun95 Mar 3, 2026
5d2841d
Fix: apply CodeRabbit feedback for React hooks and Tailwind
SanghunYun95 Mar 3, 2026
2584e3b
Feat: support multiple GEMINI_API_KEYS via comma-separated env var fo…
SanghunYun95 Mar 4, 2026
2395400
Fix: apply PR CodeRabbit round 8 feedback and add favicon
SanghunYun95 Mar 4, 2026
a0f719c
Fix: resolve conflicts and apply PR CodeRabbit round 9 feedback
SanghunYun95 Mar 4, 2026
789bdf4
Fix: apply PR CodeRabbit round 10 feedback
SanghunYun95 Mar 4, 2026
4c33094
Fix: apply PR CodeRabbit round 11 feedback
SanghunYun95 Mar 4, 2026
c9b0b91
Fix: apply PR CodeRabbit round 12 feedback
SanghunYun95 Mar 4, 2026
f24b224
fix(backend): preload models on startup and use async invokes to prev…
SanghunYun95 Mar 4, 2026
622a663
test: update mocks for refactored async llm/embedding functions
SanghunYun95 Mar 4, 2026
9eedd78
fix(pr): address lint, magic numbers, and use favicon for logo
SanghunYun95 Mar 4, 2026
4d878c2
fix(pr): resolve conflicts and add sizes prop to next/image
SanghunYun95 Mar 4, 2026
8495460
fix(backend): load models in background to prevent startup timeout on…
SanghunYun95 Mar 5, 2026
110049b
fix(backend): resolve conflict and apply PR feedback (timeouts, track…
SanghunYun95 Mar 5, 2026
105a59c
fix(backend): add graceful teardown for preload task on shutdown
SanghunYun95 Mar 5, 2026
7d918eb
feat(backend): add /ready endpoint and handle CancelledError in preload
SanghunYun95 Mar 5, 2026
382f90e
fix(backend): handle CancelledError properly in /ready readiness probe
SanghunYun95 Mar 5, 2026
1987897
fix(backend): lazy load ML models in chat routes to avoid Uvicorn sta…
SanghunYun95 Mar 5, 2026
f11491c
fix(backend): add error logging to /ready endpoint for better observa…
SanghunYun95 Mar 5, 2026
cad791b
refactor(backend): use else block for successful return in readiness …
SanghunYun95 Mar 5, 2026
e94fbe2
refactor(backend): use logger.warning in /ready, catch Exception in l…
SanghunYun95 Mar 5, 2026
359511c
Merge branch 'main' into feat/book-metadata and apply lifespan except…
SanghunYun95 Mar 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions backend/app/api/routes/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from pydantic import BaseModel, Field
from sse_starlette.sse import EventSourceResponse

from app.services.llm import get_english_translation, get_response_stream_async, generate_chat_title_async
from app.services.embedding import embedding_service
from app.services.database import get_client
from app.core.rate_limit import limiter

Expand Down Expand Up @@ -38,6 +36,9 @@ async def generate_chat_events(request: Request, query: str, history: List[Histo
Generator function that streams SSE events.
It yields 'metadata' first, then chunks of 'content'.
"""
from app.services.llm import get_english_translation, get_response_stream_async
from app.services.embedding import embedding_service

# 1. Translate Korean query to English // Note: We don't translate history here to save costs and reduce latency
try:
english_query = await asyncio.wait_for(
Expand Down Expand Up @@ -153,6 +154,8 @@ async def chat_title_endpoint(request: Request, title_request: TitleRequest):
"""
Endpoint for generating a short chat room title based on the first user query.
"""
from app.services.llm import generate_chat_title_async

query = title_request.query.strip()
if not query:
return {"title": DEFAULT_CHAT_TITLE}
Expand Down
10 changes: 8 additions & 2 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from app.api.routes import chat
from app.core.rate_limit import limiter
import asyncio
from contextlib import asynccontextmanager
import logging

Expand Down Expand Up @@ -48,6 +49,8 @@ def _on_preload_done(task: asyncio.Task):
await asyncio.wait_for(asyncio.shield(preload_task), timeout=3.0)
except asyncio.TimeoutError:
logger.warning("Preload task did not finish before shutdown.")
except Exception as e:
logger.exception("Exception occurred while waiting for preload task during shutdown.")
Comment on lines +52 to +53
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

사용하지 않는 예외 변수 e를 제거해주세요.

Line 52에서 e를 바인딩하지만 사용하지 않아 불필요한 lint 경고(F841)가 발생합니다.

🔧 제안 수정
-            except Exception as e:
+            except Exception:
                 logger.exception("Exception occurred while waiting for preload task during shutdown.")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
except Exception as e:
logger.exception("Exception occurred while waiting for preload task during shutdown.")
except Exception:
logger.exception("Exception occurred while waiting for preload task during shutdown.")
🧰 Tools
🪛 Ruff (0.15.2)

[error] 52-52: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/app/main.py` around lines 52 - 53, Remove the unused exception
variable by changing the except clause that currently reads "except Exception as
e:" to "except Exception:" in the shutdown/preload-wait block (the block that
calls logger.exception("Exception occurred while waiting for preload task during
shutdown.")). This keeps the existing logger.exception call (which logs the
traceback) while eliminating the unused variable and the lint F841 warning.


app = FastAPI(
title="PhiloRAG API",
Expand Down Expand Up @@ -83,10 +86,13 @@ async def readiness_check():
return JSONResponse({"status": "not_ready"}, status_code=503)

if preload_task.cancelled():
logger.warning("Preload task was cancelled during readiness check")
return JSONResponse({"status": "failed"}, status_code=503)

try:
preload_task.result() # re-raises if failed
return {"status": "ready"}
except Exception:
except Exception as e:
logger.warning("Preload task failed during readiness check: %s", e)
return JSONResponse({"status": "failed"}, status_code=503)
else:
return {"status": "ready"}
6 changes: 3 additions & 3 deletions backend/tests/e2e/test_chat_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def test_health_check():
assert response.status_code == 200
assert response.json() == {"status": "healthy"}

@patch("app.api.routes.chat.embedding_service.agenerate_embedding")
@patch("app.services.embedding.EmbeddingService.agenerate_embedding")
@patch("app.api.routes.chat._search_documents")
@patch("app.api.routes.chat.get_english_translation")
@patch("app.api.routes.chat.get_response_stream_async")
@patch("app.services.llm.get_english_translation")
@patch("app.services.llm.get_response_stream_async")
def test_chat_endpoint_success(mock_stream, mock_translate, mock_search, mock_embed):
# Setup mocks
mock_translate.return_value = "What is life?"
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/integration/test_supabase_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
@pytest.mark.asyncio
async def test_supabase_match_integration():
# 1. We mock the embedding service to return a dummy vector
with patch("app.api.routes.chat.embedding_service.agenerate_embedding") as mock_embed, \
with patch("app.services.embedding.EmbeddingService.agenerate_embedding") as mock_embed, \
patch("app.api.routes.chat._search_documents") as mock_search, \
patch("app.api.routes.chat.get_english_translation") as mock_translate, \
patch("app.api.routes.chat.get_response_stream_async") as mock_stream:
patch("app.services.llm.get_english_translation") as mock_translate, \
patch("app.services.llm.get_response_stream_async") as mock_stream:

mock_translate.return_value = "English Question"
mock_embed.return_value = [0.1, 0.2, 0.3]
Expand Down