-
Notifications
You must be signed in to change notification settings - Fork 75
Added MindMap Feature #991
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cd2b9a2
README update
d-rushma 46946c7
Merge branch 'open-edge-platform:main' into main
d-rushma 903f49d
Merge branch 'open-edge-platform:main' into main
d-rushma f768d8e
Merge branch 'open-edge-platform:main' into main
d-rushma 2680b28
Merge branch 'open-edge-platform:main' into main
d-rushma 6848817
Merge branch 'open-edge-platform:main' into main
d-rushma 7e85e8a
Merge branch 'open-edge-platform:main' into main
d-rushma 6f5f1d1
mindmap feature
d-rushma e0e5043
merge
d-rushma b844e69
Mindmap feature
d-rushma 171e26d
README update
d-rushma 529f9be
mindmap feature
d-rushma 94aefbe
Added mindmap
d-rushma 4b07822
Merge branch 'main' into main
avinash-palleti 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 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
82 changes: 82 additions & 0 deletions
82
education-ai-suite/smart-classroom/components/mindmap_component.py
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,82 @@ | ||
| from components.base_component import PipelineComponent | ||
| from components.llm.openvino.summarizer import Summarizer as OvSummarizer | ||
| from components.llm.ipex.summarizer import Summarizer as IpexSummarizer | ||
| from utils.runtime_config_loader import RuntimeConfig | ||
| from utils.config_loader import config | ||
| from utils.storage_manager import StorageManager | ||
| import logging, os | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| class MindmapComponent(PipelineComponent): | ||
| _model = None | ||
| _config = None | ||
|
|
||
| def __init__(self, session_id, provider, model_name, device, temperature=0.7): | ||
| self.session_id = session_id | ||
| provider = provider.lower() | ||
| config_key = (provider, model_name, device) | ||
|
|
||
| if MindmapComponent._model is None or MindmapComponent._config != config_key: | ||
| if provider == "openvino": | ||
| MindmapComponent._model = OvSummarizer( | ||
| model_name=model_name, | ||
| device=device, | ||
| temperature=temperature, | ||
| revision=None | ||
| ) | ||
| elif provider == "ipex": | ||
| MindmapComponent._model = IpexSummarizer( | ||
| model_name=model_name, | ||
| device=device.lower(), | ||
| temperature=temperature | ||
| ) | ||
| else: | ||
| raise ValueError(f"Unsupported summarizer provider: {provider}") | ||
|
|
||
| MindmapComponent._config = config_key | ||
|
|
||
| self.summarizer = MindmapComponent._model | ||
| self.model_name = model_name | ||
| self.provider = provider | ||
|
|
||
| def _get_mindmap_message(self, input_text): | ||
| lang_prompt = vars(config.mindmap.system_prompt) | ||
| logger.debug(f"Mindmap System Prompt: {lang_prompt.get(config.models.summarizer.language)}") | ||
| return [ | ||
| {"role": "system", "content": f"{lang_prompt.get(config.models.summarizer.language)}"}, | ||
| {"role": "user", "content": f"{input_text}"} | ||
| ] | ||
|
|
||
| def generate_mindmap(self, summary_text): | ||
| """ | ||
| Generate a complete mindmap string (non-streaming). | ||
| """ | ||
| project_config = RuntimeConfig.get_section("Project") | ||
| project_path = os.path.join( | ||
| project_config.get("location"), | ||
| project_config.get("name"), | ||
| self.session_id | ||
| ) | ||
| mindmap_path = os.path.join(project_path, "mindmap.mmd") | ||
|
|
||
| try: | ||
| logger.info("Generating mindmap from summary...") | ||
| mindmap_prompt = self.summarizer.tokenizer.apply_chat_template( | ||
| self._get_mindmap_message(summary_text), | ||
| tokenize=False, | ||
| add_generation_prompt=True | ||
| ) | ||
|
|
||
| # Generate tokens | ||
| mindmap_streamer = self.summarizer.generate(mindmap_prompt) | ||
| full_mindmap = "".join(token for token in mindmap_streamer) | ||
|
|
||
| # Save full mindmap to file | ||
| StorageManager.save(mindmap_path, full_mindmap, append=False) | ||
| logger.info("Mindmap generation completed successfully.") | ||
| return full_mindmap | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"Mindmap generation failed: {e}") | ||
| raise e |
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
Binary file modified
BIN
+7.58 KB
(110%)
education-ai-suite/smart-classroom/docs/user-guide/images/smart_classroom_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.