-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
49 lines (32 loc) · 1.66 KB
/
Copy pathapp.py
File metadata and controls
49 lines (32 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import streamlit as st
import os
from clone_repo import clone_repo
from load_split import load_code_files, split_code
from buildvector_faiss import build_vector_store, query_faiss
from analyze_code import analyze_code_with_llm
from save_output import save_output
st.set_page_config(page_title="Code Analyzer tool using LLM", layout="wide")
st.title("📊Code Analyzer tool using LLM")
repo_url = st.text_input("🔗 Enter GitHub repository URL:", "https://github.com/janjakovacevic/SakilaProject")
local_folder = repo_url.split('/')[-1]
if st.button("📥 Clone Repository"):
clone_repo(repo_url, local_folder)
st.success(f"Repository cloned to `{local_folder}/`")
if os.path.exists(local_folder):
st.write("✅ Repository found. Loading Java files...")
code_files = load_code_files(local_folder)
all_chunks = []
for _, code in code_files:
all_chunks.extend(split_code(code))
st.write(f"🔍 Loaded and split **{len(code_files)}** Java files into **{len(all_chunks)}** chunks.")
index, _ = build_vector_store(all_chunks)
user_query = st.text_input("❓ What would you like to know about the project?", "Give me an overview and key methods.")
if st.button("🔎 Analyze Code"):
top_chunks = query_faiss(index, all_chunks, user_query)
structured_summary = analyze_code_with_llm(top_chunks)
save_output(structured_summary)
st.subheader("📋 Analysis Result")
st.json(structured_summary)
st.success("✅ Analysis complete and saved to `output.json`")
else:
st.warning("⚠️ Please clone a repository first.")