@@ -21,23 +21,29 @@ export class ExpertManager {
2121 private workspaceId : string
2222 private fileManager : ExpertFileManager
2323 private documentProcessor : DocumentProcessor
24- private vectorStoreManager : VectorStoreManager
24+ private vectorStoreManager ? : VectorStoreManager
2525
2626 /**
2727 * Create a new ExpertManager
2828 */
29- constructor ( extensionContext : vscode . ExtensionContext , workspaceId : string , embeddingConfig : EmbeddingConfiguration ) {
29+ constructor ( extensionContext : vscode . ExtensionContext , workspaceId : string ) {
3030 this . extensionContext = extensionContext
3131 this . workspaceId = workspaceId
3232 this . fileManager = new ExpertFileManager ( )
3333 this . documentProcessor = new DocumentProcessor ( extensionContext , workspaceId )
3434
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 {
3642 const embeddings = VectorStoreManager . initializeEmbeddings ( embeddingConfig )
3743 this . vectorStoreManager = new VectorStoreManager ( {
3844 embeddings,
3945 embeddingConfig,
40- workspaceId,
46+ workspaceId : this . workspaceId ,
4147 } )
4248
4349 this . connectProcessorToVectorStore ( )
@@ -134,6 +140,9 @@ export class ExpertManager {
134140 suburl : string ,
135141 title ?: string ,
136142 ) : Promise < void > => {
143+ if ( ! this . vectorStoreManager ) {
144+ throw new Error ( "Vector store manager not initialized. Please initialize embeddings first." )
145+ }
137146 await this . vectorStoreManager . chunkAndStore ( {
138147 markdown,
139148 expertName,
@@ -165,6 +174,9 @@ export class ExpertManager {
165174
166175 if ( isDeepCrawl ) {
167176 // 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+ }
168180 await this . vectorStoreManager . deleteChunk ( linkUrl , expertName , workspacePath )
169181 await this . documentProcessor . crawlAndConvertToMarkdown (
170182 linkUrl ,
@@ -321,7 +333,9 @@ export class ExpertManager {
321333 const isDeepCrawl = metadata . deepCrawl || false
322334
323335 // 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+ }
325339
326340 // Update regular status.json if it exists
327341 if ( await this . fileManager . readStatusFile ( statusFilePath ) ) {
@@ -783,6 +797,9 @@ export class ExpertManager {
783797 * Search for a query in the expert's vector store
784798 */
785799 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+ }
786803 return this . vectorStoreManager . search ( query , expertName , workspacePath , k )
787804 }
788805}
0 commit comments