llamaindex_class.py
Source: sunholo/llamaindex/llamaindex_class.py
Functions
setup_llamaindex_subparser(subparsers)
Sets up an argparse subparser for the 'llamaindex' command.
Args: subparsers: The subparsers object from argparse.ArgumentParser().
llamaindex_command(args)
No docstring available.
Classes
LlamaIndexVertexCorpusManager
A manager class for handling RAG corpora operations with Vertex AI.
Attributes: config (ConfigManager): Configuration manager for fetching project settings. project_id (str): GCP project ID. location (str): GCP location.
- init(self, config: sunholo.utils.config_class.ConfigManager = None, project_id: str = None, location: str = None)
- Initializes the LlamaIndexVertexCorpusManager.
Args: config (ConfigManager): Configuration manager for fetching project settings. project_id (str): GCP project ID. location (str): GCP location.
Raises: ImportError: If vertexai is not installed.
- create_corpus(self, display_name: str, description: str = None)
- Creates a new corpus or returns an existing one with the specified display name.
Args: display_name (str): The display name of the corpus. description (str, optional): Description of the corpus.
Returns: The created or found corpus object.
- delete_corpus(self, display_name: str)
- Deletes a corpus by its display name.
Args: display_name (str): The display name of the corpus.
Returns: bool: True if the corpus was deleted, False otherwise.
-
delete_file(self, file_name, corpus_display_name: str)
- No docstring available.
-
fetch_corpus(self, display_name: str)
- Fetches a corpus by its display name.
Args: display_name (str): The display name of the corpus.
Returns: The fetched corpus object.
Raises: ValueError: If the corpus with the specified display name does not exist.
- find_corpus_from_list(self, display_name: str)
- Finds a corpus from the list of corpora by its display name.
Args: display_name (str): The display name of the corpus.
Returns: The found corpus object if it exists, otherwise None.
- find_file_from_list(self, display_name: str, corpus_display_name: str)
- Finds a file from the list of files by its display name.
Args: display_name (str): The display name of the file. corpus_display_name (str): The display name of the corpus to look within
Returns: The found file object if it exists, otherwise None.
-
get_file(self, file_display_name: str = None, file_name: str = None, corpus_display_name: str = None)
- No docstring available.
-
import_files(self, file_imports: list[str], corpus_display_name: str)
- No docstring available.
-
list_corpora(self)
- List all VertexAI Corpus for the project/location
-
list_files(self, corpus_display_name: str)
- No docstring available.
-
query_corpus(self, query: str, corpus_disply_name: str)
- No docstring available.
-
upload_file(self, filename: str, corpus_display_name: str, description: str = None)
- No docstring available.
-
upload_text(self, text: str, corpus_display_name: str, description: str = None)
- Uploads a text string to a specified corpus by saving it to a temporary file first.
Args: text (str): The text content to upload. corpus_display_name (str): The display name of the corpus. description (str, optional): Description of the text upload.
Returns: The uploaded file object.