Files
AIclinicalresearch/docs/03-业务模块/ASL-AI智能文献/05-开发记录/2025-11-22_Day2-Day3_LLM服务与验证系统开发.md
HaHafeng 1b53ab9d52 feat(aia): Complete AIA V2.0 with universal streaming capabilities
Major Changes:
- Add StreamingService with OpenAI Compatible format
- Upgrade Chat component V2 with Ant Design X integration
- Implement AIA module with 12 intelligent agents
- Update API routes to unified /api/v1 prefix
- Update system documentation

Backend (~1300 lines):
- common/streaming: OpenAI Compatible adapter
- modules/aia: 12 agents, conversation service, streaming integration
- Update route versions (RVW, PKB to v1)

Frontend (~3500 lines):
- modules/aia: AgentHub + ChatWorkspace (100% prototype restoration)
- shared/Chat: AIStreamChat, ThinkingBlock, useAIStream Hook
- Update API endpoints to v1

Documentation:
- AIA module status guide
- Universal capabilities catalog
- System overview updates
- All module documentation sync

Tested: Stream response verified, authentication working
Status: AIA V2.0 core completed (85%)
2026-01-14 19:15:01 +08:00

610 lines
15 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 蜈ィ譁<EFBDA8>、咲ュ帛シ€蜿題ョー蠖?- Day 2 & Day 3
**譌・譛<EFBDA5>**: 2025蟷?1譛?2譌?
**蠑€蜿鷹亳谿?*: MVP譬ク蠢<EFBDB8>粥閭ス蠑€蜿?
**雍溯エ」莠?*: AI Assistant
**迥カ諤?*: 笨?蟾イ螳梧<E89EB3>?
---
## <20>搭 蠑€蜿第ヲりァ?
譛ャ谺。蠑€蜿大ョ梧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>、咲ュ帷噪譬ク蠢キLM譛榊苅蜥碁ェ瑚ッ∫ウサ扈滂シ梧カオ逶縫ay 2蜥轡ay 3逧<33>園譛芽ョ。蛻剃ササ蜉。<E89C89>悟ケカ霑幄。御コ<E5BEA1><EFBDBA>髱「逧<EFBDA2>寔謌先オ玖ッ募柱髣ョ鬚倅ソョ螟阪€?
---
## 笨?蟾イ螳梧<E89EB3>蜉溯<E89C89>?
### Day 2: LLM 12蟄玲ョオ譛榊苅
#### 2.1 謠千、コ隸榊キ・遞倶ス鍋ウ?
**譬ク蠢<EFBDB8>枚莉カ**:
- `backend/src/modules/asl/fulltext-screening/prompts/system_prompt.md` (6,601蟄礼ャヲ)
- 9000+蟄苓ッヲ扈<EFBDA6>ystem Prompt
- Section-Aware遲也払<E4B99F>?豁・螟<EFBDA5>炊豕包シ?
- Lost in the Middle邇ー雎。郛楢ァ」
- 閾ェ鬪瑚ッ∵惻蛻カ<E89BBB><EFBDB6>elf-Verification<6F>?
- Chain-of-Thought蠑募ッシ
- `backend/src/modules/asl/fulltext-screening/prompts/user_prompt_template.md` (199陦?
- PICOS荳贋ク区枚豕ィ蜈?
-<>。」譬シ蠑剰<E8A091>騾ょコ<E38287>
-<><EFBFBD>闃よ署蜿匁欠蠑?
- `backend/src/modules/asl/fulltext-screening/prompts/json_schema.json`
- 荳・譬シ逧?2蟄玲ョオJSON Schema
-€蟆丞シ慕畑髟ソ蠎ヲ郤ヲ譚滂シ遺<EFBDBC>?0蟄礼ャヲ<EFBDAC>?
-<>怙蟄玲ョオ<EFBDAE>嗔rocessing_log縲」erification
**Cochrane譬<65>**<EFBFBD><EFBFBD>VP證ゆク榊刈霓ス<EFBFBD>?
- `prompts/cochrane_standards/髫乗惻蛹匁婿豕?md`
- `prompts/cochrane_standards/逶イ豕<EFBDB2>.md`
- `prompts/cochrane_standards/扈捺棡螳梧紛諤?md`
**Few-shot Examples**<EFBFBD>亥キイ遘サ髯、莉・莨伜喧Prompt髟ソ蠎ヲ<EFBFBD>?
- ~~`prompts/few_shot_examples/菫。諱ッ蝨ィ荳ュ髣エ菴咲スョ譯井セ?md`~~ (蟾イ蛻<EFBDB2>髯?
**隶セ隶。蜀ウ遲<EFBDB3>**:
- 笨?菫晉蕗System Prompt蜥袈ser Prompt蜴溷ァ狗沿譛ャ<E8AD9B>域悴邊セ邂€<E98282>?
- 笨?遘サ髯、Few-shot examples莉・蜃丞ー善rompt髟ソ蠎ヲ<E8A08E>井サ<E4BA95>74KB髯崎<E9ABAF>52KB<4B>?
- 笨?MVP髦カ谿オ荳榊刈霓スCochrane譬<65><EFBFBD>亥㍼蟆善rompt髟ソ蠎ヲ縲<EFBDA6>剄菴取<E88FB4>譛ャ<E8AD9B><EFBDAC>
#### 2.2 PromptBuilder譛榊苅
**譁<>サカ**: `backend/src/modules/asl/common/llm/PromptBuilder.ts` (275陦?
**譬ク蠢<EFBDB8>粥閭ス**:
- 蜉ィ諤∫サ<E288AB><EFBFBD>ystem Prompt蜥袈ser Prompt
- 蜿ッ騾牙刈霓スCochrane譬<65>
- 蜿ッ騾牙刈霓スFew-shot examples
- 扈捺棡郛灘ュ假シ亥㍼蟆第枚莉カI/O<>?
- 讓。譚ソ蜿倬㍼譖ソ謐「<E8AC90><EFBDA2>ICOS縲∫コウ蜈?謗帝勁譬<E58B81><EFBFBD>?
**MVP驟咲スョ**:
```typescript
const DEFAULT_MVP_CONFIG = {
loadCochraneStandards: false, // 荳榊刈霓スCochrane譬<65>
fewShotExamples: [], // 荳榊刈霓スFew-shot
};
```
**菫ョ螟埼琉鬚<E79089>**:
- 笨?菫ョ螟<EFBDAE> `__dirname` 蝨ィES讓。蝮嶺クュ逧<EFBDAD>スソ逕ィ<E98095>域隼逕?`fileURLToPath`<EFBFBD>?
- 笨?菫ョ螟肴枚莉カ霍ッ蠕<EFBDAF>漠隸ッ<E99AB8><EFBDAF>src/modules/modules/asl` 竊?`src/modules/asl`<60>?
- 笨?豺サ蜉<EFBDBB> `.js` 謇ゥ螻募錐莉・隨ヲ蜷<EFBDA6>S讓。蝮苓ァ<E88B93>
#### 2.3 LLM12FieldsService譬ク蠢<EFBDB8>恪蜉。
**譁<>サカ**: `backend/src/modules/asl/common/llm/LLM12FieldsService.ts` (547陦?
**譬ク蠢<EFBDB8>粥閭ス**:
1. **Nougat莨伜<E88EA8>謠仙叙遲也払**
- 闍ア譁⑰DF莨伜<E88EA8>菴ソ逕ィNougat<61>育サ捺桷蛹邦arkdown<77>?
- 雍ィ驥乗」€譟?+ PyMuPDF髯咲コァ
- 謾ッ謖∽クュ譁⑰DF逶エ謗・菴ソ逕ィPyMuPDF
2. **蜿梧ィ。蝙句ケカ陦瑚ー<E7919A><EFBDB0>?*
- DeepSeek-V3 + Qwen-Max
- 菴ソ逕ィ `Promise.allSettled` 螳樒鴫螳ケ髞<EFBDB9>
- 荳€荳ェ讓。蝙句、ア雍・荳榊スア蜩榊嘗荳€荳?
3. **3螻<33>SON隗」譫千ュ也払**<EFBFBD><EFBFBD>髞ョ蛻帶眠<EFBFBD><EFBFBD>
```typescript
Layer 1: 荳・譬シ JSON.parse()
Layer 2: json-repair 閾ェ蜉ィ菫ョ螟搾シ亥、<E4BAA5>炊蟶ク隗´LM譬シ蠑城漠隸ッ<E99AB8>?
Layer 3: 謠仙叙Markdown莉」遐∝摎荳ュ逧ЙSON
```
- 謌仙粥邇<E7B2A5><EFBFBD>100%<25>域オ玖ッ暮ェ瑚ッ<E7919A><EFBFBD>
- 閾ェ蜉ィ螟<EFBDA8>炊LLM霎灘<E99C8E><EFBFBD>推遘肴<E98198>シ蠑城琉鬚?
4. **讓。蝙句錐遘ー譏<EFBDB0><EFBFBD>**
```typescript
MODEL_NAME_MAP = {
'deepseek-v3': 'deepseek-chat',
'qwen-max': 'qwen3-72b',
};
```
- 隗」蜀ウ逕ィ謌キ蜿句・ス蜷咲ァー荳主<E88DB3>驛ィModelType逧<65>丐蟆<E4B890>琉鬚?
5. **扈捺棡郛灘ュ<E78198>**
- 蝓コ莠主<E88EA0>螳ケ蜩亥ク檎噪郛灘ュ倬醗
- 驕ソ蜈埼㍾螟広LM隹<4D>
- 譏セ闡鈴剄菴取オ玖ッ墓<EFBDAF>譛ャ
6. **謌先悽隶。邂<EFBDA1>**
- 荳ュ闍ア譁<EFBDB1>キキ蜷<EFBDB7>oken莨ー邂<EFBDB0>
- 螳樊慮謌先悽霍溯クェ
- 騾乗<E9A8BE><EFBFBD>エケ逕ィ扈溯ョ?
**菫ョ螟埼琉鬚<E79089>**:
- 笨?菫ョ螟広LM譁ケ豕戊ー<E6888A><EFBFBD><E79591>generateText` 竊?`chat`<EFBFBD>?
- 笨?菫ョ螟広LMFactory蟇シ蜈・霍ッ蠕<EFBDAF>
- 笨?豺サ蜉<EFBDBB>MODEL_NAME_MAP隗」蜀ウ讓。蝙狗アサ蝙倶ク榊源驟?
- 笨?螳樒鴫3螻<33>SON隗」譫千ュ也払菫ョ螟崎ァ」譫宣漠隸ッ
- 笨?謾ケ逕ィPromise.allSettled蠅槫シコ蜿梧ィ。蝙句ョケ髞?
**諤ァ閭ス謖<EFBDBD><E8AC96><EFBFBD>**<EFBFBD>亥黒遽⑰DF豬玖ッ包シ?
- 諤サ閠玲慮<E78EB2>?62遘?
- DeepSeek-V3<56>?3,404 tokens<6E>個?.0234
- Qwen-Max<61>?8,464 tokens<6E>個?.0739
- 諤サ謌先悽<E58588>堋・0.0973
---
### Day 3: 鬪瑚ッ∵恪蜉。 + 蜀イ遯∵」€豬?
#### 3.1 MedicalLogicValidator - 蛹サ蟄ヲ騾サ霎鷹ェ瑚ッ<E7919A>
**譁<>サカ**: `backend/src/modules/asl/common/validation/MedicalLogicValidator.ts` (413陦?
**譬ク蠢<EFBDB8>粥閭ス**:
- 5譚。蛹サ蟄ヲ騾サ霎題ァ<E9A18C><EFBDA7>鬪瑚ッ<E7919A>
1. RCT遐皮ゥカ蠢<EFBDB6>。サ譛蛾囂譛コ蛹匁婿豕<E5A9BF>
2. 逶イ豕穂ク守<EFBDB8>皮ゥカ隶セ隶。荳€閾エ諤?
3. 扈灘ア€<C280><E8AC96><EFBFBD>ク守サ捺棡螳梧紛諤ァ荳€閾エ諤?
4. 扈溯ョ。譁ケ豕穂ク守<EFBDB8>皮ゥカ隶セ隶。蛹ケ驟?
5. 蝓コ郤ソ蜿ッ豈疲€ァ荳朱囂譛コ蛹門<E89BB9>邉?
**螳ケ髞吝「槫シコ**:
```typescript
safeGetFieldValue(fieldData: any): string {
// 螟<>炊 null/undefined
// 螟<>炊蟇ケ雎。邀サ蝙具シ域署蜿紡ssessment蟄玲ョオ<EFBDAE>?
// 螟<>炊蟄礼ャヲ荳イ邀サ蝙?
// 霑泌屓遨コ蟄礼ャヲ荳イ菴應クコ鮟倩ョ、蛟?
}
```
- 笨?謇€譛芽ァ<E88ABD><EFBDA7>菴ソ逕?`safeGetFieldValue` 謠仙叙蟄玲ョオ蛟?
- 笨?莨倬寉螟<E5AF89>炊LLM霎灘<E99C8E><EFBFBD>推遘肴焚謐ョ扈捺<E68988>?
**豬玖ッ慕サ捺棡**:
- DeepSeek-V3: 笨?5/5 騾夊ソ<E5A48A>
- Qwen-Max: 笨?5/5 騾夊ソ<E5A48A>
#### 3.2 EvidenceChainValidator - 隸∵紺體セ鬪瑚ッ?
**譁<>サカ**: `backend/src/modules/asl/common/validation/EvidenceChainValidator.ts` (464陦?
**譬ク蠢<EFBDB8>粥閭ス**:
- 鬪瑚ッ∵ッ丈クェ蟄玲ョオ逧<EFBDB5>ッ∵紺體セ螳梧紛諤?
- 蜴滓枚蠑慕畑髟ソ蠎ヲ<E8A08E>遺翁50蟄礼ャヲ<EFBDAC>?
- 蠑慕畑菴咲スョ譛画譜諤?
-<>炊譌・蠢怜ョ梧紛諤?
- 閾ェ鬪瑚ッ∬ョー蠖募ョ梧紛諤?
**螳ケ髞吝「槫シコ**:
```typescript
if (!fields || typeof fields !== 'object') {
this.logger.warn('Fields is undefined, null, or not an object');
return validationResult;
}
```
- 笨?螳牙<E89EB3><EFBFBD>`undefined`/`null` fields
- 笨?驕ソ蜈<EFBDBF> `Object.entries()` 蟠ゥ貅<EFBDA9>
**豬玖ッ慕サ捺棡**:
- DeepSeek-V3: 笞<><E7AC9E><EFBFBD> 荳榊ョ梧紛<E6A2A7><E7B49B>ields荳コundefined<65>悟キイ螳ケ髞呻シ?
- Qwen-Max: 笨?12/12 蟄玲ョオ螳梧紛
#### 3.3 ConflictDetectionService - 蜀イ遯∵」€豬?
**譁<>サカ**: `backend/src/modules/asl/common/validation/ConflictDetectionService.ts` (432陦?
**譬ク蠢<EFBDB8>粥閭ス**:
1. **蟄玲ョオ郤ァ蜀イ遯∵」€豬?*
- 蟇ケ豈比ク、荳ェ讓。蝙狗<E89D99>?2蟄玲ョオ隸<EFBDB5>シー扈捺棡
-<>悪隸<E682AA>シー荳堺ク€閾エ逧<EFBDB4>ュ玲ョオ
2. **蜈ウ髞ョ蟄玲ョオ隸<EFBDB5>**
- 蜈ウ髞ョ蟄玲ョオ<EFBDAE>夐囂譛コ蛹匁婿豕輔€∫峇豕輔€∫サ捺棡螳梧紛諤?
- 驥崎ヲ∝ュ玲ョオ<EFBDAE>壻ココ鄒、迚ケ蠕√€∝ケイ鬚<EFBDB2>蒔譁ス縲∝ッケ辣ァ謗ェ譁ス縲∫サ灘ア€<C280><E8AC96><EFBFBD>€∫サ溯ョ。譁ケ豕?
- 譎ョ騾壼ュ玲ョオ<EFBDAE><EFBFBD>莉門ュ玲ョオ
3. **荳・驥咲ィ句コヲ蛻<EFBDA6>コァ**
- High: 蜈ウ髞ョ蟄玲ョオ蜀イ遯∵<E981AF>諤サ菴灘<E88FB4>遲門<E981B2><EFBFBD>
- Medium: 驥崎ヲ∝ュ玲ョオ蜀イ遯<EFBDB2>
- Low: 莉<>勸騾壼ュ玲ョオ蜀イ遯?
4. **螟肴<E89E9F>ク莨伜<E88EA8>郤ァ隶。邂?*
- 蝓コ莠主<E88EA0>遯∽ク・驥咲ィ句コヲ縲∝ュ玲ョオ謨ー驥?
- 0-100蛻<30>
- 閾ェ蜉ィ隶。邂怜サコ隶ョ螟肴<E89E9F>ク謌ェ豁「譌カ髣エ
**螳ケ髞吝「槫シコ**:
```typescript
if (!fieldsA || typeof fieldsA !== 'object') {
logger.warn('fieldsA is null, undefined, or not an object');
return { conflictFields: [], fieldConflictDetails: [] };
}
```
- 笨?螳牙<E89EB3><EFBFBD>`undefined`/`null` fields
- 笨?菫ョ螟<EFBDAE> logger 隹<><EFBFBD><E79591>this.logger` 竊?`logger`<60>?
**豬玖ッ慕サ捺棡**:
- 笨?謌仙粥譽€豬句<E8B1AC><EFBFBD><EFBFBD>ndefined vs 豁」蟶クfields<64>?
- 笨?螳ケ髞呎惻蛻カ蟾・菴懈ュ」蟶ク
- 笨?荳榊<E88DB3>蟠ゥ貅<EFBDA9>
---
## <20>ァェ 髮<><E9ABAE>豬玖ッ<E78E96>
### 豬玖ッ墓枚莉カ
1. **`__tests__/integration-test.ts`** (螳梧紛髮<E7B49B><E9ABAE>豬玖ッ<E78E96>)
- 豬玖ッ<E78E96>2-3遽<33>悄螳霸DF
- 螳梧紛LLM隹<4D>畑豬∫ィ<E288AB>
- 閠玲慮<E78EB2>夐「<E5A490>ョ?-10蛻<30>
2. **`__tests__/quick-test.ts`** (蠢ォ騾滓オ玖ッ?
- 豬玖ッ<E78E96>1遽⑰DF
-€豢∬セ灘<EFBDBE>?
- 閠玲慮<E78EB2>夂コヲ3蛻<33>
3. **`__tests__/cached-result-test.ts`** (螳ケ髞咎ェ瑚ッ<E7919A>)
- 逶エ謗・豬玖ッ暮ェ瑚ッ∝<EFBDAF>?
- 讓。諡溷推遘榊シょクク霎灘<E99C8E>
- 遘堤コァ螳梧<E89EB3>
### 豬玖ッ慕サ捺棡諤サ扈<EFBDBB>
**笨?3螻<33>SON隗」譫千ュ也払鬪瑚ッ<E7919A>**:
- Qwen-Max: Layer 2閾ェ蜉ィ菫ョ螟搾シ井ソョ螟?0蟄苓鰍譬シ蠑城漠隸ッ<E99AB8>?
- DeepSeek-V3: Layer 3莉皿arkdown莉」遐∝摎謠仙<E8ACA0>?
- **謌仙粥邇<E7B2A5><EFBFBD>100%**
**笨?蜿梧ィ。蝙句ョケ髞咎ェ瑚ッ?*:
- Promise.allSettled豁」蟶ク蟾・菴<EFBDA5>
- 荳、荳ェ讓。蝙句ケカ陦悟、<E6829F>炊謌仙粥
**笨?蛹サ蟄ヲ騾サ霎鷹ェ瑚ッ<E7919A>**:
- DeepSeek-V3: 5/5 笨?
- Qwen-Max: 5/5 笨?
**笨?蜀イ遯∵」€豬句ョケ髞?*:
- 謌仙粥螟<E7B2A5>炊undefined fields
- 荳榊<E88DB3>蟠ゥ貅<EFBDA9>
---
## <20>菅 髣ョ鬚倅ソョ螟崎ョー蠖<EFBDB0>
### 髣ョ鬚<EFBDAE>1: ES讓。蝮<EFBDA1> `__dirname` 譛ェ螳壻ケ?
**髞呵ッッ**: `ReferenceError: __dirname is not defined in ES module scope`
**菫ョ螟<EFBDAE>**:
```typescript
// 菫ョ螟榊<E89E9F>?
const promptDir = path.join(__dirname, '../../fulltext-screening/prompts');
// 菫ョ螟榊<E89E9F>?
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
```
**蠖ア蜩肴枚莉カ**: `PromptBuilder.ts`
---
### 髣ョ鬚<EFBDAE>2: 譁<>サカ霍ッ蠕<EFBDAF>漠隸ッ
**髞呵ッッ**: `ENOENT: no such file or directory, open 'D:\...\src\modules\modules\asl\...'`
**蜴溷屏**: 霍ッ蠕<EFBDAF>蕎謗・髞呵ッッ<EFBDAF>碁㍾螟堺コ<E5A0BA>modules`
**菫ョ螟<EFBDAE>**: 菫ョ豁」逶ク蟇ケ霍ッ蠕<EFBDAF>ョ。邂鈴€サ霎<EFBDBB>
**蠖ア蜩肴枚莉カ**: `PromptBuilder.ts`
---
### 髣ョ鬚<EFBDAE>3: ES讓。蝮怜ッシ蜈・郛コ蟆<EFBDBA> `.js` 謇ゥ螻募<E89EBB>?
**髞呵ッッ**: `蠖?"--moduleResolution" 荳?"node16" 謌?"nodenext" 譌カ<E8AD8C>檎嶌蟇ケ蟇シ蜈・霍ッ蠕<EFBDAF>怙隕?ECMAScript 蟇シ蜈・荳ュ逧<EFBDAD>仞蠑乗枚莉カ謇ゥ螻募錐`
**菫ョ螟<EFBDAE>**: 謇€譛臥嶌蟇ケ蟇シ蜈・豺サ蜉?`.js` 謇ゥ螻募<E89EBB>?
```typescript
import { PromptBuilder } from './PromptBuilder.js';
import type { LLM12FieldsResult } from './types.js';
```
**蠖ア蜩肴枚莉カ**: `LLM12FieldsService.ts`, `PromptBuilder.ts`, `index.ts`
---
### 髣ョ鬚<EFBDAE>4: LLM譁ケ豕穂ク榊ュ伜<EFBDAD>?
**髞呵ッッ**: `邀サ蝙<EFBFBD>"ILLMAdapter"荳贋ク榊ュ伜惠螻樊€?generateText"`
**蜴溷屏**: ILLMAdapter謗・蜿」蜿ェ譛荏chat`譁ケ豕包シ梧イ。譛荏generateText`
**菫ョ螟<EFBDAE>**:
```typescript
// 菫ョ螟榊<E89E9F>?
const response = await adapter.generateText(prompt);
// 菫ョ螟榊<E89E9F>?
const response = await adapter.chat(messages);
```
**蠖ア蜩肴枚莉カ**: `LLM12FieldsService.ts`
---
### 髣ョ鬚<EFBDAE>5: 讓。蝙狗アサ蝙倶ク榊源驟?
**髞呵ッッ**: `Unsupported model type: qwen-max`
**蜴溷屏**: `LLMFactory`譛滓悍逧МodelType譏ッ`qwen3-72b`<60>御ス<E5BEA1><EFBFBD>蜈・逧<EFBDA5>弍`qwen-max`
**菫ョ螟<EFBDAE>**: 豺サ蜉<EFBDBB>讓。蝙句錐遘ー譏<EFBDB0><EFBFBD>
```typescript
private readonly MODEL_NAME_MAP: Record<string, ModelType> = {
'deepseek-v3': 'deepseek-chat',
'qwen-max': 'qwen3-72b',
};
```
**蠖ア蜩肴枚莉カ**: `LLM12FieldsService.ts`
---
### 髣ョ鬚<EFBDAE>6: JSON隗」譫仙、ア雍・
**髞呵ッッ**: `SyntaxError: Expected ',' or '}' after property value in JSON`
**蜴溷屏**: LLM霎灘<E99C8E>逧ЙSON蜿ッ閭ス譛画<E8AD9B>シ蠑城琉鬚俶<E9AC9A>陲ォ蛹<EFBDAB>」ケ蝨ィMarkdown莉」遐∝摎荳ュ
**菫ョ螟<EFBDAE>**: 螳樒鴫3螻<33>SON隗」譫千ュ也払
```typescript
// Layer 1: 荳・譬シ隗」譫<EFBDA3>
try {
return JSON.parse(text);
} catch {}
// Layer 2: json-repair閾ェ蜉ィ菫ョ螟<EFBDAE>
try {
return JSON.parse(jsonrepair(text));
} catch {}
// Layer 3: 謠仙叙Markdown莉」遐∝<E98190>?
const match = text.match(/```json\s*\n([\s\S]*?)\n```/);
if (match) {
return JSON.parse(match[1]);
}
```
**蠖ア蜩肴枚莉カ**: `LLM12FieldsService.ts`
**萓晁オ<E69981>**: 螳芽」<E88ABD> `json-repair` 蠎?
---
### 髣ョ鬚<EFBDAE>7: MedicalLogicValidator譌<72>豕募、<E58B9F>炊蟇ケ雎。邀サ蝙句ュ玲ョオ
**髞呵ッッ**: 蟄玲ョオ蛟シ蜿ッ閭ス譏ッ蟇ケ雎。<E99B8E><EFBDA1>{ assessment: '螳梧紛', confidence: 0.9 }`<EFBFBD>€碁撼蟄礼ャヲ荳?
**菫ョ螟<EFBDAE>**: 豺サ蜉<EFBDBB> `safeGetFieldValue`<>勧蜃ス謨ー
```typescript
private safeGetFieldValue(fieldData: any): string {
if (!fieldData) return '';
if (typeof fieldData === 'string') return fieldData;
if (typeof fieldData === 'object' && fieldData.assessment) {
return fieldData.assessment;
}
return '';
}
```
**蠖ア蜩肴枚莉カ**: `MedicalLogicValidator.ts`
---
### 髣ョ鬚<EFBDAE>8: EvidenceChainValidator螟<72>炊undefined fields蟠ゥ貅<EFBDA9>
**髞呵ッッ**: `Cannot convert undefined or null to object`
**蜴溷屏**: `Object.entries(fields)` 蝨?`fields` 荳?`undefined` 譌カ蟠ゥ貅?
**菫ョ螟<EFBDAE>**: 豺サ蜉<EFBDBB>null譽€譟?
```typescript
if (!fields || typeof fields !== 'object') {
this.logger.warn('Fields is undefined, null, or not an object');
return validationResult;
}
```
**蠖ア蜩肴枚莉カ**: `EvidenceChainValidator.ts`
---
### 髣ョ鬚<EFBDAE>9: ConflictDetectionService logger譛ェ螳壻ケ?
**髞呵ッッ**: `Cannot read properties of undefined (reading 'warn')`
**蜴溷屏**: 菴ソ逕ィ莠?`this.logger.warn`<EFBFBD>御ス<EFBFBD>ッ・邀サ菴ソ逕ィ蜈ィ螻€ `logger`
**菫ョ螟<EFBDAE>**:
```typescript
// 菫ョ螟榊<E89E9F>?
this.logger.warn('fieldsA is null, undefined, or not an object');
// 菫ョ螟榊<E89E9F>?
logger.warn('fieldsA is null, undefined, or not an object');
```
**蠖ア蜩肴枚莉カ**: `ConflictDetectionService.ts`
---
### 髣ョ鬚<EFBDAE>10: Promise蟷カ陦悟、<E6829F>炊郛コ荵丞ョケ髞<EFBDB9>
**蜴溷屏**: 菴ソ逕ィ `Promise.all`<EFBFBD>御ク€荳ェ讓。蝙句、ア雍・莨壼ッシ閾エ謨エ荳ェ豬∫ィ句、ア雍・
**菫ョ螟<EFBDAE>**: 謾ケ逕ィ `Promise.allSettled`
```typescript
const results = await Promise.allSettled([
this.process12Fields(pdfBuffer, picosContext, 'deepseek-v3'),
this.process12Fields(pdfBuffer, picosContext, 'qwen-max'),
]);
// 莨倬寉螟<E5AF89>炊驛ィ蛻<EFBDA8>、ア雍・
if (results[0].status === 'fulfilled') { /* 菴ソ逕ィ扈捺棡A */ }
if (results[1].status === 'fulfilled') { /* 菴ソ逕ィ扈捺棡B */ }
```
**蠖ア蜩肴枚莉カ**: `LLM12FieldsService.ts`
---
## <20>逃 譁ー蠅樔セ晁オ<E69981>
```json
{
"dependencies": {
"json-repair": "^0.x.x" // JSON閾ェ蜉ィ菫ョ螟榊コ?
}
}
```
**螳芽」<E88ABD>多莉、**:
```bash
cd backend
npm install json-repair
```
---
## <20>投 莉」遐∫サ溯ョ。
**譁ー蠅樊枚莉カ**: 22荳?
**諤サ莉」遐∬。梧<EFBDA1>?*: ~4,500陦?
**譬ク蠢<EFBDB8>恪蜉。**:
- `PromptBuilder.ts`: 275陦?
- `LLM12FieldsService.ts`: 547陦?
- `MedicalLogicValidator.ts`: 413陦?
- `EvidenceChainValidator.ts`: 464陦?
- `ConflictDetectionService.ts`: 432陦?
**謠千、コ隸肴枚莉?*:
- `system_prompt.md`: 6,601蟄礼ャヲ
- `user_prompt_template.md`: 199陦?
- Cochrane譬<65>㊥: 3荳ェ譁<EFBDAA>サ?
**豬玖ッ墓枚莉カ**:
- `integration-test.ts`: ~200陦?
- `quick-test.ts`: 266陦?
- `cached-result-test.ts`: 129陦?
---
## <20>識 雍ィ驥丈ソ晁ッ<E69981>
### 莉」遐∬エィ驥<EFBDA8>
- 笨?謇€譛瑛inter髞呵ッッ蟾イ菫ョ螟?
- 笨?TypeScript邀サ蝙句ョ牙<EFBDAE>
- 笨?ES讓。蝮苓ァ<E88B93>激驕オ蠕ェ
- 笨?螳梧紛逧<E7B49B>漠隸ッ螟<EFBDAF><E89E9F>?
- 笨?隸ヲ扈<EFBDA6>噪譌・蠢苓ョー蠖?
### 豬玖ッ戊ヲ<E6888A>
- 笨?蜊募<E89C8A>豬玖ッ包シ磯ェ瑚ッ∝勣<E2889D>?
- 笨?髮<><E9ABAE>豬玖ッ包シ亥ョ梧紛豬∫ィ具シ<E585B7>
- 笨?螳ケ髞呎オ玖ッ包シ亥シょクク螟<EFBDB8><EFBFBD><E7828A>
- 笨?逵溷ョ霸DF豬玖ッ<E78E96>
### 諤ァ閭ス莨伜喧
- 笨?扈捺棡郛灘ュ假シ磯∩蜈埼㍾螟崎ー<E5B48E><EFBFBD><E79591>
- 笨?蟷カ陦悟、<E6829F><EFBFBD>亥曙讓。蝙具シ?
- 笨?Prompt莨伜喧<E4BC9C>育ァサ髯、Few-shot<6F>悟㍼蟆?4KB竊?2KB<4B>?
- 笨?謌先悽霑ス雕ェ<E99B95>€<C280><EFBFBD>エケ逕ィ扈溯ョ。<EFBDAE><EFBDA1>
---
## <20>噫 荳倶ク€豁・隶。蛻?
譬ケ謐ョ蠑€蜿題ョ。蛻?`04-蜈ィ譁<EFBDA8>、咲ュ帛シ€蜿題ョ。蛻?md`<EFBFBD>?
**Day 4: 謇ケ螟<EFBDB9>炊莉サ蜉。譛榊<E8AD9B>?* (蠕<>€蟋?
- 莉サ蜉。髦溷<E9ABA6>邂。逅<EFBDA1>
- 謇ケ驥丞、<E4B89E>炊騾サ霎<EFBDBB>
- 霑帛コヲ霍溯クェ
- 蟷カ蜿第而蛻カ
**Day 5: 蜑咲ォッUI蠑€蜿?* (蠕<>€蟋?
- 隶セ鄂ョ鬘オ髱「
- 蟾・菴懷床鬘オ髱?
- 扈捺棡鬘オ髱「
- 蜿瑚ァ<E7919A>崟螳。髦<EFBDA1>シケ遯?
**Day 6: API髮<49><E9ABAE>荳手隹?* (蠕<>€蟋?
- RESTful API螳樒鴫
- 蜑榊錘遶ッ閨碑ー?
- 遶ッ蛻ー遶ッ豬玖ッ?
---
## <20>庁 蜈ウ髞ョ謚€譛ッ蜀ウ遲?
### 蜀ウ遲<EFBDB3>1: 遘サ髯、Few-shot Examples
**逅<>罰**:
- Prompt莉?4KB髯崎<E9ABAF>52KB
- 髯堺ス鮫LM隹<4D>畑謌先悽郤?0%
- MVP髦カ谿オ莨伜<E88EA8>騾溷コヲ蜥梧<E89CA5>譛?
**蜷守サュ**: 蜿ッ蝨ィ逕滉コァ邇ッ蠅<EFBDAF><E8A085>ケ謐ョ蜃<EFBDAE>。ョ邇<EFBDAE>怙豎る㍾譁ー隸<EFBDB0>シ?
### 蜀ウ遲<EFBDB3>2: MVP荳榊刈霓スCochrane譬<65>
**逅<>罰**:
- 蜃丞ー善rompt髟ソ蠎ヲ
- 髯堺ス鮫LM隹<4D>畑謌先悽
- 荳捺ウィ譬ク蠢ゴection-Aware遲也払
**蜷守サュ**: 蜿ッ騾夊ソ<E5A48A><EFBDBF>鄂ョ蠑€蜈ウ轣オ豢サ蜷ッ逕?
### 蜀ウ遲<EFBDB3>3: 3螻<33>SON隗」譫千ュ也払
**逅<>罰**:
- LLM霎灘<E99C8E>譬シ蠑丈ク咲ィウ螳?
- 驕ソ蜈崎ァ」譫仙、ア雍・蟇シ閾エ謨エ荳ェ莉サ蜉。螟ア雍・
-€霑帑ソョ螟咲ュ也払<E4B99F>悟ソォ騾櫪VP莠、莉<EFBDA4>
**謨域棡**: 豬玖ッ穂ク?00%謌仙粥邇?
### 蜀ウ遲<EFBDB3>4: Promise.allSettled螳ケ髞<EFBDB9>
**逅<>罰**:
- 荳€荳ェ讓。蝙句、ア雍・荳榊スア蜩榊嘗荳€荳?
- 莨倬寉髯咲コァ<EFBDBA><EFBDA7>egraded Mode<64>?
- 謠宣ォ倡ウサ扈溷庄髱<E5BA84>諤?
**謨域棡**: 蜿梧ィ。蝙句ョケ髞咎ェ瑚ッ<E7919A>€夊ソ<E5A48A>
---
## <20>統 扈城ェ梧€サ扈<EFBDBB>
### 謌仙粥扈城ェ<E59F8E>
1. **貂占ソ帛シ丞シ€蜿?*: 蜈亥ョ樒鴫譬ク蠢<EFBDB8>粥閭ス<E996AD><EFBFBD>莨伜喧扈<E596A7><E68988>?
2. **螳梧紛豬玖ッ<E78E96>**: 蜊募<E89C8A>豬玖ッ<E78E96> + 髮<><E9ABAE>豬玖ッ<E78E96> + 螳ケ髞呎オ玖ッ<E78E96>
3. **螳ケ髞呵ョセ隶。**: 螟壼アる亟謚、<E8AC9A>御シ倬寉髯咲コ?
4. **諤ァ閭ス莨伜<E88EA8>**: Prompt莨伜喧縲∫シ灘ュ俶惻蛻カ縲∝ケカ陦悟、<E6829F><EFBDA4>?
### 謨呵ョュ
1. **ES讓。蝮苓ソ∫ァサ**: 髴€隕∵ウィ諢?`__dirname`縲~.js` 謇ゥ螻募錐遲臥サ<E887A5>
2. **LLM霎灘<E99C8E>荳咲ィウ螳?*: 蠢<>。サ譛詠obust逧<74>ァ」譫仙柱鬪瑚ッ∵惻蛻カ
3. **TypeScript邀サ蝙区」€譟?*: 譌ゥ譛溷書邇ー貎懷惠髣ョ鬚<EFBDAE>
4. **譌・蠢苓ョー蠖<EFBDB0>**: 隸ヲ扈<EFBDA6>律蠢怜ッケ隹<EFBDB9>ッ戊<EFBDAF>蜈ウ驥崎ヲ?
---
## <20>梼 逶ク蜈ウ譁<EFBDB3>。」
- **蠑€蜿題ョ。蛻?*: `04-蠑€蜿題ョ。蛻?04-蜈ィ譁<EFBDA8>、咲ュ帛シ€蜿題ョ。蛻?md`
- **雍ィ驥丈ソ晞囿遲也払**: `02-謚€譛ッ隶セ隶?08-蜈ィ譁<EFBDA8>、咲ュ幄エィ驥丈ソ晞囿遲也払.md`
- **API隶セ隶。**: `02-謚€譛ッ隶セ隶?02-API隶セ隶。隗<EFBDA1>激.md`
- **謨ー謐ョ蠎楢ョセ隶?*: `02-謚€譛ッ隶セ隶?01-謨ー謐ョ蠎楢ョセ隶?md`
---
**螳梧<E89EB3>譌・譛<EFBDA5>**: 2025蟷?1譛?2譌?
**迥カ諤?*: 笨?Day 2 & Day 3 蜈ィ驛ィ螳梧<E89EB3>
**荳倶ク€豁?*: Day 4 謇ケ螟<EFBDB9>炊莉サ蜉。譛榊<E8AD9B>?