diff --git a/app.py b/app.py index a9a6dd1..3b7786f 100644 --- a/app.py +++ b/app.py @@ -41,8 +41,9 @@ def __init__(self, folder_path, user_prompt, sortly): def run(self): try: + chunk_size = 100 # Process files in chunks of 100 all_files = os.listdir(self.folder_path) - chunks = [all_files[i:i + 40] for i in range(0, len(all_files), 40)] + chunks = [all_files[i:i + chunk_size] for i in range(0, len(all_files), chunk_size)] for idx, chunk in enumerate(chunks, start=1): user_message = f"Sort this folder: {self.folder_path} with the contents: {chunk}." @@ -138,7 +139,7 @@ def __init__(self): option_label = QLabel("Select model:") self.option_dropdown = QComboBox() - self.option_dropdown.addItems(["gemini-2.0-flash", "gpt-4.1", "o4-mini", "local_lm_studio"]) + self.option_dropdown.addItems(self.supported_models.keys()) self.option_dropdown.setFixedWidth(140) self.option_dropdown.currentTextChanged.connect(self.on_option_changed) api_row.addStretch() # Push dropdown to right @@ -169,10 +170,20 @@ def __init__(self): main_layout.addWidget(self.sort_button, alignment=Qt.AlignCenter) self.folder_path = None + self.model = "gemini-2.0-flash" + self.endpoint = self.supported_models.get(self.model, "https://generativelanguage.googleapis.com/v1beta/openai/") self.files_content = [] self.apply_theme() + supported_models = { + "gemini-2.0-flash": "https://generativelanguage.googleapis.com/v1beta/openai/", + "gpt-4.1": "https://api.openai.com/v1/", + "gpt-4o": "https://api.openai.com/v1/", + "o4-mini": "https://api.openai.com/v1/", + "local_lm_studio": "localhost:1234/v1", + } + def save_api_key(self): @@ -183,7 +194,9 @@ def save_api_key(self): QMessageBox.warning(self, "Invalid", "Please enter a valid API key.") def on_option_changed(self, text): - print(f"Dropdown option changed to: {text}") + print(f"Model option changed to: {text} the endpoint that will be used is: {self.supported_models.get(text)}") + self.model = text + self.endpoint = self.supported_models.get(text) def toggle_theme(self): self.is_dark = not self.is_dark @@ -232,7 +245,7 @@ def sort_files(self): self.text_input.append("Starting sort...") user_prompt = self.text_input.toPlainText() - sortly = Sortly(os.getenv("OPENAI_API_KEY")) + sortly = Sortly(os.getenv("OPENAI_API_KEY"), model=self.model, base_url=self.endpoint) self.worker = SortWorker(self.folder_path, user_prompt, sortly) self.worker.progress.connect(self.update_progress) diff --git a/src/Sortly.py b/src/Sortly.py index 59b73ba..70962cb 100644 --- a/src/Sortly.py +++ b/src/Sortly.py @@ -34,8 +34,9 @@ def __init__( - Folder names should be descriptive (Maximum 3 words) and meaningful, not just file extensions. - Keep original file names intact; do not rename files. - If there are existing folders do not rename or move them. try to put the files in the existing folders if it matches the context. - - If there are files that don’t clearly belong in a category, place them into an "Misc" folder. But before putting any file in that check if it can be put in any existing files. - - You do not have to arrange the existing folders. Do not include them unless they can be combined in a meaningful way. + - If there are files that don’t clearly belong in a category try to match it with a existing folder and if not do not include it at all. + - Do put just only one file in a folder. If the file is not related to any folder, do not include it in the folder structure. + - You do not have to arrange the existing folders. Do not combine them unless they can be combined in a meaningful way. """ def sort_folder(self, user_prompt: str): @@ -84,6 +85,9 @@ def sort( Done: Message """ for folder_name, file_list in folder_structure.items(): + if "existi" in folder_name.lower(): + # Skip existing folders + continue target_folder_path = os.path.join(root_folder_path, folder_name) os.makedirs(target_folder_path, exist_ok=True)