IndexPrompt
IndexPrompt
is the class for retrieving from an index and concat the retrieved context information with the query input, to get the result from LLM. The class is implemented based onllama_index
.
NOTE: the class only supports
SimpleVectorIndex
andKGIndex
right now.
Constructor
Parameters
index_name
(str): The type of index you want to build or load, should be in one of ["simple_vector_index", "kg_index" ].index_path
(str): The path to your saved index file, default to be None. If provided, the index will be loaded during initializaion.
Example
build_index
Description
Build a index on your custom data.
Parameters
data_path
(str): The document data path.llm_model_name
(str): Large language model type to predict triplets from raw text. If not provided, will use the default setting "text-dacinci-002" for prediction.chunk_size_limit
(int): Chunk size limit. Default is 512 (4096 max input size).max_triplets_per_chunk
(int): Triplets number limit. Default is 5.
Returns
List[Document]
: A list of documents.Document
is a class from llama_index.
load_from_disk
Load index from saved path
Parameters
index_path
(str): The path to your saved index.
save_to_disk
Description
Save index to local path
Parameters
save_path
(str): The path to save your index.
query
Description
Query for ChatGPT/GPT3. Retrieve from built index, and concat the retrieved knowledge with the input prompt.
Parameters
prompt
(str): your input question.
Returns
dict
: A response dict from LLM.
Examples
Last updated