-
Notifications
You must be signed in to change notification settings - Fork 19
Advanced Installation Intent Detection (Issue #53) #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pavanimanchala53
wants to merge
21
commits into
cortexlinux:main
Choose a base branch
from
pavanimanchala53:feature/advanced-intent-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b5f00da
Add Advanced Installation Intent Detection (#53) - complete feature w…
pavanimanchala53 bf832fa
Remove venv from repository index (clean up)
pavanimanchala53 4d6bc23
Finalize feature: add .gitignore and update llm_agent
pavanimanchala53 7a190af
Fix review comments: dedupe GPU intents, optional api_key, persist in…
pavanimanchala53 6698f87
Fix GPU intent dedupe as per review
pavanimanchala53 a725461
Apply ClassVar annotation, remove unused import, and fix GPU dedupe
pavanimanchala53 161acf6
Use GPU synonyms for configure intent
pavanimanchala53 ecd9a50
Fix CodeRabbit comments for llm_agent.py
pavanimanchala53 7535e5d
Add timeout to LLM API calls per CodeRabbit review
pavanimanchala53 2ac027c
Apply full CodeRabbit fixes for llm_agent.py
pavanimanchala53 af522e9
Apply CodeRabbit review fixes: timeouts, safety checks, imports (llm_…
pavanimanchala53 4277225
Add PyYAML to requirements
pavanimanchala53 26202e8
Update test_installation_history.py
pavanimanchala53 db80201
Update test_installation_history.py
pavanimanchala53 79bbfbd
Pin PyYAML version to 6.0.3
pavanimanchala53 9ed0503
Fix Issue #53: Add interactive clarification flow and user confirmation
Sahilbhatane c628890
Merge pull request #1 from Sahilbhatane/pr-213
pavanimanchala53 24cb1fe
Enhance GPU detection logic in planner.py
Sahilbhatane bf095c3
Delete .github/workflows/codeql.yml for sonarworkflow
Sahilbhatane 35ca9bb
Merge branch 'main' into feature/advanced-intent-detection
Sahilbhatane ed3620f
Merge branch 'main' into feature/advanced-intent-detection
Sahilbhatane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ pyyaml>=6.0.0 | |
|
|
||
| # Type hints for older Python versions | ||
| typing-extensions>=4.0.0 | ||
| PyYAML==6.0.3 | ||
File renamed without changes.
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # clarifier.py | ||
|
|
||
| from typing import List, Optional | ||
| from intent.detector import Intent | ||
|
|
||
| class Clarifier: | ||
| """ | ||
| Checks if the detected intents have missing information. | ||
| Returns a clarifying question if needed. | ||
| """ | ||
|
|
||
| def needs_clarification(self, intents: List[Intent], text: str) -> Optional[str]: | ||
| text = text.lower() | ||
|
|
||
| # 1. If user mentions "gpu" but has not specified which GPU → ask | ||
| if "gpu" in text and not any(i.target in ["cuda", "pytorch", "tensorflow"] for i in intents): | ||
| return "Do you have an NVIDIA GPU? (Needed for CUDA/PyTorch/TensorFlow installation)" | ||
|
|
||
| # 2. If user says "machine learning tools" but nothing specific | ||
| generic_terms = ["ml", "machine learning", "deep learning", "ai tools"] | ||
| if any(term in text for term in generic_terms) and len(intents) == 0: | ||
| return "Which ML frameworks do you need? (PyTorch, TensorFlow, JupyterLab...)" | ||
|
|
||
| # 3. If user asks to install CUDA but no GPU exists in context | ||
| if any(i.target == "cuda" for i in intents) and "gpu" not in text: | ||
| return "Installing CUDA requires an NVIDIA GPU. Do you have one?" | ||
|
|
||
| # 4. If package versions are missing (later we can add real version logic) | ||
| # Only ask about GPU/CPU version if user hasn't already specified | ||
| if "torch" in text and "version" not in text: | ||
| # Don't ask if user already mentioned GPU or CUDA | ||
| if not any(term in text for term in ["gpu", "cuda", "nvidia", "graphics"]): | ||
| return "Do you need the GPU version or CPU version of PyTorch?" | ||
|
|
||
| # 5. Otherwise no clarification needed | ||
| return None |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # context.py | ||
|
|
||
| from typing import List, Optional | ||
| from intent.detector import Intent | ||
|
|
||
| class SessionContext: | ||
| """ | ||
| Stores context from previous user interactions. | ||
| This is needed for Issue #53: | ||
| 'Uses context from previous commands' | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| self.detected_gpu: Optional[str] = None | ||
| self.previous_intents: List[Intent] = [] | ||
| self.installed_packages: List[str] = [] | ||
| self.clarifications: List[str] = [] | ||
|
|
||
| # ------------------- | ||
| # GPU CONTEXT | ||
| # ------------------- | ||
|
|
||
| def set_gpu(self, gpu_name: str): | ||
| self.detected_gpu = gpu_name | ||
|
|
||
| def get_gpu(self) -> Optional[str]: | ||
| return self.detected_gpu | ||
|
|
||
| # ------------------- | ||
| # INTENT CONTEXT | ||
| # ------------------- | ||
|
|
||
| def add_intents(self, intents: List[Intent]): | ||
| self.previous_intents.extend(intents) | ||
|
|
||
| def get_previous_intents(self) -> List[Intent]: | ||
| return self.previous_intents | ||
|
|
||
| # ------------------- | ||
| # INSTALLED PACKAGES | ||
| # ------------------- | ||
|
|
||
| def add_installed(self, pkg: str): | ||
| if pkg not in self.installed_packages: | ||
| self.installed_packages.append(pkg) | ||
|
|
||
| def is_installed(self, pkg: str) -> bool: | ||
| return pkg in self.installed_packages | ||
|
|
||
| # ------------------- | ||
| # CLARIFICATIONS | ||
| # ------------------- | ||
|
|
||
| def add_clarification(self, question: str): | ||
| self.clarifications.append(question) | ||
|
|
||
| def get_clarifications(self) -> List[str]: | ||
| return self.clarifications | ||
|
|
||
| # ------------------- | ||
| # RESET CONTEXT | ||
| # ------------------- | ||
|
|
||
| def reset(self): | ||
| """Reset context (new session)""" | ||
| self.detected_gpu = None | ||
| self.previous_intents = [] | ||
| self.installed_packages = [] | ||
| self.clarifications = [] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # detector.py | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import List, Optional, ClassVar | ||
|
|
||
| @dataclass | ||
| class Intent: | ||
| action: str | ||
| target: str | ||
| details: Optional[dict] = None | ||
|
|
||
| class IntentDetector: | ||
| """ | ||
| Extracts high-level installation intents from natural language requests. | ||
| """ | ||
|
|
||
| COMMON_PACKAGES: ClassVar[dict[str, List[str]]] = { | ||
| "cuda": ["cuda", "nvidia toolkit"], | ||
| "pytorch": ["pytorch", "torch"], | ||
| "tensorflow": ["tensorflow", "tf"], | ||
| "jupyter": ["jupyter", "jupyterlab", "notebook"], | ||
| "cudnn": ["cudnn"], | ||
| "python": ["python", "python3"], | ||
| "docker": ["docker"], | ||
| "nodejs": ["node", "nodejs", "npm"], | ||
| "git": ["git"], | ||
| "gpu": ["gpu", "graphics card", "rtx", "nvidia"] | ||
| } | ||
|
|
||
| def detect(self, text: str) -> List[Intent]: | ||
| text = text.lower() | ||
| intents = [] | ||
|
|
||
| # 1. Rule-based keyword detection (skip GPU to avoid duplicate install intent) | ||
| for pkg, keywords in self.COMMON_PACKAGES.items(): | ||
| if pkg == "gpu": | ||
| continue # GPU handled separately below | ||
| if any(k in text for k in keywords): | ||
| intents.append(Intent(action="install", target=pkg)) | ||
|
|
||
| # 2. Look for verify steps | ||
| if "verify" in text or "check" in text: | ||
| intents.append(Intent(action="verify", target="installation")) | ||
|
|
||
| # 3. GPU configure intent (use all GPU synonyms) | ||
| gpu_keywords = self.COMMON_PACKAGES.get("gpu", ["gpu"]) | ||
| if any(k in text for k in gpu_keywords) and not any( | ||
| i.action == "configure" and i.target == "gpu" | ||
| for i in intents | ||
| ): | ||
| intents.append(Intent(action="configure", target="gpu")) | ||
|
|
||
| return intents |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.