semantic search

This commit is contained in:
Hamid Reza Mohammadi 2026-09-10 14:42:11 +03:30
parent b0d21bbb09
commit 1303431972
2 changed files with 50 additions and 17 deletions

View File

@ -98,14 +98,35 @@
flex-shrink: 0;
}
#ss-widget-query {
flex: 1;
padding: 8px 12px;
#ss-widget-form input[type="text"],
#ss-widget-form input[type="submit"] {
box-sizing: border-box;
height: 38px;
font-size: 0.95rem;
border-radius: 8px;
border: 1px solid var(--border-gold);
}
#ss-widget-query {
flex: 1;
padding: 0 12px;
background: var(--card-inner);
color: inherit;
font-size: 0.95rem;
}
#ss-widget-form input[type="submit"] {
padding: 0 16px;
background: var(--card-inner);
color: var(--brand);
-webkit-text-fill-color: var(--brand);
font-weight: 600;
white-space: nowrap;
cursor: pointer;
transition: background 0.2s ease;
}
#ss-widget-form input[type="submit"]:hover {
background: var(--card-nested);
}
#ss-widget-status {
@ -158,7 +179,7 @@
}
</style>
<a href="javascript:void(0);" id="ss-widget-launcher" title="جست‌وجوی معنایی — پیدا کردن شعر با توصیف معنای آن" onclick="ssWidgetOpen()">
<a href="javascript:void(0);" id="ss-widget-launcher" title="جستجوی معنایی — پیدا کردن شعر با توصیف معنای آن" onclick="ssWidgetOpen()">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--gold, currentColor)">
<path d="M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z" />
</svg>
@ -168,7 +189,7 @@
<div id="ss-widget-panel" style="display:none;">
<div id="ss-widget-header">
<span>جست‌وجوی معنایی</span>
<span>جستجوی معنایی</span>
<div class="ss-widget-actions">
<a href="javascript:void(0);" id="ss-widget-maximize-btn" onclick="ssWidgetToggleMaximize()" title="بزرگ‌نمایی">⤢</a>
<a href="javascript:void(0);" onclick="ssWidgetClose()" title="بستن">×</a>
@ -176,7 +197,7 @@
</div>
<form id="ss-widget-form" onsubmit="return ssWidgetSubmit(event);">
<input type="text" id="ss-widget-query" placeholder="مثلاً: شعری در مورد بی‌وفایی دنیا" autocomplete="off" />
<input type="submit" value="جست‌وجو" />
<input type="submit" value="جستجو" />
</form>
<div id="ss-widget-status"></div>
<div id="ss-widget-results"></div>
@ -231,7 +252,7 @@
var statusEl = document.getElementById("ss-widget-status");
resultsEl.innerHTML = "";
statusEl.style.display = "block";
statusEl.textContent = "در حال جست‌وجو...";
statusEl.textContent = "در حال جستجو...";
$.ajax({
type: "POST",
@ -245,7 +266,7 @@
error: function (xhr) {
statusEl.style.display = "block";
if (xhr.status === 503) {
statusEl.textContent = "در حال حاضر جست‌وجوی معنایی در دسترس نیست. لطفاً کمی بعد دوباره امتحان کنید.";
statusEl.textContent = "در حال حاضر جستجوی معنایی در دسترس نیست. لطفاً کمی بعد دوباره امتحان کنید.";
} else if (xhr.responseText) {
statusEl.textContent = "خطا: " + xhr.responseText;
} else {

View File

@ -24564,17 +24564,29 @@
pool: each process gets its own instance of this (and everything it loads) — "singleton"
only means one instance per process, not per server. See the migration notes for the
memory math this implies at scale.
SemanticSearch:Enabled gates ALL of the above, checked before anything else runs — this
is what actually keeps a disabled instance (e.g. api.ganjoor.net, where third-party apps
shouldn't get this feature) from ever loading the ~530MB embeddings file or the ONNX model
into memory at all, not just from serving requests. Defaults to disabled (fail-closed) if
the key is missing entirely — deliberately, since the whole point of this flag is
preventing resource loading on instances that shouldn't have it; an instance that's
SUPPOSED to have it (ganjgah.ir) needs the key explicitly set to "True", not left implicit.
</summary>
</member>
<member name="M:RMuseum.Utils.SemanticSearch.LazySemanticSearchResources.TryGetResources(RMuseum.Utils.SemanticSearch.EmbeddingIndex@,RMuseum.Utils.SemanticSearch.QueryEmbedder@,System.String@)">
<summary>
Attempts to load the resources on first call (subsequent calls reuse the same result,
success or failure — this never retries automatically; a fresh app start is required
to try again after a config/file fix, which is the expected deploy-and-restart flow
anyway). Returns true and populates both out parameters if available; returns false
and populates <paramref name="error"/> otherwise. NEVER THROWS — that guarantee is the
entire point of this class.
</summary>
<summary>
Attempts to load the resources on first call (subsequent calls reuse the same result,
success or failure — this never retries automatically; a fresh app start is required
to try again after a config/file fix, which is the expected deploy-and-restart flow
anyway). Returns true and populates both out parameters if available; returns false
and populates <paramref name="error"/> otherwise. NEVER THROWS — that guarantee is the
entire point of this class.
If SemanticSearch:Enabled isn't "True", this returns false immediately, every call,
without ever touching EmbeddingIndex.Load/QueryEmbedder's constructor — the actual
mechanism that keeps a disabled instance from loading anything into memory at all.
</summary>
</member>
<member name="T:RMuseum.Utils.SemanticSearch.SemanticSearchUnavailableException">
<summary>