Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Semantic search using AI embeddings https://github.com/siyuan-note/siyuan/issues/17788

Danield3a010701634
diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.ts
index f7c295c09a..800a98bb04 100644
--- a/app/src/mobile/menu/search.ts
+++ b/app/src/mobile/menu/search.ts
@@ -289,7 +289,8 @@ export const updateSearchResult = (config: Config.IUILayoutTabSearchConfig, elem
} else {
previousElement.setAttribute("disabled", "disabled");
}
- fetchPost("/api/search/fullTextSearchBlock", {
+ const endpoint = config.method === 4 ? "/api/search/semanticSearchBlock" : "/api/search/fullTextSearchBlock";
+ fetchPost(endpoint, {
query: config.query,
method: config.method,
types: config.types,
diff --git a/app/src/search/menu.ts b/app/src/search/menu.ts
index 09c2e5d5d0..81e54b1565 100644
--- a/app/src/search/menu.ts
+++ b/app/src/search/menu.ts
@@ -552,47 +552,60 @@ export const moreMenu = async (config: Config.IUILayoutTabSearchConfig,
replaceFilterMenu(config);
}
}).element);
- window.siyuan.menus.menu.append(new MenuItem({
- iconHTML: "",
- label: window.siyuan.languages.searchMethod,
- type: "submenu",
- submenu: [{
- icon: "iconExact",
- label: window.siyuan.languages.keyword,
- current: config.method === 0,
- click() {
- config.method = 0;
- config.page = 1;
- updateSearchResult(config, element, true);
- }
- }, {
- icon: "iconQuote",
- label: window.siyuan.languages.querySyntax,
- current: config.method === 1,
- click() {
- config.method = 1;
- config.page = 1;
- updateSearchResult(config, element, true);
- }
- }, {
- icon: "iconDatabase",
- label: "SQL",
- current: config.method === 2,
- click() {
- config.method = 2;
- config.page = 1;
- updateSearchResult(config, element, true);
- }
- }, {
- icon: "iconRegex",
- label: window.siyuan.languages.regex,
- current: config.method === 3,
+ const searchMethodSubmenu = [{
+ icon: "iconExact",
+ label: window.siyuan.languages.keyword,
+ current: config.method === 0,
+ click() {
+ config.method = 0;
+ config.page = 1;
+ updateSearchResult(config, element, true);
+ }
+ }, {
+ icon: "iconQuote",
+ label: window.siyuan.languages.querySyntax,
+ current: config.method === 1,
+ click() {
+ config.method = 1;
+ config.page = 1;
+ updateSearchResult(config, element, true);
+ }
+ }, {
+ icon: "iconDatabase",
+ label: "SQL",
+ current: config.method === 2,
+ click() {
+ config.method = 2;
+ config.page = 1;
+ updateSearchResult(config, element, true);
+ }
+ }, {
+ icon: "iconRegex",
+ label: window.siyuan.languages.regex,
+ current: config.method === 3,
+ click() {
+ config.method = 3;
+ config.page = 1;
+ updateSearchResult(config, element, true);
+ }
+ }];
+ if (window.siyuan.config.ai.providers?.find(p => p.type === "embedding")?.apiKey) {
+ searchMethodSubmenu.push({
+ icon: "iconSparkles",
+ label: window.siyuan.languages.semanticSearch,
+ current: config.method === 4,
click() {
- config.method = 3;
+ config.method = 4;
config.page = 1;
updateSearchResult(config, element, true);
}
- }]
+ });
+ }
+ window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: "",
+ label: window.siyuan.languages.searchMethod,
+ type: "submenu",
+ submenu: searchMethodSubmenu
}).element);
/// #endif
const sortMenu = [{