Hello @Logan M , I tried the guideline you shared, I got the
raise ValueError("Reference doc id is None.")
any idea of this, here's my code, the
codeSnippet.source
it's the code snippet that I spilt myself.
def indexCodeSnippets(self, codeSnippets: List[CodeSnippet]):
nextDocId = 1
previousNode: Node = None
nodes: List[Node] = []
for codeSnippet in codeSnippets:
node = Node(text=codeSnippet.source, doc_id=str(nextDocId))
nodes.append(node)
if previousNode is not None:
previousNode.relationships[DocumentRelationship.NEXT] = node.get_doc_id()
node.relationships[DocumentRelationship.PREVIOUS] = previousNode.get_doc_id()
previousNode = node
nextDocId += 1
# define LLM
llm_predictor = LLMPredictor(llm=OpenAI(temperature=0, model_name="text-davinci-003"))
# define prompt helper
# set maximum input size
max_input_size = 4096
# set number of output tokens
num_output = 10000
# set maximum chunk overlap
max_chunk_overlap = 20
prompt_helper = PromptHelper(max_input_size, num_output, max_chunk_overlap)
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor,
prompt_helper=prompt_helper)
self.__gptSimpleVectorIndex = GPTSimpleVectorIndex(nodes=nodes, service_context=service_context)