Commit Graph

249 Commits

Author SHA1 Message Date
Vu Quoc Anh
fd143aba17 Potential fix for code scanning alert no. 7: Incomplete URL substring sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-11-30 17:53:15 +07:00
f17081b185 Add retry utilities, input validation, and comprehensive tests
- Implemented async retry logic with exponential backoff in `src/utils/retry.py`.
- Created input validation utilities for Discord bot in `src/utils/validators.py`.
- Refactored token pricing import in `src/utils/token_counter.py`.
- Added comprehensive test suite in `tests/test_comprehensive.py` covering various modules including pricing, validators, retry logic, and Discord utilities.
2025-11-30 17:45:36 +07:00
e2b961e9c0 Refactor OpenAI utility functions: enhance descriptions, add parameters, and improve clarity
- Updated descriptions for functions to provide clearer guidance on usage.
- Added detailed parameter descriptions for better understanding.
- Introduced new function `remove_background` for background removal.
- Adjusted parameter requirements and constraints across various functions.
- Improved overall consistency and readability of the code.
2025-11-29 23:00:34 +07:00
Vu Quoc Anh
c9531b37bb Add LICENSE file 2025-10-31 21:53:31 +07:00
86875bf93d feat: Revamp README.md for enhanced clarity and feature presentation in v2.0.0 2025-10-03 23:57:26 +07:00
0a1e871cdb feat: Implement package cleanup and usage tracking in Docker and non-Docker environments 2.0.4 2025-10-03 13:05:07 +07:00
33a76aa8cc feat: Implement Docker environment detection to use system Python and skip virtual environment management 2025-10-03 12:48:14 +07:00
42274e6ad5 feat: Implement dynamic message length handling for Discord to prevent exceeding character limits 2025-10-02 23:09:10 +07:00
9c180bdd89 Refactor OpenAI utilities and remove Python executor
- Removed the `analyze_data_file` function from tool definitions to streamline functionality.
- Enhanced the `execute_python_code` function description to clarify auto-installation of packages and file handling.
- Deleted the `python_executor.py` module to simplify the codebase and improve maintainability.
- Introduced a new `token_counter.py` module for efficient token counting for OpenAI API requests, including support for Discord image links and cost estimation.
2025-10-02 21:49:48 +07:00
1cb47f1d25 refactor: Update prepare_messages_for_api tests to reflect changes in message handling 2025-08-28 15:31:45 +07:00
7785a8f26e feat: Enhance token usage tracking and history management
- Implement proactive history trimming in DatabaseHandler to limit conversation messages to the last 50 while preserving system messages.
- Add methods for saving and retrieving user token usage statistics, including breakdowns by model.
- Introduce model pricing for token usage calculations in MessageHandler.
- Update message handling to count tokens accurately and log costs associated with API calls.
- Refactor token counting methods to utilize API response data instead of internal counting.
- Improve tool definitions in get_tools_for_model for clarity and conciseness.
- Remove deprecated python_executor_new.py file.
- Adjust web_utils to use tiktoken for preprocessing content before API calls.
2025-08-28 11:43:42 +07:00
85b0d265a6 refactor: remove forced tool choice parameter in API call for model tool usage 2025-08-27 10:22:47 +07:00
6bfc6d4573 refactor: update database handler references for user tool display preferences in message handling 2025-08-27 00:05:47 +07:00
19e62f85fc refactor: add user preference for tool execution display and enhance message handling for search and scraping activities 2025-08-26 23:36:47 +07:00
eaaef0676a refactor: enhance persistent package management and streamline code execution environment 2025-08-26 23:21:28 +07:00
b51bcdc3a9 refactor: enforce tool usage in API calls and enhance Discord message displays for search and scraping activities 2025-08-25 23:16:08 +07:00
8277e06a13 refactor: improve code execution display by handling long code outputs with file attachments and enhancing error messaging 2025-08-25 21:40:03 +07:00
ecfc2b48d5 refactor: enhance Python code execution with async package installation and improved timeout handling 2025-08-25 21:01:22 +07:00
ac6bb8c582 refactor: simplify logging setup by removing file handlers and using console output only 2025-08-25 17:47:50 +07:00
5a69b29ae0 refactor: enhance code execution and analysis features with package installation support and detailed output display 2025-08-24 23:50:54 +07:00
7b19756932 refactor: optimize memory usage by removing unnecessary global variables and implementing cleanup mechanisms 2025-08-15 00:12:15 +07:00
8cad2c541f refactor: adjust token limits and streamline prompts for improved clarity and efficiency 2025-08-14 16:55:35 +07:00
e5d8e5db94 refactor: update NORMAL_CHAT_PROMPT for clarity and conciseness in user interactions 2025-08-08 16:04:23 +07:00
61abc9b1e6 refactor: streamline API call parameters and enhance token management for OpenAI interactions 2025-08-08 11:44:17 +07:00
59b5e13005 fix: update PdfReader import from PyPDF2 to pypdf in pdf_utils.py 2025-08-08 10:18:27 +07:00
e93f76d693 Refactor code structure for improved readability and maintainability 2025-08-08 09:54:18 +07:00
7af48efe00 Refactor and optimize utility functions for improved performance and readability
- Updated `openai_utils.py` to streamline tool definitions and enhance token usage efficiency.
- Simplified the `process_tool_calls` function for better error handling and message preparation.
- Improved time parsing logic in `reminder_utils.py` to support various formats including AM/PM and "tomorrow" keywords.
- Added async wrappers for Google search and webpage scraping in `web_utils.py` to match expected interfaces and improve error handling.
2.0.3
2025-06-21 21:46:06 +07:00
e505cc4b3a feat: Remove linting step from CI workflow 2025-06-20 21:26:05 +07:00
ac8fd924c1 feat: Add comprehensive unit tests for DatabaseHandler, OpenAI utilities, and code utilities 2025-06-20 21:23:03 +07:00
623b18a37c feat: Update execute_python_code tool to enforce explicit print() statements for calculations and add test_executor.py for validation 2025-06-20 21:14:59 +07:00
d3b92f8bef feat: Implement data analysis and code execution utilities
- Added data_analyzer.py for comprehensive data analysis with templates for summary, correlation, distribution, and custom analysis.
- Integrated logging for tracking analysis processes and errors.
- Included package installation functionality for required libraries.
- Developed python_executor.py to safely execute user-provided Python code with sanitization and timeout features.
- Implemented security measures to prevent unsafe code execution.
- Enhanced output handling to capture visualizations and standard output.
2025-06-20 17:56:27 +07:00
cce1ff506b feat: Update NORMAL_CHAT_PROMPT to prioritize Python for code execution and analysis 2025-05-13 23:45:03 +07:00
423d09664c feat: Update model support in MessageHandler to include additional OpenAI models 2025-04-24 14:38:27 +07:00
18bcd79090 feat: Extend model support in response history tracking for additional OpenAI models 2025-04-23 17:35:06 +07:00
47309c0a98 feat: Update PDF processing model validation to use PDF_ALLOWED_MODELS for better flexibility 2025-04-18 18:07:27 +07:00
3163049207 feat: Update MODEL_OPTIONS and PDF_ALLOWED_MODELS to include additional OpenAI models 2025-04-17 20:31:01 +07:00
20ee9b63ab feat: Update PDF_ALLOWED_MODELS and MODEL_OPTIONS to include additional OpenAI models 2025-04-17 15:09:01 +07:00
5649d67d78 feat: Add missing COPY commands for Python packages in Dockerfile 2025-04-16 22:52:24 +07:00
858c938a8b refactor: Simplify Dockerfile by removing non-root user setup and adjusting paths for Python package installation 2025-04-16 22:38:15 +07:00
9dab6d4068 fix: Downgrade Python version in Dockerfile from 3.14 to 3.13.3 for compatibility 2025-04-16 22:03:33 +07:00
d0a6743d80 feat: Update model references to include 'openai/' prefix and improve Dockerfile for better caching and user permissions 2025-04-16 21:58:15 +07:00
daeff6d997 fix: Correct logs directory path in Dockerfile 2025-04-16 17:13:58 +07:00
f295e7b4db feat: Copy logs directory to the application runtime in Dockerfile 2025-04-16 16:58:31 +07:00
80991a9e29 feat: Update .gitignore to exclude logs and add log files for code execution, interpreter, and Discord bot 2025-04-16 16:35:46 +07:00
85ec2bda91 feat: Add additional OpenAI GPT-4.1 model options to MODEL_OPTIONS 2025-04-16 16:20:39 +07:00
3422e5352e feat: Add image editing and enhancement functionalities
- Implemented `edit_image` method for background removal from images.
- Added `enhance_prompt` method to generate improved versions of text prompts.
- Introduced `image_to_text` method for converting images to text descriptions.
- Created `upscale_image` method to enhance image resolution.
- Developed `photo_maker` method for generating images based on prompts and reference images.
- Added `generate_image_with_refiner` method for high-quality image generation using a refiner model.
- Updated OpenAI function definitions to include new image processing capabilities.
- Enhanced message processing to handle image URLs and descriptions appropriately.
2025-04-16 16:19:11 +07:00
Vu Quoc Anh
cc1f884a2f Update Dockerfile 2025-03-31 22:10:45 +07:00
Vu Quoc Anh
a90004614e Update Dockerfile 2025-03-31 22:02:06 +07:00
74cc29e376 feat: Remove caching configuration from Docker build steps for amd64 and arm64 2025-03-28 13:57:09 +07:00
921d057602 feat: Refactor Dockerfile to improve cleanup commands and ensure safe copying of binary files 2025-03-28 13:49:02 +07:00