@@ -21,23 +21,29 @@ export class ExpertManager {
21
21
private workspaceId : string
22
22
private fileManager : ExpertFileManager
23
23
private documentProcessor : DocumentProcessor
24
- private vectorStoreManager : VectorStoreManager
24
+ private vectorStoreManager ? : VectorStoreManager
25
25
26
26
/**
27
27
* Create a new ExpertManager
28
28
*/
29
- constructor ( extensionContext : vscode . ExtensionContext , workspaceId : string , embeddingConfig : EmbeddingConfiguration ) {
29
+ constructor ( extensionContext : vscode . ExtensionContext , workspaceId : string ) {
30
30
this . extensionContext = extensionContext
31
31
this . workspaceId = workspaceId
32
32
this . fileManager = new ExpertFileManager ( )
33
33
this . documentProcessor = new DocumentProcessor ( extensionContext , workspaceId )
34
34
35
- // Initialize embedding client and vector store manager
35
+ // No embedding initialization here
36
+ }
37
+
38
+ /**
39
+ * Initialize embedding client and vector store manager
40
+ */
41
+ public initializeEmbeddings ( embeddingConfig : EmbeddingConfiguration ) : void {
36
42
const embeddings = VectorStoreManager . initializeEmbeddings ( embeddingConfig )
37
43
this . vectorStoreManager = new VectorStoreManager ( {
38
44
embeddings,
39
45
embeddingConfig,
40
- workspaceId,
46
+ workspaceId : this . workspaceId ,
41
47
} )
42
48
43
49
this . connectProcessorToVectorStore ( )
@@ -134,6 +140,9 @@ export class ExpertManager {
134
140
suburl : string ,
135
141
title ?: string ,
136
142
) : Promise < void > => {
143
+ if ( ! this . vectorStoreManager ) {
144
+ throw new Error ( "Vector store manager not initialized. Please initialize embeddings first." )
145
+ }
137
146
await this . vectorStoreManager . chunkAndStore ( {
138
147
markdown,
139
148
expertName,
@@ -165,6 +174,9 @@ export class ExpertManager {
165
174
166
175
if ( isDeepCrawl ) {
167
176
// For deepcrawl experts, delete chunks and re-crawl
177
+ if ( ! this . vectorStoreManager ) {
178
+ throw new Error ( "Vector store manager not initialized. Please initialize embeddings first." )
179
+ }
168
180
await this . vectorStoreManager . deleteChunk ( linkUrl , expertName , workspacePath )
169
181
await this . documentProcessor . crawlAndConvertToMarkdown (
170
182
linkUrl ,
@@ -321,7 +333,9 @@ export class ExpertManager {
321
333
const isDeepCrawl = metadata . deepCrawl || false
322
334
323
335
// Delete from vector DB regardless (since the URL might have been crawled before)
324
- await this . vectorStoreManager . deleteChunk ( linkUrl , expertName , workspacePath )
336
+ if ( this . vectorStoreManager ) {
337
+ await this . vectorStoreManager . deleteChunk ( linkUrl , expertName , workspacePath )
338
+ }
325
339
326
340
// Update regular status.json if it exists
327
341
if ( await this . fileManager . readStatusFile ( statusFilePath ) ) {
@@ -783,6 +797,9 @@ export class ExpertManager {
783
797
* Search for a query in the expert's vector store
784
798
*/
785
799
async search ( query : string , expertName : string , workspacePath : string , k ?: number ) : Promise < string > {
800
+ if ( ! this . vectorStoreManager ) {
801
+ throw new Error ( "Vector store manager not initialized. Please initialize embeddings first." )
802
+ }
786
803
return this . vectorStoreManager . search ( query , expertName , workspacePath , k )
787
804
}
788
805
}
0 commit comments