app.utils Package
Utility functions used across the application.
Modules
app.utils.utils
Provides common utility functions: logging setup (setup_logging), Gemini API configuration and validation (configure_genai_api, validate_gemini_api_key), repository path handling (get_local_repo_path, get_remote_repo_url, clone_remote_repo), repository-to-text conversion (convert_repo_to_txt), and file uploading (upload_file_to_gemini, convert_file_to_txt).
- app.utils.utils.setup_logging(log_file: Path, level=20, log_to_console=True)[source]
Configures logging to output to a file and optionally to the console.
- app.utils.utils.validate_gemini_api_key(api_key: str, test_prompt: str = 'Test') tuple[bool, str][source]
Validates the provided Gemini API key by configuring the API and attempting a minimal text generation using the “gemini-2.0-flash-001” model.
- Returns:
(True, “”) if the key is valid, (False, error_message) if invalid.
- app.utils.utils.configure_genai_api(api_key: str)[source]
Configures the Google Gemini API with the provided API key.
- app.utils.utils.get_local_repo_path(repo_path: str) Path[source]
Validates that the local repository path exists and is a directory.
- app.utils.utils.get_remote_repo_url(repo_url: str) str[source]
Validates the remote repository URL format. This function accepts URLs with branch information in the ‘/tree/<branch>’ format.
- app.utils.utils.clone_remote_repo(repo_url: str) Path[source]
Clones the remote repository into a temporary directory. Returns the path to the cloned repository. If the repo_url includes branch information in the ‘/tree/<branch>’ format, the repository is cloned using that branch.
- app.utils.utils.convert_repo_to_txt(repo_path: Path, output_txt_path: Path)[source]
Walks through the repository directory, captures the file tree, file names, and file contents, and writes them to a single .txt file.
app.utils.commit_message
Contains functions related to Git commit messages. Loads prompts from YAML and defines helper functions (generate_general_prompt, extract_result). Provides core functions generate_CM (generates a commit message from code diffs) and improve_CM (improves an existing commit message based on diffs) using an LLM API call (llm_api.gemini_api).
- app.utils.commit_message.generate_general_prompt()[source]
Since there’s prompts of Generation task and Improvement task have a lot in common. This function generate part in common to avoid duplicate
app.utils.creation
Focuses on creating documentation content. Loads prompts from YAML (creation_prompt.yaml). create_part generates specific documentation sections (like description, usage, etc.) using an LLM based on provided info and file tree context. create_feature generates feature descriptions, potentially ensuring uniqueness against existing features. structure_markdown likely reorganizes generated markdown sections into a final document structure.
app.utils.file_tree
Contains generate_file_tree, a function to create a string representation of the repository’s directory structure, controllable by depth and whether to show files.
- app.utils.file_tree.generate_file_tree(root_path: str, max_depth: int = None, show_files: bool = True, prefix: str = '') str[source]
Generate a file tree in string format. This can help LLM to understand the structure of repo, which decrease the potential of lowering LLM’s attention on other important information. This function can be used on ReadME. :param root_path: selected root path of the repo # TODO: Open a window to let user select root path. (Must) :param max_depth: Max depth of the file tree. Control the size of file tree. # TODO: Automatically generate the max depth of file tree. (Should) :param show_files: Only show folders’ name or detailed files’ name. :param prefix: a parameter to bring blank space for sub tree. :return: a file tree in string format.
app.utils.help_popup
Provides a HelpPopup class using Tkinter to display an image (likely a guide or screenshot) in a separate window, useful for GUI help buttons.
app.utils.llm_api
Contains functions for interacting with different LLM APIs. Includes gemini_api for calls to Google Gemini (with rate-limiting sleep) and together_api for calls to the Together AI platform.
app.utils.repo_structure
Seems to combine functions also found elsewhere. Contains generate_file_tree (like app.utils.file_tree) and get_repo_path, convert_repo_to_txt (like app.utils.utils).
- app.utils.repo_structure.generate_file_tree(root_path: str, max_depth: int = None, show_files: bool = True, prefix: str = '') str[source]
Generate a file tree in string format. This can help LLM to understand the structure of repo, which decrease the potential of lowering LLM’s attention on other important information. This function can be used on ReadME. :param root_path: selected root path of the repo # TODO: Open a window to let user select root path. (Must) :param max_depth: Max depth of the file tree. Control the size of file tree. # TODO: Automatically generate the max depth of file tree. (Should) :param show_files: Only show folders’ name or detailed files’ name. :param prefix: a parameter to bring blank space for sub tree. :return: a file tree in string format.