arun3676 commited on
Commit
76e89b2
Β·
1 Parent(s): 646ba30

Update: Add GitHub Repository analysis to matrix_app.py, fix deployment config

Browse files
Files changed (4) hide show
  1. Procfile +1 -1
  2. matrix_app.py +89 -21
  3. matrix_final.py +50 -50
  4. render.yaml +2 -2
Procfile CHANGED
@@ -1 +1 @@
1
- web: streamlit run app.py --server.port=$PORT --server.address=0.0.0.0
 
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
- st.markdown("### πŸ“Ÿ CODE_INPUT_TERMINAL")
455
-
456
- # Code input with Matrix styling
457
- code_input = st.text_area(
458
- "PASTE_TARGET_CODE",
459
- value=st.session_state.get('code_input', ''),
460
- height=400,
461
- key="code_input",
462
- help="Insert code for neural network analysis..."
463
- )
464
-
465
- # Matrix-styled analyze button
466
- analyze_button = st.button(
467
- "πŸš€ INITIATE_SCAN",
468
- type="primary",
469
- disabled=not code_input.strip(),
470
- help="Begin deep neural analysis of target code"
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 analyze_all:
480
- # Multi-model analysis
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- # 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
 
 
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: main
7
  buildCommand: pip install -r requirements.txt
8
- startCommand: streamlit run app.py --server.port=$PORT --server.address=0.0.0.0
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