-
Couldn't load subscription status.
- Fork 4
mcp tool of the new derive graph (flow chart) from sympy code. #38
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
NiccoloGrillo
wants to merge
6
commits into
main
Choose a base branch
from
Nicco_grillo
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.
+122
−4
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dad0ff4
mcp tool of the new derive graph (flow chart) from sympy code.
4369173
refactor: update generate_derivation_graph to use multipart/form-data…
54f4df1
Merge branch 'main' into Nicco_grillo
a96lex 93b2678
address review comments
e5e4e46
fixed bug, now works correctly
bcb4674
nitpicking corrections
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """Utilities for handling code input processing.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
|
|
||
| def get_python_code(code_input: Path | str) -> tuple[str, Path | None]: | ||
| """Extract Python code from either a file path or direct string. | ||
|
|
||
| Args: | ||
| code_input: Either a Path object to a .py file or a string (file path or direct code) | ||
|
|
||
| Returns: | ||
| tuple[str, Path | None]: | ||
| - code_content: The Python code to process | ||
| - file_path: Path to the source file if input was a file, None if direct code | ||
| (Used to determine where to save output files) | ||
|
|
||
| Raises: | ||
| ValueError: If file not found or unsupported file type | ||
| """ | ||
| if isinstance(code_input, Path): | ||
| if not code_input.exists(): | ||
| raise ValueError(f"File not found: {code_input}") | ||
|
|
||
| if code_input.suffix.lower() != ".py": | ||
| raise ValueError(f"Unsupported file type: {code_input.suffix}. Only .py files are supported") | ||
|
|
||
| with Path.open(code_input, encoding="utf-8") as f: | ||
| return f.read(), code_input | ||
|
|
||
| if len(code_input) < 500 and "\n" not in code_input: | ||
| potential_path = Path(code_input) | ||
|
|
||
| if potential_path.suffix: | ||
| if not potential_path.exists(): | ||
| raise ValueError(f"File not found: {potential_path}") | ||
|
|
||
| if potential_path.suffix.lower() != ".py": | ||
| raise ValueError(f"Unsupported file type: {potential_path.suffix}. Only .py files are supported") | ||
|
|
||
| with Path.open(potential_path, encoding="utf-8") as f: | ||
| return f.read(), potential_path | ||
|
|
||
| return code_input, None | ||
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.