Skip to content

Commit

Permalink
Fixed docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
souradipp76 committed Nov 24, 2024
1 parent 9743a4f commit 020df2e
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 118 deletions.
34 changes: 17 additions & 17 deletions readme_ready/index/create_vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ def create_vector_store(
"""
Creates a vector store from Markdown documents.
Loads documents from the specified root directory, splits the text into chunks,
creates a vector store using the selected LLM model, and saves the vector store
to the output path. Ignores files matching the patterns provided in the ignore list.
Args:
root: The root directory containing the documents to be processed.
output: The directory where the vector store will be saved.
ignore: A list of file patterns to ignore during document loading.
llms: A list of LLMModels to use for generating embeddings.
device: The device to use for embedding generation (e.g., 'cpu' or 'cuda').
Returns:
None.
Raises:
IOError: If an error occurs accessing the filesystem.
Exception: If an error occurs during document loading, splitting, or vector store creation.
Loads documents from the specified root directory, splits the text into chunks,
creates a vector store using the selected LLM model, and saves the vector store
to the output path. Ignores files matching the patterns provided in the ignore list.
Args:
root: The root directory containing the documents to be processed.
output: The directory where the vector store will be saved.
ignore: A list of file patterns to ignore during document loading.
llms: A list of LLMModels to use for generating embeddings.
device: The device to use for embedding generation (e.g., 'cpu' or 'cuda').
Returns:
None.
Raises:
IOError: If an error occurs accessing the filesystem.
Exception: If an error occurs during document loading, splitting, or vector store creation.
"""

llm = llms[1] if len(llms) > 1 else llms[0]
Expand Down
5 changes: 1 addition & 4 deletions readme_ready/index/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .process_repository import process_repository


def index(config: AutodocRepoConfig):
def index(config: AutodocRepoConfig) -> None:
"""
Indexes a repository to generate documentation and vector store files.
Expand All @@ -26,9 +26,6 @@ def index(config: AutodocRepoConfig):
Returns:
None.
Raises:
OSError: If an error occurs while creating directories.
Exception: If an error occurs during repository processing, Markdown conversion, or vector store creation.
"""
json_path = Path(config.output) / "docs" / "json"
markdown_path = Path(config.output) / "docs" / "markdown"
Expand Down
42 changes: 21 additions & 21 deletions readme_ready/index/process_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@
from .select_model import select_model


def process_repository(config: AutodocRepoConfig, dry_run=False):
"""
Creates a vector store from Markdown documents.
Loads documents from the specified root directory, splits the text into chunks,
creates a vector store using the selected LLM model, and saves the vector store
to the output path. Ignores files matching the patterns provided in the ignore list.
Args:
root: The root directory containing the documents to be processed.
output: The directory where the vector store will be saved.
ignore: A list of file patterns to ignore during document loading.
llms: A list of LLMModels to use for generating embeddings.
device: The device to use for embedding generation (e.g., 'cpu' or 'cuda').
Returns:
None.
Raises:
IOError: If an error occurs accessing the filesystem.
Exception: If an error occurs during document loading, splitting, or vector store creation.
def process_repository(config: AutodocRepoConfig, dry_run=False) -> None:
"""
Creates a vector store from Markdown documents.
Loads documents from the specified root directory, splits the text into chunks,
creates a vector store using the selected LLM model, and saves the vector store
to the output path. Ignores files matching the patterns provided in the ignore list.
Args:
root: The root directory containing the documents to be processed.
output: The directory where the vector store will be saved.
ignore: A list of file patterns to ignore during document loading.
llms: A list of LLMModels to use for generating embeddings.
device: The device to use for embedding generation (e.g., 'cpu' or 'cuda').
Returns:
None.
Raises:
IOError: If an error occurs accessing the filesystem.
Exception: If an error occurs during document loading, splitting, or vector store creation.
"""


Expand Down
90 changes: 45 additions & 45 deletions readme_ready/query/create_chat_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,28 @@ def make_qa_chain(
"""
Creates a question-answering (QA) chain for the specified project.
Initializes and configures the QA chain using the provided repository and user configurations.
Selects the appropriate language model (LLM), sets up the retriever with a history-aware mechanism,
and combines document chains for processing queries. The chain facilitates interaction with the
vector store to retrieve and process relevant information based on user queries.
Args:
project_name: The name of the project for which the QA chain is being created.
repository_url: The URL of the repository containing the project.
content_type: The type of content to be processed (e.g., 'code', 'documentation').
chat_prompt: The prompt template used for generating chat responses.
target_audience: The intended audience for the QA responses.
vectorstore: An instance of HNSWLib representing the vector store containing document embeddings.
llms: A list of LLMModels to select from for generating embeddings and responses.
device: The device to use for model inference (default is 'cpu').
on_token_stream: Optional callback for handling token streams during model inference.
Returns:
A retrieval chain configured for question-answering, combining the retriever and document processing chain.
Raises:
ValueError: If no suitable model is found in the provided LLMs.
RuntimeError: If there is an issue initializing the chat models or creating the chains.
Initializes and configures the QA chain using the provided repository and user configurations.
Selects the appropriate language model (LLM), sets up the retriever with a history-aware mechanism,
and combines document chains for processing queries. The chain facilitates interaction with the
vector store to retrieve and process relevant information based on user queries.
Args:
project_name: The name of the project for which the QA chain is being created.
repository_url: The URL of the repository containing the project.
content_type: The type of content to be processed (e.g., 'code', 'documentation').
chat_prompt: The prompt template used for generating chat responses.
target_audience: The intended audience for the QA responses.
vectorstore: An instance of HNSWLib representing the vector store containing document embeddings.
llms: A list of LLMModels to select from for generating embeddings and responses.
device: The device to use for model inference (default is 'cpu').
on_token_stream: Optional callback for handling token streams during model inference.
Returns:
A retrieval chain configured for question-answering, combining the retriever and document processing chain.
Raises:
ValueError: If no suitable model is found in the provided LLMs.
RuntimeError: If there is an issue initializing the chat models or creating the chains.
"""
llm = llms[1] if len(llms) > 1 else llms[0]
llm_name = llm.value
Expand Down Expand Up @@ -268,29 +268,29 @@ def make_readme_chain(
"""
Creates a README generation chain for the specified project.
Initializes and configures the README generation chain using the provided repository, user, and README configurations.
Selects the appropriate language model (LLM), sets up the document processing chain with the specified prompts,
and integrates with the vector store to generate comprehensive README sections based on project data.
The chain facilitates automated generation of README files tailored to the project's specifications.
Args:
project_name: The name of the project for which the README is being generated.
repository_url: The URL of the repository containing the project.
content_type: The type of content to be included in the README (e.g., 'overview', 'installation').
chat_prompt: The prompt template used for generating README content.
target_audience: The intended audience for the README.
vectorstore: An instance of HNSWLib representing the vector store containing document embeddings.
llms: A list of LLMModels to select from for generating README content.
peft_model: An optional parameter specifying a PEFT (Parameter-Efficient Fine-Tuning) model for enhanced performance.
device: The device to use for model inference (default is 'cpu').
on_token_stream: Optional callback for handling token streams during model inference.
Returns:
A retrieval chain configured for README generation, combining the retriever and document processing chain.
Raises:
ValueError: If no suitable model is found in the provided LLMs.
RuntimeError: If there is an issue initializing the chat models or creating the chains.
Initializes and configures the README generation chain using the provided repository, user, and README configurations.
Selects the appropriate language model (LLM), sets up the document processing chain with the specified prompts,
and integrates with the vector store to generate comprehensive README sections based on project data.
The chain facilitates automated generation of README files tailored to the project's specifications.
Args:
project_name: The name of the project for which the README is being generated.
repository_url: The URL of the repository containing the project.
content_type: The type of content to be included in the README (e.g., 'overview', 'installation').
chat_prompt: The prompt template used for generating README content.
target_audience: The intended audience for the README.
vectorstore: An instance of HNSWLib representing the vector store containing document embeddings.
llms: A list of LLMModels to select from for generating README content.
peft_model: An optional parameter specifying a PEFT (Parameter-Efficient Fine-Tuning) model for enhanced performance.
device: The device to use for model inference (default is 'cpu').
on_token_stream: Optional callback for handling token streams during model inference.
Returns:
A retrieval chain configured for README generation, combining the retriever and document processing chain.
Raises:
ValueError: If no suitable model is found in the provided LLMs.
RuntimeError: If there is an issue initializing the chat models or creating the chains.
"""
llm = llms[1] if len(llms) > 1 else llms[0]
llm_name = llm.value
Expand Down
62 changes: 31 additions & 31 deletions readme_ready/query/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ def query(repo_config: AutodocRepoConfig, user_confg: AutodocUserConfig):
"""
Queries the repository for information based on user input.
Initializes a question-answering chain, displays a welcome message, and enters a loop to
prompt the user for questions about the repository. Processes each question by invoking
the QA chain, updates the chat history, and displays the response in Markdown format. The
loop continues until the user types 'exit'.
Args:
repo_config: An AutodocRepoConfig instance containing configuration settings for the repository.
user_confg: An AutodocUserConfig instance containing user-specific configuration settings.
Returns:
None.
Raises:
Exception: If an error occurs during the initialization of the QA chain, displaying the welcome message,
or during the invocation of the QA chain.
Initializes a question-answering chain, displays a welcome message, and enters a loop to
prompt the user for questions about the repository. Processes each question by invoking
the QA chain, updates the chat history, and displays the response in Markdown format. The
loop continues until the user types 'exit'.
Args:
repo_config: An AutodocRepoConfig instance containing configuration settings for the repository.
user_confg: An AutodocUserConfig instance containing user-specific configuration settings.
Returns:
None.
Raises:
Exception: If an error occurs during the initialization of the QA chain, displaying the welcome message,
or during the invocation of the QA chain.
"""
chain = init_qa_chain(repo_config, user_confg)

Expand Down Expand Up @@ -127,22 +127,22 @@ def generate_readme(
"""
Generates a README file based on repository and user configurations.
Initializes a README generation chain, clears the terminal, and prepares the output file.
Iterates over the specified headings in the README configuration, generates content for each
section by invoking the chain, and writes the content in Markdown format to the README file.
Handles any RuntimeError that occurs during the process.
Args:
repo_config: An AutodocRepoConfig instance containing configuration settings for the repository.
user_config: An AutodocUserConfig instance containing user-specific configuration settings.
readme_config: An AutodocReadmeConfig instance containing configuration settings for README generation.
Returns:
None.
Raises:
IOError: If an error occurs while accessing or writing to the filesystem.
Exception: If an error occurs during the initialization of the README chain or content generation.
Initializes a README generation chain, clears the terminal, and prepares the output file.
Iterates over the specified headings in the README configuration, generates content for each
section by invoking the chain, and writes the content in Markdown format to the README file.
Handles any RuntimeError that occurs during the process.
Args:
repo_config: An AutodocRepoConfig instance containing configuration settings for the repository.
user_config: An AutodocUserConfig instance containing user-specific configuration settings.
readme_config: An AutodocReadmeConfig instance containing configuration settings for README generation.
Returns:
None.
Raises:
IOError: If an error occurs while accessing or writing to the filesystem.
Exception: If an error occurs during the initialization of the README chain or content generation.
"""
chain = init_readme_chain(repo_config, user_config)

Expand Down

0 comments on commit 020df2e

Please sign in to comment.