This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
KnowledgeBase/files/client/custom/modules/knowledge-base/res/templates/kb/index.tpl
T
chaim 8829a2e93a feat: KnowledgeBase extension v0.1.6 — inline PDF viewer in browse tab
KnowledgeBase extension for EspoCRM: UI on top of the shira-hermes KB of
Israeli National Insurance law, regulations, and circulars.

Three modes:
- חיפוש — Hybrid (pgvector + tsvector) + Voyage rerank-2.5, returns ranked
  chunks with heading_path and citations.
- שאל את שירה — Full agent loop; Shira picks up search_insurance_kb as
  needed and returns a summary with citations.
- עיון — Browse all active sources. Click a source:
  - PDF source (ספר הליקויים, ספר המבחנים, circulars): renders the
    original PDF inline via an iframe proxied through the
    KnowledgeBasePdf EntryPoint, so the layout/columns/tables are
    preserved and Ctrl+F works natively.
  - TXT source (חוק הביטוח הלאומי scraped from Wikisource): falls back
    to the hierarchical chunk list with RTL styling.

Architecture:
- Controller: KnowledgeBase.php — thin proxy to shira-hermes /kb/*.
- Service: KnowledgeBaseService.php — shared curl plumbing; derives the
  shira-hermes base URL from the SmartAssistant integration record so
  there is no second admin config.
- EntryPoint: KnowledgeBasePdf.php — streams the PDF inline, wraps the
  body in a php://temp stream for setBody, applies a locked-down CSP.
- JS: views/kb/index.js branches on source.original_path; modes wired
  through the SmartAssistant fa_IR i18n convention.

Auth model:
- Browser → EspoCRM: session cookie / X-Api-Key (EspoCRM's existing auth).
- EspoCRM → shira-hermes: X-Api-Key from the SmartAssistant integration
  (never exposed to the browser).
- Portal users are blocked at both the Controller and the EntryPoint.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 11:57:23 +00:00

60 lines
2.7 KiB
Smarty

<div class="kb-page" dir="rtl">
<div class="page-header">
<h3>בסיס ידע — ביטוח לאומי</h3>
</div>
<ul class="nav nav-tabs" style="margin-bottom:12px;">
<li class="{{#ifEqual mode 'search'}}active{{/ifEqual}}">
<a href="#" role="button" data-action="switchMode" data-mode="search">חיפוש</a>
</li>
<li class="{{#ifEqual mode 'ask'}}active{{/ifEqual}}">
<a href="#" role="button" data-action="switchMode" data-mode="ask">שאל את שירה</a>
</li>
<li class="{{#ifEqual mode 'browse'}}active{{/ifEqual}}">
<a href="#" role="button" data-action="switchMode" data-mode="browse">עיון</a>
</li>
</ul>
{{#ifEqual mode 'search'}}
<div class="kb-search-box" style="margin-bottom:12px;">
<div class="form-inline" style="display:flex;gap:8px;flex-wrap:wrap;">
<input type="text" class="form-control" data-name="query"
placeholder="מונחי חיפוש…"
style="flex:1 1 320px;min-width:280px;" />
<select class="form-control" data-name="kind" style="flex:0 0 auto;">
<option value="any">כל הסוגים</option>
<option value="law">חוק</option>
<option value="regulation">תקנות</option>
<option value="circular">חוזרים</option>
</select>
<button type="button" class="btn btn-primary" data-action="submit">חפש</button>
</div>
<div class="small text-muted" style="margin-top:6px;">
חיפוש Hybrid: וקטורי + מילולי + rerank. מחזיר עד 8 קטעים רלוונטיים.
</div>
</div>
{{/ifEqual}}
{{#ifEqual mode 'ask'}}
<div class="kb-search-box" style="margin-bottom:12px;">
<div class="form-inline" style="display:flex;gap:8px;flex-wrap:wrap;">
<input type="text" class="form-control" data-name="query"
placeholder="שאלה בשפה חופשית…"
style="flex:1 1 320px;min-width:280px;" />
<button type="button" class="btn btn-primary" data-action="submit">שאל את שירה</button>
</div>
<div class="small text-muted" style="margin-top:6px;">
שירה תחפש בבסיס הידע ותחזיר תשובה מסוכמת עם ציטוטים.
</div>
</div>
{{/ifEqual}}
{{#ifEqual mode 'browse'}}
<div class="kb-sources panel panel-default" style="padding:12px;">
<div class="text-muted">טוען מקורות…</div>
</div>
{{/ifEqual}}
<div class="kb-results" style="margin-top:12px;"></div>
</div>