@WhiteFang_Jr sure. This is just a slightly modified version of the first section from
https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/OpensearchDemo.html where I'm trying to slot in the sentence-transformers:
#!/usr/bin/env python3
from os import getenv
from llama_index import SimpleDirectoryReader
from llama_index.vector_stores import OpensearchVectorStore, OpensearchVectorClient
from llama_index import VectorStoreIndex, StorageContext
from langchain.embeddings import HuggingFaceEmbeddings
from llama_index import ServiceContext, set_global_service_context
from llama_index import Document
from llama_index.vector_stores.types import MetadataFilters, ExactMatchFilter
###Setup the embedding model
embed_model = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-mpnet-base-v2"
)
service_context = ServiceContext.from_defaults(embed_model=embed_model)
set_global_service_context(service_context)
endpoint = getenv("OPENSEARCH_ENDPOINT", "http://localhost:9200")
# index to demonstrate the VectorStore impl
idx = getenv("OPENSEARCH_INDEX", "gpt-index-demo")
# load some sample data
documents = SimpleDirectoryReader("../paul_graham_essay/data").load_data()
text_field = "content"
embedding_field = "embedding"
client = OpensearchVectorClient(
endpoint, idx, 1536, embedding_field=embedding_field, text_field=text_field
)
vector_store = OpensearchVectorStore(client)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
documents=documents,
storage_context=storage_context,
service_context=service_context
)
I've confirmed that this works if I set the OpenAI api key, but if I omit it, it fires the llamacpp error. I'm only trying to index at this point so I don't think there should be any querying going on. This is a fresh installation of llamaindex from github. What am I doing wrong?