Skip to content

Commit 006a779

Browse files
author
Tian-hao Zhang
committed
formatted code to satisfy linter
1 parent dad8679 commit 006a779

4 files changed

Lines changed: 38 additions & 12 deletions

File tree

client/src/components/Chatbot.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ function Chatbot({ onClose }) {
8080
// server may not be ready yet
8181
}
8282
})();
83-
return () => { cancelled = true; };
83+
return () => {
84+
cancelled = true;
85+
};
8486
}, []);
8587

8688
/* ── switch conversation ───────────────────────────────────────────────── */
@@ -355,9 +357,7 @@ function Chatbot({ onClose }) {
355357
opacity: 0.4,
356358
transition: "opacity 0.15s",
357359
}}
358-
onMouseEnter={(e) =>
359-
(e.currentTarget.style.opacity = "1")
360-
}
360+
onMouseEnter={(e) => (e.currentTarget.style.opacity = "1")}
361361
onMouseLeave={(e) =>
362362
(e.currentTarget.style.opacity = "0.4")
363363
}

server_api/auth/models.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean, Float, Text
1+
from sqlalchemy import (
2+
Column,
3+
Integer,
4+
String,
5+
DateTime,
6+
ForeignKey,
7+
Boolean,
8+
Float,
9+
Text,
10+
)
211
from sqlalchemy.orm import relationship
312
from sqlalchemy.sql import func
413
from .database import Base
@@ -72,17 +81,26 @@ class Conversation(Base):
7281
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
7382
title = Column(String, default="New Chat")
7483
created_at = Column(DateTime(timezone=True), server_default=func.now())
75-
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
76-
77-
messages = relationship("ChatMessage", back_populates="conversation", cascade="all, delete-orphan", order_by="ChatMessage.created_at")
84+
updated_at = Column(
85+
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
86+
)
87+
88+
messages = relationship(
89+
"ChatMessage",
90+
back_populates="conversation",
91+
cascade="all, delete-orphan",
92+
order_by="ChatMessage.created_at",
93+
)
7894
owner = relationship("User")
7995

8096

8197
class ChatMessage(Base):
8298
__tablename__ = "chat_messages"
8399

84100
id = Column(Integer, primary_key=True, index=True)
85-
conversation_id = Column(Integer, ForeignKey("conversations.id", ondelete="CASCADE"), nullable=False)
101+
conversation_id = Column(
102+
Integer, ForeignKey("conversations.id", ondelete="CASCADE"), nullable=False
103+
)
86104
role = Column(String, nullable=False) # "user" or "assistant"
87105
content = Column(Text, nullable=False)
88106
created_at = Column(DateTime(timezone=True), server_default=func.now())

server_api/chatbot/chatbot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ def search_documentation(query: str) -> str:
330330
"""
331331
_search_call_count[0] += 1
332332
if _search_call_count[0] > 2:
333-
return "Search limit reached. Answer with the documentation already retrieved."
333+
return (
334+
"Search limit reached. Answer with the documentation already retrieved."
335+
)
334336

335337
docs = retriever.invoke(query)
336338
if docs:

server_api/main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ async def check_files(req: Request):
522522

523523
# ── Chat history persistence endpoints ─────────────────────────────────────────
524524

525+
525526
@app.get("/chat/conversations", response_model=List[models.ConversationResponse])
526527
def list_conversations(
527528
user: models.User = Depends(get_current_user),
@@ -691,7 +692,9 @@ async def chat_query(
691692

692693
# Persist to DB
693694
db.add(models.ChatMessage(conversation_id=convo_id, role="user", content=query))
694-
db.add(models.ChatMessage(conversation_id=convo_id, role="assistant", content=response))
695+
db.add(
696+
models.ChatMessage(conversation_id=convo_id, role="assistant", content=response)
697+
)
695698

696699
# Auto-title: first user message becomes the title (truncated)
697700
if convo.title == "New Chat":
@@ -737,6 +740,7 @@ async def chat_status():
737740
# Helper chat endpoints (inline "?" popovers — RAG only, no training/inference)
738741
# ---------------------------------------------------------------------------
739742

743+
740744
def _ensure_helper_chat(task_key: str):
741745
"""Lazily build a helper agent for *task_key*, reusing it on subsequent calls."""
742746
global _chatbot_error
@@ -777,7 +781,9 @@ async def chat_helper_query(req: Request):
777781

778782
# Prepend field context to the first message so the LLM knows what field
779783
# the user is looking at.
780-
user_content = f"[Field context: {field_context}]\n\n{query}" if field_context else query
784+
user_content = (
785+
f"[Field context: {field_context}]\n\n{query}" if field_context else query
786+
)
781787

782788
reset_fn()
783789
all_messages = history + [{"role": "user", "content": user_content}]

0 commit comments

Comments
 (0)