Skip to content

Commit

Permalink
Set service context for llama index in local.py (#462)
Browse files Browse the repository at this point in the history
* mark depricated API section

* add readme

* add readme

* add readme

* add readme

* add readme

* add readme

* add readme

* add readme

* add readme

* CLI bug fixes for azure

* check azure before running

* Update README.md

* Update README.md

* bug fix with persona loading

* remove print

* make errors for cli flags more clear

* format

* fix imports

* fix imports

* add prints

* update lock

* remove asserts

* bump version

* set global context for llama index
  • Loading branch information
sarahwooders authored Nov 15, 2023
1 parent 33fa2de commit 7aa7478
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions memgpt/cli/cli_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

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()
Expand Down
7 changes: 2 additions & 5 deletions memgpt/connectors/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@

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

Expand Down Expand Up @@ -42,6 +38,7 @@ def __init__(self, name: Optional[str] = None, agent_config: Optional[AgentConfi
# 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"
Expand Down

0 comments on commit 7aa7478

Please sign in to comment.