I'm testing a couple of the widely published GPT models just trying to get my feet wet and I am running into an error that I cannot solve.
I am running this code:
from llama_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
from langchain import OpenAI
import gradio as gr
import sys
import os
os.environ["OPENAI_API_KEY"] = 'MYKEY'
def construct_index(directory_path):
max_input_size = 4096
num_outputs = 512
max_chunk_overlap = 20
chunk_size_limit = 600
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
llm_predictor_gpt = LLMPredictor(llm=OpenAI(temperature=0.7, model_name="text-davinci-003", max_tokens=num_outputs))
documents = SimpleDirectoryReader(directory_path).load_data()
index = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor_gpt, prompt_helper=prompt_helper)
index.save_to_disk('index.json')
return index
def chatbot(input_text):
index = GPTSimpleVectorIndex.load_from_disk('index.json')
response = index.query(input_text, response_mode="compact")
return response.response
iface = gr.Interface(fn=chatbot,
inputs=gr.inputs.Textbox(lines=7, label="Enter your text"),
outputs="text",
title="Custom-trained AI Chatbot")
index = construct_index("salesdocs")
iface.launch(share=False)
And I keep getting this error
File "C:\Users\Anonymous\anaconda3\lib\site-packages\llama_index\indices\vector_store\base.py", line 58, in __init__
super().__init__(
TypeError: __init__() got an unexpected keyword argument 'llm_predictor'
Having a hard time finding much documentation on llamma index errors, hoping someone can point me in the right direction.
llm_predictor
keyword argument toGPTSimpleVectorIndex
? – Inksterllm_predictor=llm_predictor_gpt,
. – Inkster