Spaces:
Running
Running
Update app.py
#1
by
yashwanth-javvaji
- opened
app.py
CHANGED
@@ -1,29 +1,33 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
import
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
st.
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
st.
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from sentence_transformers import SentenceTransformer, util
|
4 |
+
|
5 |
+
embedder = SentenceTransformer('all-mpnet-base-v2')
|
6 |
+
|
7 |
+
st.title("iSeBetter: Semantic Issue Transformer")
|
8 |
+
st.caption("Empower Developers with Advanced AI Issue Resolution")
|
9 |
+
|
10 |
+
st.markdown('#')
|
11 |
+
|
12 |
+
st.subheader("Search for Similar Issues")
|
13 |
+
form = st.form("Search for Similar Issues")
|
14 |
+
text_input = form.text_area("Please enter the issue details",
|
15 |
+
help="Title and description of the issue could be a good start!")
|
16 |
+
|
17 |
+
if form.form_submit_button():
|
18 |
+
# Perform semantic search
|
19 |
+
query_embedding = embedder.encode(text_input, convert_to_tensor=True)
|
20 |
+
corpus_embeddings = torch.load('saved_corpus.pt')
|
21 |
+
corpus_embeddings_name = torch.load('saved_corpus_list.txt')
|
22 |
+
cos_scores = util.cos_sim(query_embedding, corpus_embeddings)[0]
|
23 |
+
top_results = torch.topk(cos_scores, k=5)
|
24 |
+
|
25 |
+
st.markdown('#')
|
26 |
+
|
27 |
+
# Display results
|
28 |
+
st.subheader("Top 5 Similar Issues")
|
29 |
+
st.divider()
|
30 |
+
for score, idx in zip(top_results[0], top_results[1]):
|
31 |
+
st.write(corpus_embeddings_name[idx])
|
32 |
+
st.progress(score.item(), f"Score: {score:.4f}")
|
33 |
+
st.divider()
|