Commit Graph

19 Commits

Author SHA1 Message Date
pengxiao 37c0364e7e refactor: replace print() with structured logging across backend
Replace all print()/stderr logging with Python logging module using
logger = logging.getLogger(__name__) pattern for consistent log levels
and formatting. Extract score conversion to shared score_utils module.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 15:52:44 +08:00
pengxiao 4bb50ae9c1 feat: multimodal RAG with PDF image extraction and display
Extract images from PDFs using pymupdf, generate descriptions via
Qwen3-VL-8B, store in ChromaDB alongside text chunks, and render
images in chat answers. Includes image proxy rewrite, force re-process
endpoint, and VLM API timeout.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 12:14:40 +08:00
pengxiao 3f12e96ea0 fix: use hostname:8000 as API fallback for remote deployments
Replace hardcoded localhost:8000 with window.location.hostname:8000 so the
frontend auto-detects the correct backend address when deployed on a remote
server instead of always pointing to localhost.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:22:46 +08:00
pengxiao b8561e04c6 fix: source list scroll, citation targeting, and page UI polish
- Replace ScrollArea with native overflow-y-auto for reliable mouse wheel scrolling
- Scope source DOM IDs by message ID to fix cross-round citation jumps
- Improve profile, settings, forum, knowledge page layouts
- Update mobile navigation and chat interface

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:05:08 +08:00
pengxiao abcced35b8 feat: RAG inline citations, source highlighting, and admin panel
- Increase RAG retrieval from 5 to 50 docs with relevance threshold (0.15)
- LLM inline citations with [来源N] format and reference list
- Clickable citation links scroll to source cards with highlight animation
- Source previews with full chunk text and answer-matched highlighting
- Message-scoped source IDs to fix cross-round citation targeting
- Admin panel pages (knowledge, users, forum, course, settings)
- Add rehype-raw dependency for HTML-in-markdown rendering

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 20:51:28 +08:00
pengxiao 5d42a0573a refactor: improve forum, profile and settings page UI
Streamline profile and settings pages, refine forum listing and post pages.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 16:45:40 +08:00
pengxiao 38865b0f7d feat: system knowledge base management with admin/user role separation
- Auto-create system KBs from data/knowledge_base/ subdirectories on startup
- Upgrade existing user KBs to system KBs when matching directory found
- Admin can upload to system KBs (saved to knowledge_base dir)
- Regular users see only their own KBs on knowledge page
- Fix API permission checks for system KBs (list, detail, documents, update, delete)
- Add is_superuser to UserResponse and frontend User type
- Fix sidebar session menu visibility for long titles

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 16:42:28 +08:00
pengxiao 1ce689ad1e fix: sidebar menu visibility, model selector cleanup, time format
- Sidebar: restore DropdownMenu for session actions, fix long titles
  pushing button off-screen (add w-0 flex-1, w-full on content div)
- Model selector: remove SiliconFlow models, DeepSeek only
  (deepseek-reasoner default, deepseek-chat alternative)
- Message timestamp: change from HH:mm to yyyy/M/d HH:mm format
- Default model changed to deepseek-reasoner

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 15:10:45 +08:00
pengxiao 19b6cdcbd8 refactor: simplify thinking process UI and reduce noise
- Remove redundant status steps (understanding, preparing, generating)
  from SSE stream — only emit retrieved docs and reasoning content
- ThinkingProcess: only show when there's actual reasoning or docs
- Collapse header shows concise state: thinking count or doc count
- Clean up unused icon imports

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:26:30 +08:00
pengxiao ecd5c7ff31 feat: add DeepSeek official API support and capture reasoning content
- Add DeepSeek provider routing: deepseek-chat/deepseek-reasoner use
  api.deepseek.com, other models use SiliconFlow
- Add stream_with_reasoning() using raw OpenAI SDK to capture
  reasoning_content (langchain_openai strips this field)
- RAG chain and conversation chain both use stream_with_reasoning
  for proper reasoning display in thinking models
- Frontend model selector: grouped by provider (DeepSeek official +
  SiliconFlow), default changed to deepseek-chat
- Regenerate message converted to streaming with reasoning capture
- Minor UI: globals.css additions, chat store refactoring

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 12:37:31 +08:00
pengxiao 51d6fd22c0 feat: capture reasoning content from thinking models, improve thinking UI
- Backend: intercept reasoning_content from DeepSeek-R1/QwQ streaming
  chunks and emit as thinking events (stage=reasoning)
- RAG chain: show retrieved document titles/previews in thinking steps
- Conversation chain: directly stream from LLM to capture reasoning
- Frontend: collapsible thinking panel with reasoning section,
  document details, and time summary
- Replace relative time with HH:mm format for message timestamps

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 11:47:14 +08:00
pengxiao 62da8b3c58 fix: async document processing in background threads, improve chat UX
- Fix knowledge_base_service calling async process_document synchronously
  in background threads — use asyncio.new_event_loop().run_until_complete()
  instead of bare call that returned unawaited coroutine
- Same fix for _update_document and reindex_document
- Replace ModeSelector with auto-detect: RAG mode when knowledge bases selected
- Convert regenerateMessage to streaming (was synchronous API call)
- Show "知识库检索模式" indicator above input when KB selected
- Remove loadSessions side-effect from streaming onComplete
- Fix chat page loading state to avoid flash
- Improve forum page spacing and sizing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 11:33:32 +08:00
pengxiao 50faf7ad4e feat: add forum seed categories, improve page layouts and navigation
- Seed default forum categories (announcements, learning, feedback) on startup
- Update forum pages with improved category/post/reply UI
- Refine navbar, mobile nav, and home page content layout
- Improve analytics, course-content, knowledge, profile, settings, spatial pages

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 10:02:30 +08:00
pengxiao 45e3da82e1 fix: count all documents for homepage stats, not just knowledge_base type
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 09:47:04 +08:00
pengxiao 0251a5e3ff fix: propagate real message IDs via SSE and fix regenerate model parameter
- Add message_id and user_message_id to SSE done events so frontend
  can replace temp IDs with real DB IDs, fixing "消息不存在" on regenerate
- Replace Body(default=None) with RegenerateRequest Pydantic model for
  proper JSON body parsing, fixing 422 Unprocessable Content
- Frontend always sends model in regenerate request body
- Pass selected model through message-item → regenerateMessage chain
- Various UI refinements to chat sidebar, quick questions, and layout

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 09:00:31 +08:00
pengxiao 53a9380d7a style: redesign knowledge graph to light academic theme
Switch from dark p5-style background to light slate theme with softer
indigo particles, white label pills, and reduced glow effects for
better readability in academic context.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 14:25:53 +08:00
pengxiao 90ab913ef9 fix: use config paths for static file mounts, redesign knowledge graph
- Fix generated images 404: use settings.generated_images_dir and
  settings.upload_dir instead of hardcoded relative paths in main.py
- Redesign knowledge graph with p5-style particle background, glow
  nodes, and curved gradient links
- Update course-content page border styling

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 14:20:28 +08:00
pengxiao 09621ef767 refactor: simplify homepage layout, consolidate landing page components
Merge hero/stats/features/footer sections into home-page-content.tsx,
remove separate landing-page.tsx. Update styles, layout, navbar, and
backend config.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 11:24:34 +08:00
pengxiao ddbb79b9f6 Initial commit: 国土空间规划课程智能体 v1.0
单容器 Docker 架构的国土空间规划课程智能问答系统,集成 FastAPI 后端与 Next.js 前端。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 09:40:18 +08:00