Skip to content

armgit / letta

Public Imported from GitHub
0

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.py
index 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.py
index 72fd6c5b4..5178a9443 100644
--- a/memgpt/connectors/local.py
+++ b/memgpt/connectors/local.py
@@ -8,11 +8,7 @@ import os
from typing import List, Optional
-from llama_index import (
- VectorStoreIndex,
- EmptyIndex,
- ServiceContext,
-)
+from llama_index import VectorStoreIndex, EmptyIndex, ServiceContext, set_global_service_context
from llama_index.retrievers import VectorIndexRetriever
from llama_index.schema import TextNode
@@ -42,6 +38,7 @@ class LocalStorageConnector(StorageConnector):
# llama index contexts
self.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 index
self.save_path = f"{self.save_directory}/nodes.pkl"