Commit Graph

392 Commits

Author SHA1 Message Date
Alishahryar1 16fa9d90cd Add message_thread_id support across messaging components
- Introduced message_thread_id to the IncomingMessage model for handling forum topic IDs in Telegram.
- Updated messaging platforms (Discord and Telegram) to accept and process message_thread_id in send_message methods.
- Modified message handlers to utilize message_thread_id when sending messages.
- Enhanced test cases to validate the integration of message_thread_id in message handling.

This change improves support for forum supergroups in Telegram and enhances message management across platforms.
2026-02-18 16:10:57 -08:00
Alishahryar1 8807f58267 decreased default message rate limit 2026-02-18 13:35:09 -08:00
Alishahryar1 2220880671 Add voice note cancellation feature during transcription
- Implemented functionality to cancel pending voice transcriptions when a user replies with the /clear command.
- Updated the Telegram and Discord platform classes to manage pending voice messages, including registration and cancellation logic.
- Enhanced the message handler to delete associated messages and notify users when a voice note is cancelled.
- Added tests to ensure the cancellation feature works as expected during transcription.
2026-02-18 06:36:42 -08:00
Alishahryar1 f66834e402 Add optional voice extra imports for analysis in pyproject.toml
- Updated the pyproject.toml to include allowed unresolved imports for optional voice dependencies: torch, transformers, and librosa.
- This change facilitates smoother integration in CI environments where these packages may not be installed.
2026-02-18 06:22:49 -08:00
Alishahryar1 75e066f17f Refactor voice note transcription to use Hugging Face transformers Whisper pipeline
- Updated transcription logic to utilize Hugging Face's Whisper models instead of faster-whisper.
- Introduced new model mapping and pipeline loading functions.
- Adjusted tests to reflect changes in the transcription process.
- Updated documentation in README, .env.example, and settings to align with the new implementation.
- Ensured compatibility with CUDA 13 and removed unnecessary dependencies.
2026-02-18 06:18:28 -08:00
Ali Khokhar 34fb8e2ca7 Merge pull request #40 from Alishahryar1/cursor/voice-note-transcribe-fallbacks-adb6
Voice note transcribe fallbacks
2026-02-18 05:39:39 -08:00
Cursor Agent db646ef2db Remove auto support for whisper_device; only cpu and cuda allowed
- Validate whisper_device in Settings and _get_local_model
- Reject 'auto' with clear ValueError/ValidationError
- Update docs in config, .env.example, README
- Add tests for invalid device and valid cpu/cuda

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-18 13:38:59 +00:00
Cursor Agent 2135e6da05 Add large-v3 and large-v3-turbo whisper model options
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-18 13:37:58 +00:00
Cursor Agent eabe8db2e8 Remove CPU fallbacks for voice note transcribe; auto/cuda/cpu fail fast
- Remove _cuda_failed_models and inference-time CPU fallback
- auto: try CUDA only, fail fast on RuntimeError (no CPU fallback)
- cpu/cuda: use device directly, fail fast on errors
- Update docs in config, .env.example, README

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-18 13:37:23 +00:00
Alishahryar1 f07d38655a updated agent instructions 2026-02-18 05:32:43 -08:00
Alishahryar1 a9e5de0765 lint 2026-02-18 04:19:37 -08:00
Alishahryar1 b05d0d2703 new linter rules and fixes 2026-02-18 04:13:41 -08:00
Ali Khokhar c8b887c0d3 Merge pull request #38 from Alishahryar1/claude/add-linting-rules-tjRGC
Configure Ruff linter and formatter with project standards
2026-02-18 04:04:03 -08:00
Alishahryar1 c4a9b06f1a Merge branch 'main' of https://github.com/Alishahryar1/cc-nim 2026-02-18 04:03:30 -08:00
Alishahryar1 7b6fcf02b8 Updated agent md files for cloud agents 2026-02-18 04:03:29 -08:00
Claude b57defe61d Add ruff, ruff format, and ty best-practice rules to pyproject.toml
- [tool.ruff]: target-version=py314 (matches requires-python>=3.14.2), line-length=88
- [tool.ruff.lint]: select E/W/F/I/UP/B/C4/SIM/PERF/RUF; ignore E501 (formatter handles it)
- [tool.ruff.lint.isort]: known-first-party covers all local packages
- [tool.ruff.format]: double quotes, space indent, auto line-ending
- [tool.ty.environment]: python-version=3.14 for type-checking accuracy

https://claude.ai/code/session_01RVyLT88hTnfJZAVLUbWawS
2026-02-18 12:03:04 +00:00
Ali Khokhar 08a31aa3ed Merge pull request #36 from Alishahryar1/cursor/claude-api-403-error-944f 2026-02-16 23:35:26 -08:00
Cursor Agent e9beb28897 fix: validate API keys at provider init to prevent 403 'authorization missing'
When NVIDIA_NIM_API_KEY or OPENROUTER_API_KEY is empty or not set,
the proxy forwarded requests without a valid Authorization header,
causing providers to return 403 with 'Header of type authorization
was missing'.

Now fail fast with HTTP 503 and a clear message telling users to add
the key to .env, with links to obtain keys.

Fixes #29

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 07:33:56 +00:00
Alishahryar1 7300156925 Add status message handling for voice note processing
- Introduced a new optional field `status_message_id` in the IncomingMessage model to track the status of voice note processing.
- Updated the Telegram and Discord platforms to utilize the `status_message_id` for editing status messages instead of sending new ones.
- Modified tests to assert the correct status message ID is used during voice note handling.
- Changed status message text from "Processing voice note..." to "Transcribing voice note..." for clarity.
2026-02-16 20:48:47 -08:00
Alishahryar1 2b1ae3deea Add voice note processing feedback for Telegram and Discord platforms
- Implemented a queue message to indicate "Processing voice note..." for both Telegram and Discord platforms.
- Updated the Telegram platform to send a status message when handling voice notes.
- Enhanced the test for Telegram voice handling to verify the queue message is sent correctly.
2026-02-16 20:37:10 -08:00
Alishahryar1 454099d36c Merge branch 'main' of https://github.com/Alishahryar1/cc-nim 2026-02-16 20:32:26 -08:00
Alishahryar1 f5aeae21bd fixed weight warning 2026-02-16 20:32:24 -08:00
Ali Khokhar ed5162da17 Update README 2026-02-16 20:31:53 -08:00
Alishahryar1 2d68906f65 Updated gitignore 2026-02-16 20:29:16 -08:00
Alishahryar1 18a1cfa523 Enhance transcription model handling
- Introduced a mechanism to track models that fail CUDA inference, allowing for automatic fallback to CPU on subsequent requests.
- Updated the model loading logic to respect the CUDA failure state, improving robustness in audio transcription.
- Removed debug logging code from Discord platform to streamline error handling.
2026-02-16 20:28:48 -08:00
Alishahryar1 3c9514c6cc lint 2026-02-16 20:16:20 -08:00
Alishahryar1 d668f6e476 Add voice note transcription feature
- Introduced voice note handling for Discord and Telegram platforms.
- Added configuration options for voice note functionality in settings.py and .env.example.
- Updated README to include voice note instructions and configuration details.
- Implemented audio attachment processing and transcription using faster-whisper.
- Enabled voice note support through message handlers in both platforms.
2026-02-16 20:14:59 -08:00
Ali Khokhar 71a518ba8e Merge pull request #35 from Alishahryar1/claude/code-review-architecture-tRi3B
Fix type check errors and CI
2026-02-16 18:32:40 -08:00
Cursor Agent 034d185770 Fix type check errors and CI
- Add re-exports: _is_gfm_table_header_line, _normalize_gfm_tables (discord_markdown)
- Add re-exports: _parse_allowed_channels, _get_discord (discord)
- Add re-exports: NetworkError, RetryAfter, TelegramError (telegram)
- Fix Python 3 except syntax (discord, discord_markdown, telegram_markdown, request_utils)
- Update test patches to messaging.platforms.* for moved modules

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:31:40 +00:00
Ali Khokhar 951eefec85 Merge pull request #34 from Alishahryar1/claude/code-review-architecture-tRi3B
Phase 7: Directory restructuring (messaging/ and tests/)
2026-02-16 18:27:19 -08:00
Cursor Agent 4b4f87515d Phase 7: Directory restructuring (messaging/ and tests/)
- Create messaging/platforms/ (base, discord, telegram, factory)
- Create messaging/rendering/ (discord_markdown, telegram_markdown)
- Create messaging/trees/ (data, repository, processor, queue_manager)
- Organize tests/ into api/, providers/, messaging/, cli/, config/
- Add backward-compatible re-exports at old locations
- Update handler.py and test_messaging_factory.py imports
- Fix Telegram type hints for TELEGRAM_AVAILABLE=False case
- Fix Python 3 except syntax in discord_markdown

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:25:42 +00:00
Alishahryar1 bf9f15b98b docs: Remove redundant PowerShell version guideline from coding environment documentation. 2026-02-16 18:18:23 -08:00
Alishahryar1 eaa81f5922 Updated Readme 2026-02-16 18:16:41 -08:00
Ali Khokhar 386ef0c0d9 Merge pull request #33 from Alishahryar1/claude/code-review-architecture-tRi3B
Update README: project structure, command order, provider extension docs
2026-02-16 18:11:57 -08:00
Cursor Agent 38a7980546 Update README: project structure, command order, provider extension docs
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:11:37 +00:00
Ali Khokhar f39d1bf6bf Merge pull request #32 from Alishahryar1/claude/code-review-architecture-tRi3B
Add architecture improvement plan from code review
2026-02-16 18:07:04 -08:00
Cursor Agent adc04ebfc7 Improve AGENTS.md and CLAUDE.md per best practices
- Remove Windows machine claim
- Replace informal tone with professional CI language
- Add explicit CI check order (ruff format, ruff check, ty check, pytest)
- Tighten bullets, add backticks for commands
- Clarify vague instructions (execute incrementally, prefer built-in tools)
- Add sync note for duplication; bold workflow steps

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:06:00 +00:00
Cursor Agent db1ae0fea9 Align AGENTS.md and CLAUDE.md with architecture plan principles
Add ARCHITECTURE PRINCIPLES section reflecting PLAN.md:
- Shared utilities, DRY, encapsulation, provider-specific config
- Dead code removal, performance, platform-agnostic naming
- No type ignores, backward compatibility
Fix typo: proapagate -> propagate

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:04:03 +00:00
Cursor Agent 794e64bba9 Fix ruff format for handler.py and session.py
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:03:04 +00:00
Cursor Agent bfc781e0ed Phase 4-6: Dead code removal, performance, minor fixes
Phase 4:
- Remove legacy SessionRecord, _sessions, _msg_to_session from SessionStore
- Fix hardcoded provider in root endpoint (use settings.provider_type)
- Update session store tests

Phase 5:
- Use list-based string accumulation in ThinkingSegment, TextSegment, ToolCallSegment
- Cache MAX_MESSAGE_LOG_ENTRIES_PER_CHAT at SessionStore init
- Use iterative DFS in MessageTree.get_descendants

Phase 6:
- Add comment for abstract async generator workaround in BaseProvider
- Rename TELEGRAM_EDIT log tags to PLATFORM_EDIT in handler

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 02:01:01 +00:00
Cursor Agent 72b7e34999 Phase 3: Fix encapsulation violations
- Add MessageTree.set_current_task() method
- Update tree_processor to use set_current_task instead of _current_task
- Move nim_settings out of ProviderConfig, pass only to NvidiaNimProvider
- Update api/dependencies and all tests

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 01:58:51 +00:00
Cursor Agent bab86a2687 Phase 2: Extract OpenAICompatibleProvider base class
- Create providers/openai_compat.py with shared streaming logic
- Refactor NvidiaNimProvider, OpenRouterProvider, LMStudioProvider to extend it
- OpenRouter overrides _handle_extra_reasoning for reasoning_details
- Update test patches to providers.openai_compat

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 01:57:34 +00:00
Cursor Agent d3f5f8877f Phase 1: Extract shared provider utils into providers/common/
- Create providers/common/ with sse_builder, message_converter, think_parser,
  heuristic_tool_parser, error_mapping
- Update nvidia_nim/utils and errors to re-export from common for backward compat
- Update all provider clients and tests to import from providers.common
- Remove duplicated files from nvidia_nim/utils/

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-17 01:55:38 +00:00
Claude 33e17092ce Add architecture improvement plan from code review
Comprehensive 7-phase plan covering: shared provider utils extraction,
streaming base class, encapsulation fixes, dead code removal,
performance improvements, minor fixes, and directory restructuring.

https://claude.ai/code/session_01R3BN4qzAoJ21fQzSBnWCAY
2026-02-17 01:27:01 +00:00
Ali Khokhar 96553df53d Update README.md 2026-02-16 16:29:18 -08:00
Alishahryar1 6abcdb4017 Add clear command functionality to message handler
- Implemented handling of the `/clear` command to clear specific branches or entire trees based on message replies.
- Added tests for various scenarios of the clear command, including clearing branches, handling unknown replies, and clearing entire trees.
- Enhanced `TreeQueueManager` with methods to cancel branches and remove subtrees, ensuring proper state management in the session store.
- Updated `SessionStore` and `TreeRepository` to support removal of node mappings and trees, improving data integrity during clear operations.
2026-02-16 16:23:26 -08:00
Alishahryar1 e4ae59511e Updated models list 2026-02-16 16:06:32 -08:00
Alishahryar1 8a16efc1b1 Included agents files for cloud agents 2026-02-16 16:04:15 -08:00
Alishahryar1 416664ed41 Renamed a check in workflow 2026-02-16 15:59:25 -08:00
Alishahryar1 b8d1bfecbb Improved test coverage 2026-02-16 15:58:16 -08:00