add CLI file input support for FILE_ANALYZER tool when running locally#172
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by Qodo(Agentic_describe updated until commit 1515fec)Add CLI file input support with session file staging and error handling
WalkthroughsDescription• Add CLI file input support via -f/--file argument for FILE_ANALYZER tool • Introduce SessionFilePreparationError exception for robust file staging error handling • Implement _prepare_session_files() function to safely copy user files into session directory • Add comprehensive unit tests covering valid file copying and error scenarios • Integrate session management and logger reconfiguration into CLI workflow Diagramflowchart LR
CLI["CLI Arguments<br/>-f/--file"]
PREP["_prepare_session_files()"]
COPY["Copy files to<br/>session input dir"]
ERROR["SessionFilePreparationError<br/>handling"]
WORKFLOW["create_workflow()"]
CLI -- "file paths" --> PREP
PREP -- "validate & stage" --> COPY
PREP -- "error cases" --> ERROR
COPY -- "input_dir" --> WORKFLOW
ERROR -- "user feedback" --> CLI
File Changes1. app/core/main.py
|
Code Review by Qodo
1.
|
PR Reviewer Guide 🔍(Review updated until commit 1515fec)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
| # Initialize language models | ||
| models = llm_creation() | ||
|
|
There was a problem hiding this comment.
3. Api key cli not applied 🐞 Bug ☼ Reliability
The CLI accepts --api-key but does not pass it to llm_creation(), so model initialization may still rely on environment variables and fail even when the user supplies a key.
Agent Prompt
### Issue description
`--api-key` is parsed but not used when creating the LLM instances via `llm_creation()`. This can break local CLI usage when the environment variables are not set.
### Issue Context
`llm_creation(api_key=None, ...)` is designed to accept an explicit key. The CLI already exposes `--api-key`.
### Fix Focus Areas
- app/core/main.py[262-265]
- app/core/main.py[292-294]
### Suggested fix
Change `models = llm_creation()` to `models = llm_creation(api_key=args.api_key)` (or equivalent provider-aware wiring) so the CLI-provided key is honored during model creation.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
- Introduced SessionFilePreparationError for better error management during file staging. - Enhanced _prepare_session_files function to handle various file-related errors. - Added unit tests for session file preparation, covering valid file copying and error scenarios. - Documented changes in the agentic engineering log.
Code Review by Qodo
1. Wrong API key reused
|
|
Persistent review updated to latest commit 1515fec |
PR Code Suggestions ✨No code suggestions found for the PR. |
| # Initialize language models | ||
| models = llm_creation(api_key=args.api_key) |
There was a problem hiding this comment.
1. Wrong api key reused 🐞 Bug ≡ Correctness
main() now forwards --api-key into llm_creation(), but llm_creation keeps a single api_key value and applies it to every configured provider section. In a multi-provider params.ini (OpenAI + deepseek + ovh), deepseek/ovh models will incorrectly receive the OpenAI key (or the first resolved key), causing authentication failures.
Agent Prompt
### Issue description
`llm_creation()` reuses a single `api_key` value across all config sections. After this PR, `main()` passes `--api-key` into `llm_creation()`, so deepseek/ovh models can receive the OpenAI key and fail auth.
### Issue Context
`app/config/params.ini` contains OpenAI sections plus `deepseek_*` and `ovh_*` sections. Each provider needs its own key (from provider-specific env vars), while the CLI `--api-key` is described as an OpenAI key.
### Fix Focus Areas
- app/core/main.py[109-166]
- app/core/main.py[346-348]
### Suggested fix approach
- In `llm_creation()`, do **not** mutate/reuse the incoming `api_key` parameter across sections.
- Introduce a per-section variable, e.g. `section_api_key`:
- If `provider == "openai"` and a CLI `api_key` is provided, use it.
- Otherwise, resolve via `get_api_key(provider)` for that section.
- Use `section_api_key` when setting `model_params[...]`.
- (Optional) If you want CLI support for deepseek/ovh keys too, add explicit CLI flags rather than overloading `--api-key`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
PR Type
enhancement, tests
Description
Added CLI file input support for FILE_ANALYZER tool
Introduced error handling for session file preparation
Implemented unit tests for session file preparation
Updated CLI documentation with usage examples
Diagram Walkthrough
File Walkthrough
main.py
Add CLI file input and error handlingapp/core/main.py
SessionFilePreparationErrorfor error handling_prepare_session_filesfor file stagingtest_main.py
Implement tests for session file preparationapp/core/tests/test_main.py