@Logan M after a deep dive into the codebase, I figured out how to do this!
from llama_index import Document, GPTSimpleVectorIndex, ServiceContext, LLMPredictor
from langchain.chat_models import ChatOpenAI
from llama_index.embeddings import openai
txt1 = "foo"
txt2 = "bar"
# generate embeddings async
embedder = openai.OpenAIEmbedding()
embdResult = await embedder.aget_queued_text_embeddings([("txt1", txt1), ("txt2", txt2)])
# create empty index
llm_predictor = LLMPredictor(llm=ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0.7))
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor)
index = GPTSimpleVectorIndex.from_documents(documents=[], service_context=service_context)
# add docs as needed (note that they already have embeddings attached to them)
docs = [
Document(text=txt1, doc_id="txt1", embedding=embdResult[0]),
Document(text=txt2, doc_id="txt2", embedding=embdResult[1]),
]
for d in docs:
index.insert(d)