Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
Set service context for llama index in `local.py` (#462)
Sarah Woodersf781d4426aa2
diff --git a/memgpt/cli/cli_load.py b/memgpt/cli/cli_load.pyindex 5a05d2577..2bdbc7e45 100644--- a/memgpt/cli/cli_load.py+++ b/memgpt/cli/cli_load.py@@ -27,6 +27,7 @@ app = typer.Typer()def store_docs(name, docs, show_progress=True):"""Common function for embedding and storing documents"""+storage = StorageConnector.get_storage_connector(name=name)config = MemGPTConfig.load()embed_model = embedding_model()diff --git a/memgpt/connectors/local.py b/memgpt/connectors/local.pyindex 72fd6c5b4..5178a9443 100644--- a/memgpt/connectors/local.py+++ b/memgpt/connectors/local.py@@ -8,11 +8,7 @@ import osfrom typing import List, Optional-from llama_index import (- VectorStoreIndex,- EmptyIndex,- ServiceContext,-)+from llama_index import VectorStoreIndex, EmptyIndex, ServiceContext, set_global_service_contextfrom llama_index.retrievers import VectorIndexRetrieverfrom llama_index.schema import TextNode@@ -42,6 +38,7 @@ class LocalStorageConnector(StorageConnector):# llama index contextsself.embed_model = embedding_model()self.service_context = ServiceContext.from_defaults(llm=None, embed_model=self.embed_model, chunk_size=config.embedding_chunk_size)+ set_global_service_context(self.service_context)# load/create indexself.save_path = f"{self.save_directory}/nodes.pkl"