File size: 613 Bytes
a26db82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from core.lifecycle import Lifecycle
from llama.context import ServiceContextManager
from llama_index.indices.vector_store import VectorStoreIndex
from typing import Optional


class IndexManager(Lifecycle):
    index: Optional[VectorStoreIndex]

    def __init__(self, context_manager: ServiceContextManager) -> None:
        super().__init__()
        self.index = None
        self.context_manager = context_manager

    def get_index(self) -> Optional[VectorStoreIndex]:
        if not self.lifecycle_state.is_started():
            raise Exception("Lifecycle state is not correct")
        return self.index