chore: 清理 docs 目录冗余文档(55个→9个)
删除: - docs/1.0/ 全部22个(旧Simple KB文档,已被替代) - docs/2.0/ 全部2个(空文件/过时) - docs/design/ 全部4个(旧功能设计) - docs/plans/ 旧版5个(保留v2.0设计文档) - docs/superpowers/ 全部4个(飞书集成文档) - docs/根目录杂项 8个(开发规范/快速参考/调试/飞书/Git设置) - docs/3.0/knowledge_graph_analysis.md(不相关) 保留: - docs/3.0/ 考核工作流设计 2个 - docs/plans/ v2.0设计文档 1个 - docs/tests/ 测试文档 6个 合计: 55个 → 9个 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
# Feature Design: Automatic Title Generation (feat-auto-title-generation)
|
||||
|
||||
## 1. Overview
|
||||
This feature automatically generates meaningful titles for uploaded documents and chat sessions using AI. It aims to replace generic filenames and "New Conversation" labels with content-aware titles, improving user experience and organization.
|
||||
|
||||
## 2. Requirements
|
||||
|
||||
### 2.1 Document Title Generation
|
||||
- **Trigger**: Automatically triggered after text extraction (Fast or Precise mode).
|
||||
- **Process**:
|
||||
1. Extract a sample of the document content (first 2,000 - 3,000 characters).
|
||||
2. Send the content to the default LLM with a specific generation prompt.
|
||||
3. Update the `KnowledgeBase` record with the generated title.
|
||||
- **Rules**:
|
||||
- The title should be concise (less than 50 characters).
|
||||
- It should be in the user's preferred language (defaulting to the detected document language if possible).
|
||||
- Output should be "raw" (no preamble like "The title is...").
|
||||
|
||||
### 2.2 Chat Title Generation
|
||||
- **Trigger**: Triggered after the first user message and its corresponding assistant response are recorded.
|
||||
- **Process**:
|
||||
1. Collect the initial message pair.
|
||||
2. Send the pair to the default LLM with a generation prompt.
|
||||
3. Update the `SearchHistory` record's `title` field.
|
||||
- **Rules**: Same as document titles.
|
||||
|
||||
## 3. Technical Design
|
||||
|
||||
### 3.1 Data Model Changes
|
||||
- **KnowledgeBase Entity**: Add a `title` field (nullable, optional). If empty, fallback to `originalName`.
|
||||
- **SearchHistory Entity**: No changes required (has `title`).
|
||||
|
||||
### 3.2 Backend Implementation
|
||||
|
||||
#### KnowledgeBaseService
|
||||
- Add `generateTitle(kbId: string)` method.
|
||||
- Hook into `processFile` after `updateStatus(kbId, FileStatus.EXTRACTED)`.
|
||||
|
||||
#### ChatService / SearchHistoryService
|
||||
- Add logic to check if the session title is still the default (usually the first message snippet) and trigger `generateTitle(historyId: string)` after the first assistant response.
|
||||
|
||||
#### Prompt Design
|
||||
- **Document Prompt**:
|
||||
```text
|
||||
You are a document analyzer. Read the provided text and generate a concise, professional title (max 50 chars).
|
||||
Return ONLY the title.
|
||||
Language: {userLanguage}
|
||||
Text: {contentSample}
|
||||
```
|
||||
- **Chat Prompt**:
|
||||
```text
|
||||
Based on the following conversation snippet, generate a short, descriptive title (max 50 chars) that summarizes the topic.
|
||||
Return ONLY the title.
|
||||
Language: {userLanguage}
|
||||
Snippet:
|
||||
User: {userMessage}
|
||||
AI: {aiResponse}
|
||||
```
|
||||
|
||||
## 4. Verification Plan
|
||||
|
||||
### Automated Tests
|
||||
- Integration tests in `KnowledgeBaseService` to verify the title field is updated after processing.
|
||||
- Mock LLM responses to ensure the title update logic works.
|
||||
|
||||
### Manual Verification
|
||||
- Upload various files (PDF, Word, TXT) and verify the displayed title in the knowledge base list.
|
||||
- Start a new chat, send a message, and check the sidebar for the updated session title.
|
||||
Reference in New Issue
Block a user