@hasna/knowledge 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/service.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  import { createArtifactStore } from './artifact-store';
2
+ import {
3
+ embeddingIndexStatus,
4
+ indexKnowledgeEmbeddings,
5
+ searchVectorIndex,
6
+ type EmbeddingIndexOptions,
7
+ type EmbeddingSearchOptions,
8
+ } from './embeddings';
2
9
  import { consumeOpenFilesOutbox } from './outbox-consume';
3
10
  import { getKnowledgeDbStats, migrateKnowledgeDb, openKnowledgeDb } from './knowledge-db';
4
11
  import { ingestOpenFilesManifest } from './manifest-ingest';
@@ -184,6 +191,29 @@ export class KnowledgeService {
184
191
  modelRegistry(): ModelRegistryEntry[] {
185
192
  return listModelRegistry(this.config());
186
193
  }
194
+
195
+ embeddingStatus() {
196
+ const workspace = this.ensureWorkspace();
197
+ return embeddingIndexStatus(workspace.knowledgeDbPath);
198
+ }
199
+
200
+ async indexEmbeddings(options: Omit<EmbeddingIndexOptions, 'dbPath' | 'config'> = {}) {
201
+ const workspace = this.ensureWorkspace();
202
+ return indexKnowledgeEmbeddings({
203
+ ...options,
204
+ dbPath: workspace.knowledgeDbPath,
205
+ config: this.config(),
206
+ });
207
+ }
208
+
209
+ async semanticSearch(options: Omit<EmbeddingSearchOptions, 'dbPath' | 'config'>) {
210
+ const workspace = this.ensureWorkspace();
211
+ return searchVectorIndex({
212
+ ...options,
213
+ dbPath: workspace.knowledgeDbPath,
214
+ config: this.config(),
215
+ });
216
+ }
187
217
  }
188
218
 
189
219
  export function createKnowledgeService(options: KnowledgeServiceOptions = {}): KnowledgeService {
package/src/workspace.ts CHANGED
@@ -39,6 +39,12 @@ export interface KnowledgeConfig {
39
39
  preferred_ref: 'open-files';
40
40
  allowed_schemes: string[];
41
41
  };
42
+ embeddings?: {
43
+ default_model?: string;
44
+ dimensions?: number;
45
+ batch_size?: number;
46
+ max_parallel_calls?: number;
47
+ };
42
48
  providers?: {
43
49
  default_model?: string;
44
50
  aliases?: Record<string, string>;
@@ -136,6 +142,12 @@ export function defaultKnowledgeConfig(): KnowledgeConfig {
136
142
  default_model: 'deepseek-chat',
137
143
  },
138
144
  },
145
+ embeddings: {
146
+ default_model: 'openai:text-embedding-3-small',
147
+ dimensions: 1536,
148
+ batch_size: 64,
149
+ max_parallel_calls: 4,
150
+ },
139
151
  safety: {
140
152
  network: {
141
153
  web_search_enabled: false,