@Emanuel Ferreira this way?
from llama_index import (
SimpleDirectoryReader,
GPTVectorStoreIndex,
ServiceContext,
PromptHelper,
)
from langchain.chat_models import ChatOpenAI as openai
def construct_index(directory_path):
max_input_size = 4096
num_outputs = 512 # było 500
max_chunk_overlap = 1
chunk_size_limit = 600
prompt_helper = PromptHelper(
max_input_size,
num_outputs,
max_chunk_overlap,
chunk_size_limit=chunk_size_limit,
)
# define LLM
llm = openai(temperature=0.1, model="gpt-4")
service_context = ServiceContext.from_defaults(llm=llm)
# print model_name:
documents = SimpleDirectoryReader(directory_path, num_files_limit=1).load_data()
index = GPTVectorStoreIndex.from_documents(
documents, service_context=service_context, prompt_helper=prompt_helper
)
index.storage_context.persist("index.json")
return index
edit:
ok, it does use GPT4 - thanks for that!