Enhance and refactor codebase with improved type safety and configura…#7
Closed
QRcode1337 wants to merge 8 commits intomainfrom
Closed
Enhance and refactor codebase with improved type safety and configura…#7QRcode1337 wants to merge 8 commits intomainfrom
QRcode1337 wants to merge 8 commits intomainfrom
Conversation
…tion This commit includes several major improvements to code quality and maintainability: 1. Fixed critical missing dependencies in pyproject.toml - Added PyQt6 (entire GUI framework was missing!) - Added anthropic, openai, networkx, beautifulsoup4 - Ensures proper installation via Poetry 2. Added comprehensive type hints to shared_utils.py - All functions now have proper type annotations - Improved code clarity and IDE support - Better error detection during development 3. Centralized configuration system in config.py - Added API_MAX_TOKENS, API_TEMPERATURE, API_TIMEOUT constants - Model-specific configs (LLaMA, DeepSeek, Together AI) - Image and video generation settings - Eliminated magic numbers throughout codebase 4. Improved error handling consistency - Added proper logging configuration - Specific exception handling (RequestException, APIError, ReplicateError) - Better error messages and stack traces - Replaced print statements with logger calls 5. Removed dead code - Eliminated unused functions (read_shared_html, update_shared_html, etc.) - Kept only actively used functionality These changes make the codebase more maintainable, easier to debug, and safer to modify.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors shared_utils.py to improve code maintainability by adding type hints, centralizing configuration constants, and enhancing error handling with structured logging. The changes include extracting hardcoded values to config.py and removing unused stub functions.
- Adds comprehensive type hints to all function signatures for better type safety
- Centralizes API configuration constants (tokens, temperature, timeouts) into
config.py - Improves error handling with structured logging and specific exception types
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| shared_utils.py | Adds type hints to all functions, replaces hardcoded API parameters with config constants, implements structured logging with specific exception handlers, and removes unused stub functions |
| config.py | Introduces centralized configuration constants for API parameters (max tokens, temperature, timeout), model-specific settings (LLaMA, DeepSeek, Together), and image/video generation settings |
| pyproject.toml | Adds missing dependency declarations (PyQt6, anthropic, openai, networkx, beautifulsoup4) |
Comments suppressed due to low confidence (1)
shared_utils.py:42
- Import of 'SORA_POLL_INTERVAL_SECONDS' is not used.
from config import (
API_MAX_TOKENS, API_TEMPERATURE, API_TIMEOUT,
LLAMA_MAX_TOKENS, LLAMA_TEMPERATURE, LLAMA_TOP_P, LLAMA_REPETITION_PENALTY, LLAMA_MAX_HISTORY,
DEEPSEEK_MAX_TOKENS, DEEPSEEK_TEMPERATURE,
TOGETHER_MAX_TOKENS, TOGETHER_TEMPERATURE, TOGETHER_TOP_P,
IMAGE_WIDTH, IMAGE_HEIGHT,
SORA_POLL_INTERVAL_SECONDS
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
auto-merge was automatically disabled
November 21, 2025 05:05
Pull request was closed
auto-merge was automatically disabled
November 30, 2025 16:19
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…tion
This commit includes several major improvements to code quality and maintainability:
Fixed critical missing dependencies in pyproject.toml
Added comprehensive type hints to shared_utils.py
Centralized configuration system in config.py
Improved error handling consistency
Removed dead code
These changes make the codebase more maintainable, easier to debug, and safer to modify.