Commit Graph

55 Commits

Author SHA1 Message Date
Alishahryar1 e7ac85264f Improved optimizations to decrease llm calls further and increase throughput 2026-02-18 17:54:41 -08:00
Alishahryar1 b05d0d2703 new linter rules and fixes 2026-02-18 04:13:41 -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
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
Alishahryar1 71cc814efb Add plans directory support to CLI session management
- Introduced `plans_directory` parameter in `CLISessionManager`, `CLISession`, and updated related methods to handle plan files.
- Updated `api/app.py` to pass the plans directory to the CLI session manager.
- Added a new test in `test_cli.py` to verify that the `--settings plansDirectory` argument is included when starting a task with a specified plans directory.
2026-02-16 15:34:26 -08:00
Alishahryar1 01852e1638 Add configurable HTTP timeouts for provider API requests
Updated the README to include new timeout settings. Implemented these timeouts in the provider classes and added corresponding tests to ensure they are correctly passed to the client. Also included environment variable support for the new settings.
2026-02-16 01:40:15 -08:00
Alishahryar1 6511542bfe Implement Discord bot support and update README for messaging platform changes 2026-02-16 00:08:09 -08:00
Alishahryar1 ad44594197 Added ruff check to workflow and fixed ruff check errors 2026-02-15 22:02:15 -08:00
Alishahryar1 539854fe7b Refactor done using GLM-5 2026-02-15 21:58:03 -08:00
Alishahryar1 b83be84313 Add LM Studio provider support
- Introduced `LMStudioProvider` to the provider system.
- Added a new fixture `lmstudio_provider` in `conftest.py` for testing.
- Updated `get_provider` function to handle `lmstudio` as a valid provider type.
- Enhanced README and `.env.example` to include LM Studio configuration details.
- Updated settings to accommodate LM Studio's base URL and provider type.
- Added tests to verify the functionality of the LM Studio provider.
2026-02-15 19:41:03 -08:00
Alishahryar1 054f9869b7 Refactor rate limiting configuration to use unified provider settings
- Replaced NVIDIA NIM and OpenRouter specific rate limit settings with a generic provider rate limit in settings, tests, and environment files.
- Updated README.md to reflect the new provider rate limit configuration.
- Adjusted tests to validate the new provider rate limit attributes.
2026-02-15 11:03:59 -08:00
Alishahryar1 e5a096049d feat: add OpenRouter support and configuration options
- Introduced OpenRouter as a new provider option in settings and environment configuration.
- Updated README.md to include instructions for using OpenRouter.
- Enhanced the message converter to support reasoning content for OpenRouter.
- Added tests for OpenRouter provider functionality and message conversion.
- Updated dependencies to include OpenRouterProvider.
2026-02-15 10:50:53 -08:00
Alishahryar1 7dfcad2a4c Enhance logging and error handling across multiple modules
- Added request ID context to logging in FastAPI routes and NVIDIA NIM provider.
- Improved logging format to include context variables for better traceability.
- Updated message handling in Telegram and Claude handlers to log message previews.
- Enhanced error logging in NVIDIA NIM provider with request ID for easier debugging.
- Added logging for tree repository actions to track tree and node registrations.
2026-02-15 02:01:57 -08:00
Alishahryar1 ab74791e4b Improved logging coverage 2026-02-14 23:14:58 -08:00
Alishahryar1 0d292cd578 ci: enhance type checking in workflow and improve test coverage
- Added a step to fail the CI if any '# type: ignore' comments are found in Python files.
- Refactored tests to use mocking for better isolation and reliability.
- Updated type hints and casting in several files to improve type safety.
2026-02-14 23:01:11 -08:00
github-actions[bot] 9822e2d6a1 style: apply ruff format 2026-02-15 06:43:46 +00:00
Cursor Agent 575637bc94 fix: correct except clause syntax in request_utils (TypeError, ValueError)
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-15 05:07:17 +00:00
Alishahryar1 7259b1def8 Optimized code in hot paths with z-ai/glm5 2026-02-14 19:59:46 -08:00
Alishahryar1 96747f2216 Updated token counting and removed non streaming support 2026-02-14 19:10:09 -08:00
Alishahryar1 ba344f26c9 Revamped logging 2026-02-14 18:55:33 -08:00
Alishahryar1 64e5b10612 Refactor done by z-ai/glm5 2026-02-14 18:47:26 -08:00
Alishahryar1 25b9d9d1e4 Added ruff and ty dependencies and lint 2026-02-14 18:00:21 -08:00
Cursor Agent 25c7123e33 Phase 7 & 8: Routes optimization refactor and request utils split
Phase 7 - Optimization handlers:
- Create api/optimization_handlers.py with try_prefix_detection,
  try_quota_mock, try_title_skip, try_suggestion_skip, try_filepath_mock
- Add try_optimizations() that runs handlers in order
- Refactor routes.create_message to use try_optimizations()
- Update test_routes_optimizations patch targets

Phase 8 - Request utils split:
- Create api/detection.py: is_quota_check_request, is_title_generation_request,
  is_prefix_detection_request, is_suggestion_mode_request,
  is_filepath_extraction_request
- Create api/command_utils.py: extract_command_prefix, extract_filepaths_from_command
- Slim request_utils.py to get_token_count + re-exports for backward compat

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-15 01:41:35 +00:00
Alishahryar1 42a833245f Removed all signal handler logic 2026-02-14 17:17:58 -08:00
Alishahryar1 bd1e097d74 fixed tool parser and added signal handlers 2026-02-14 04:25:12 -08:00
Alishahryar1 fabca59f5c lint 2026-02-13 17:24:18 -08:00
Alishahryar1 de7677ba6c added graceful shutdown 2026-02-13 13:40:49 -08:00
Alishahryar1 42bfb2da9b improve test coverage 2026-02-13 12:54:48 -08:00
Alishahryar1 697bc37faf Upon dequeue the current request immediately displays processing state instead of position 1 waiting 2026-02-08 04:06:41 -08:00
Alishahryar1 6d8f13d84e Added feature to update queue positions on telegram when messages are dequeued and added new tests 2026-02-08 04:00:58 -08:00
Alishahryar1 6102583026 Major Refactor Part 2 with kimi-k2.5 in claude code 2026-02-05 16:09:16 -08:00
Alishahryar1 fcbe204f44 Major refactor done with kimi-k2.5 in claude code 2026-02-05 10:51:33 -08:00
Alishahryar1 b3b3389ced fixed logging race condition 2026-02-03 19:42:30 -08:00
Alishahryar1 a971c45004 lint 2026-02-03 19:25:52 -08:00
Alishahryar1 81d41fb6d5 Added mocking for suggestion mode and file path extraction 2026-02-03 19:24:18 -08:00
Alishahryar1 78d0276d03 fixed /stop 2026-01-31 14:39:24 -08:00
Alishahryar1 8ce86f4267 fixed type errors 2026-01-31 14:13:09 -08:00
Alishahryar1 b0f77b67cc changed close to aclose 2026-01-31 14:05:41 -08:00
Alishahryar1 0ea3ec8741 added tree persistence 2026-01-31 13:56:06 -08:00
Alishahryar1 303767e346 fixed linter errors 2026-01-30 23:32:02 -08:00
Alishahryar1 7045e0ed44 add retry for telegram message edits with tests and updated rate telegram limit 2026-01-30 15:41:24 -08:00
Alishahryar1 3b037932d7 refactor to reduce coupling 2026-01-30 13:39:40 -08:00
Alishahryar1 312c365f54 Implemeted the 2 new optimizations 2026-01-30 03:25:05 -08:00
Alishahryar1 d958544c3d Migrated from telethon to telegram bot api 2026-01-30 00:38:39 -08:00
Alishahryar1 6eca7377ce Revert "Added rate limiter queue for telegram"
This reverts commit 6a4409d625.
2026-01-29 23:16:01 -08:00
Alishahryar1 82ab6d64e1 Revert "added messaging app rate limiter params"
This reverts commit 8ee1da7140.
2026-01-29 23:14:59 -08:00
Alishahryar1 8ee1da7140 added messaging app rate limiter params 2026-01-29 22:38:26 -08:00
Alishahryar1 6a4409d625 Added rate limiter queue for telegram 2026-01-29 22:28:18 -08:00
Alishahryar1 5fd7268d3f added tree based session handler 2026-01-29 18:17:42 -08:00