Commit 22dc6af
committed
Improve self-reflection question handling: special instruction, context formatting, rewrite logic, cache
1. Add special instruction for self-reflection questions about 'chà tá»':
- Detect self-reflection questions about critical/survival-level weaknesses
- Provide StillMe-specific architecture details (validation chain, RAG retrieval, RSS feeds, etc.)
- Require meta-cognitive reflection about which weaknesses are most critical
- Structure: Group by category (Technical, Philosophical, Operational), explain why 'chà tá»', how StillMe faces it
- Location: backend/identity/prompt_builder.py
2. Fix context formatting for foundational knowledge:
- Check both 'content' and 'document' fields (ChromaDB may return either)
- Ensure foundational knowledge markers are properly included in context_text
- Location: stillme_core/rag/rag_retrieval.py
3. Improve rewrite logic for StillMe queries:
- Allow rewrite if quality is very low (< 0.5) even for StillMe queries
- Preserve foundational knowledge in rewrite prompt
- Only skip rewrite if quality is acceptable (>= 0.5)
- Location: backend/api/routers/chat_router.py
4. Disable cache for self-reflection questions:
- Self-reflection questions need fresh analysis, not cached generic answers
- Cache disabled for StillMe self-reflection questions
- Location: backend/api/routers/chat_router.py
All improvements address the issue where StillMe gave generic AI answers instead of StillMe-specific analysis for self-reflection questions.1 parent ed082ea commit 22dc6af
3 files changed
Lines changed: 124 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4756 | 4756 | | |
4757 | 4757 | | |
4758 | 4758 | | |
4759 | | - | |
4760 | | - | |
4761 | | - | |
4762 | | - | |
4763 | | - | |
4764 | | - | |
4765 | | - | |
4766 | | - | |
4767 | | - | |
4768 | | - | |
4769 | | - | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
| 4771 | + | |
4770 | 4772 | | |
4771 | | - | |
| 4773 | + | |
| 4774 | + | |
4772 | 4775 | | |
4773 | | - | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
4774 | 4789 | | |
4775 | 4790 | | |
4776 | 4791 | | |
| |||
5588 | 5603 | | |
5589 | 5604 | | |
5590 | 5605 | | |
| 5606 | + | |
| 5607 | + | |
5591 | 5608 | | |
5592 | | - | |
5593 | | - | |
5594 | | - | |
5595 | | - | |
5596 | | - | |
5597 | | - | |
5598 | | - | |
5599 | | - | |
| 5609 | + | |
| 5610 | + | |
| 5611 | + | |
| 5612 | + | |
| 5613 | + | |
| 5614 | + | |
| 5615 | + | |
| 5616 | + | |
| 5617 | + | |
| 5618 | + | |
| 5619 | + | |
| 5620 | + | |
| 5621 | + | |
| 5622 | + | |
5600 | 5623 | | |
5601 | 5624 | | |
5602 | 5625 | | |
5603 | | - | |
| 5626 | + | |
5604 | 5627 | | |
5605 | 5628 | | |
5606 | 5629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
| 457 | + | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
| 516 | + | |
517 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
518 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
519 | 594 | | |
520 | 595 | | |
521 | 596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
884 | | - | |
| 884 | + | |
| 885 | + | |
885 | 886 | | |
886 | 887 | | |
887 | 888 | | |
| |||
0 commit comments