Spaces:
Sleeping
Sleeping
arun3676 commited on
Commit Β·
76e89b2
1
Parent(s): 646ba30
Update: Add GitHub Repository analysis to matrix_app.py, fix deployment config
Browse files- Procfile +1 -1
- matrix_app.py +89 -21
- matrix_final.py +50 -50
- render.yaml +2 -2
Procfile
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
web: streamlit run
|
|
|
|
| 1 |
+
web: streamlit run matrix_app.py --server.port=$PORT --server.address=0.0.0.0
|
matrix_app.py
CHANGED
|
@@ -399,6 +399,13 @@ with st.sidebar:
|
|
| 399 |
# Multi-model analysis toggle
|
| 400 |
analyze_all = st.checkbox("π MULTI_NETWORK_SCAN", value=False)
|
| 401 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
# Language selection
|
| 403 |
languages = ["auto-detect", "python", "javascript", "java", "cpp", "csharp", "go", "rust"]
|
| 404 |
selected_language = st.selectbox(
|
|
@@ -451,33 +458,94 @@ console.log(`Reality: ${reality}`);
|
|
| 451 |
col1, col2 = st.columns([1, 1])
|
| 452 |
|
| 453 |
with col1:
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
|
| 473 |
# Results Terminal
|
| 474 |
with col2:
|
| 475 |
st.markdown("### π ANALYSIS_OUTPUT_TERMINAL")
|
| 476 |
|
| 477 |
-
if analyze_button and code_input.strip():
|
| 478 |
with st.spinner("π’ SCANNING... NEURAL_NETWORKS_PROCESSING..."):
|
| 479 |
-
if
|
| 480 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
st.markdown("#### π MULTI_NETWORK_ANALYSIS_INITIATED")
|
| 482 |
|
| 483 |
results = analyzer.analyze_with_all_models(
|
|
|
|
| 399 |
# Multi-model analysis toggle
|
| 400 |
analyze_all = st.checkbox("π MULTI_NETWORK_SCAN", value=False)
|
| 401 |
|
| 402 |
+
# Analysis mode selection
|
| 403 |
+
analysis_mode = st.selectbox(
|
| 404 |
+
"ANALYSIS_MODE",
|
| 405 |
+
["Code Analysis", "GitHub Repository"],
|
| 406 |
+
format_func=lambda x: f"π {x}" if x == "Code Analysis" else f"π¦ {x}"
|
| 407 |
+
)
|
| 408 |
+
|
| 409 |
# Language selection
|
| 410 |
languages = ["auto-detect", "python", "javascript", "java", "cpp", "csharp", "go", "rust"]
|
| 411 |
selected_language = st.selectbox(
|
|
|
|
| 458 |
col1, col2 = st.columns([1, 1])
|
| 459 |
|
| 460 |
with col1:
|
| 461 |
+
if analysis_mode == "Code Analysis":
|
| 462 |
+
st.markdown("### π CODE_INPUT_TERMINAL")
|
| 463 |
+
|
| 464 |
+
# Code input with Matrix styling
|
| 465 |
+
code_input = st.text_area(
|
| 466 |
+
"PASTE_TARGET_CODE",
|
| 467 |
+
value=st.session_state.get('code_input', ''),
|
| 468 |
+
height=400,
|
| 469 |
+
key="code_input",
|
| 470 |
+
help="Insert code for neural network analysis..."
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
# Matrix-styled analyze button
|
| 474 |
+
analyze_button = st.button(
|
| 475 |
+
"π INITIATE_SCAN",
|
| 476 |
+
type="primary",
|
| 477 |
+
disabled=not code_input.strip(),
|
| 478 |
+
help="Begin deep neural analysis of target code"
|
| 479 |
+
)
|
| 480 |
+
|
| 481 |
+
else: # GitHub Repository mode
|
| 482 |
+
st.markdown("### π¦ GITHUB_REPOSITORY_TERMINAL")
|
| 483 |
+
|
| 484 |
+
# GitHub URL input
|
| 485 |
+
github_url = st.text_input(
|
| 486 |
+
"TARGET_REPOSITORY_URL",
|
| 487 |
+
placeholder="https://github.com/owner/repo",
|
| 488 |
+
help="Enter GitHub repository URL for analysis"
|
| 489 |
+
)
|
| 490 |
+
|
| 491 |
+
# GitHub analyze button
|
| 492 |
+
analyze_github_button = st.button(
|
| 493 |
+
"π SCAN_REPOSITORY",
|
| 494 |
+
type="primary",
|
| 495 |
+
disabled=not github_url.strip(),
|
| 496 |
+
help="Begin neural analysis of GitHub repository"
|
| 497 |
+
)
|
| 498 |
+
|
| 499 |
+
# Initialize code_input for compatibility
|
| 500 |
+
code_input = ""
|
| 501 |
+
analyze_button = False
|
| 502 |
|
| 503 |
# Results Terminal
|
| 504 |
with col2:
|
| 505 |
st.markdown("### π ANALYSIS_OUTPUT_TERMINAL")
|
| 506 |
|
| 507 |
+
if (analyze_button and code_input.strip()) or (analysis_mode == "GitHub Repository" and 'analyze_github_button' in locals() and analyze_github_button and github_url.strip()):
|
| 508 |
with st.spinner("π’ SCANNING... NEURAL_NETWORKS_PROCESSING..."):
|
| 509 |
+
if analysis_mode == "GitHub Repository":
|
| 510 |
+
# GitHub Repository Analysis
|
| 511 |
+
st.markdown("#### π¦ GITHUB_REPOSITORY_SCAN_INITIATED")
|
| 512 |
+
|
| 513 |
+
if analyze_all:
|
| 514 |
+
# Multi-model GitHub analysis
|
| 515 |
+
results = {}
|
| 516 |
+
for model_key in available_models.keys():
|
| 517 |
+
result = analyzer.analyze_github_repo(github_url, model_key)
|
| 518 |
+
results[model_key] = result
|
| 519 |
+
|
| 520 |
+
# Display comparison metrics for GitHub
|
| 521 |
+
comparison = analyzer.compare_analyses(results)
|
| 522 |
+
|
| 523 |
+
col_metrics = st.columns(4)
|
| 524 |
+
with col_metrics[0]:
|
| 525 |
+
st.metric("REPOSITORY", "ANALYZED")
|
| 526 |
+
with col_metrics[1]:
|
| 527 |
+
st.metric("MODELS_USED", len(results))
|
| 528 |
+
with col_metrics[2]:
|
| 529 |
+
st.metric("CONSENSUS_SCORE", f"{comparison.get('consensus_score', 0):.1f}")
|
| 530 |
+
with col_metrics[3]:
|
| 531 |
+
st.metric("SCAN_TIME", f"{comparison['analysis_time']:.1f}s")
|
| 532 |
+
|
| 533 |
+
# Create tabs for each neural network
|
| 534 |
+
tab_names = [f"π€ {available_models[key]}" for key in results.keys()]
|
| 535 |
+
tabs = st.tabs(tab_names)
|
| 536 |
+
|
| 537 |
+
for idx, (model_key, result) in enumerate(results.items()):
|
| 538 |
+
with tabs[idx]:
|
| 539 |
+
display_matrix_analysis_result(result, available_models[model_key])
|
| 540 |
+
else:
|
| 541 |
+
# Single model GitHub analysis
|
| 542 |
+
st.markdown(f"#### π€ {available_models[selected_model].upper()}_GITHUB_ANALYSIS")
|
| 543 |
+
|
| 544 |
+
result = analyzer.analyze_github_repo(github_url, selected_model)
|
| 545 |
+
display_matrix_analysis_result(result, available_models[selected_model])
|
| 546 |
+
|
| 547 |
+
elif analyze_all:
|
| 548 |
+
# Multi-model code analysis
|
| 549 |
st.markdown("#### π MULTI_NETWORK_ANALYSIS_INITIATED")
|
| 550 |
|
| 551 |
results = analyzer.analyze_with_all_models(
|
matrix_final.py
CHANGED
|
@@ -681,57 +681,57 @@ col1, col2 = st.columns([1, 1])
|
|
| 681 |
with col1:
|
| 682 |
if analysis_mode == "Code Analysis":
|
| 683 |
st.markdown("### π Code Input")
|
| 684 |
-
|
| 685 |
-
|
| 686 |
st.markdown("#### π Upload File")
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
else: # GitHub Repository mode
|
| 736 |
st.markdown("### π¦ GitHub Analysis")
|
| 737 |
|
|
|
|
| 681 |
with col1:
|
| 682 |
if analysis_mode == "Code Analysis":
|
| 683 |
st.markdown("### π Code Input")
|
| 684 |
+
|
| 685 |
+
# File upload section
|
| 686 |
st.markdown("#### π Upload File")
|
| 687 |
+
uploaded_file = st.file_uploader(
|
| 688 |
+
"Choose a code file",
|
| 689 |
+
type=['py', 'js', 'java', 'cpp', 'c', 'cs', 'go', 'rs', 'php', 'rb', 'swift', 'kt', 'txt'],
|
| 690 |
+
help="Upload code files for AI analysis"
|
| 691 |
+
)
|
| 692 |
+
|
| 693 |
+
code_from_file = ""
|
| 694 |
+
if uploaded_file is not None:
|
| 695 |
+
# Read file content
|
| 696 |
+
try:
|
| 697 |
+
code_from_file = str(uploaded_file.read(), "utf-8")
|
| 698 |
+
file_size = len(code_from_file)
|
| 699 |
+
file_lines = len(code_from_file.splitlines())
|
| 700 |
+
|
| 701 |
+
st.markdown(f"""
|
| 702 |
+
<div class="file-info">
|
| 703 |
+
β
<strong>File Uploaded Successfully</strong><br>
|
| 704 |
+
π <strong>Name:</strong> {uploaded_file.name}<br>
|
| 705 |
+
π <strong>Size:</strong> {file_size} bytes<br>
|
| 706 |
+
π <strong>Lines:</strong> {file_lines}<br>
|
| 707 |
+
π <strong>Status:</strong> Ready for analysis
|
| 708 |
+
</div>
|
| 709 |
+
""", unsafe_allow_html=True)
|
| 710 |
+
|
| 711 |
+
# Auto-populate the text area
|
| 712 |
+
st.session_state.code_input = code_from_file
|
| 713 |
+
|
| 714 |
+
except UnicodeDecodeError:
|
| 715 |
+
st.error("π¨ File encoding error: Please use UTF-8 encoded files")
|
| 716 |
+
except Exception as e:
|
| 717 |
+
st.error(f"π¨ File read error: {str(e)}")
|
| 718 |
+
|
| 719 |
+
# Code input with modern styling
|
| 720 |
+
code_input = st.text_area(
|
| 721 |
+
"Or paste your code here",
|
| 722 |
+
value=st.session_state.get('code_input', ''),
|
| 723 |
+
height=350,
|
| 724 |
+
key="code_input",
|
| 725 |
+
help="Paste code directly or upload file above"
|
| 726 |
+
)
|
| 727 |
+
|
| 728 |
+
# Modern analyze button
|
| 729 |
+
analyze_button = st.button(
|
| 730 |
+
"π Analyze Code",
|
| 731 |
+
type="primary",
|
| 732 |
+
help="Analyze your code with AI"
|
| 733 |
+
)
|
| 734 |
+
|
| 735 |
else: # GitHub Repository mode
|
| 736 |
st.markdown("### π¦ GitHub Analysis")
|
| 737 |
|
render.yaml
CHANGED
|
@@ -3,9 +3,9 @@ services:
|
|
| 3 |
name: llm-code-analyzer
|
| 4 |
env: python
|
| 5 |
repo: https://github.com/arun3676/ai-code-analyzer.git
|
| 6 |
-
branch:
|
| 7 |
buildCommand: pip install -r requirements.txt
|
| 8 |
-
startCommand: streamlit run
|
| 9 |
plan: free
|
| 10 |
envVars:
|
| 11 |
- key: OPENAI_API_KEY
|
|
|
|
| 3 |
name: llm-code-analyzer
|
| 4 |
env: python
|
| 5 |
repo: https://github.com/arun3676/ai-code-analyzer.git
|
| 6 |
+
branch: master
|
| 7 |
buildCommand: pip install -r requirements.txt
|
| 8 |
+
startCommand: streamlit run matrix_app.py --server.port=$PORT --server.address=0.0.0.0
|
| 9 |
plan: free
|
| 10 |
envVars:
|
| 11 |
- key: OPENAI_API_KEY
|