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.check_api_key(self)[source]
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.utils.upload_file_to_gemini(file_path: Path)[source]

Uploads the specified file to Google Gemini. Returns the uploaded file object.

app.utils.utils.convert_file_to_txt(source_file: Path, output_file: Path)[source]

Reads the content of a source file and writes it to an output .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.commit_message.generate_CM(code_diff, model)[source]

Generate CM from code diff.

app.utils.commit_message.improve_CM(code_diff, commit_message, model)[source]

Generate CM from code diff and original CM.

app.utils.commit_message.extract_result(raw_result)[source]

There’s useless information in refined CM, e.g. “Here is the commit message…” To avoid this, regex is used.

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.creation.convert_repo_to_txt()[source]
app.utils.creation.create_part(part_name, info, file_tree, model)[source]

Create the given section by gemini. :param: part_name: name of section :param: content: content of section btw, it seems that parameter can be improved. This will be done once UI is designed. :return: improved section

app.utils.creation.create_feature(existed_feature, file_tree, model)[source]
app.utils.creation.structure_markdown(ordered_text, model)[source]

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.detect_max_depth()[source]
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.

class app.utils.help_popup.HelpPopup(image_path, height, width)[source]

Bases: object

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.llm_api.gemini_api(prompt: str, model) str[source]

Get answer via API of gemini. NOTICE: time.sleep(5) is to avoid reach rate limit per minutes, this can be deleted if there’s a pro account. :param prompt: the given prompt to LLM-gemini. :return: the answer from LLM.

app.utils.llm_api.together_api(prompt: str) str[source]

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.

app.utils.repo_structure.get_repo_path() Path[source]

Prompts the user to input the repository folder path. Validates that the path exists and is a directory.

app.utils.repo_structure.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.toolkit