Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -175,34 +175,12 @@ st.info(f"Running with a subset of {SUBSET_SIZE} repositories for testing purpos
|
|
175 |
# Precompute embeddings for the subset
|
176 |
data = precompute_embeddings(data, model, tokenizer)
|
177 |
|
178 |
-
# Main App Interface
|
179 |
-
st.title("Repository Recommender System π")
|
180 |
-
st.caption("Testing Version - Running on subset of data")
|
181 |
|
182 |
-
#
|
183 |
|
184 |
# Main App Interface
|
185 |
-
st.title("
|
186 |
-
|
187 |
-
# Sidebar for History and Stats
|
188 |
-
with st.sidebar:
|
189 |
-
st.header("π Search History")
|
190 |
-
if st.session_state.history:
|
191 |
-
for idx, item in enumerate(st.session_state.history[-5:]): # Show last 5 searches
|
192 |
-
with st.expander(f"Search {len(st.session_state.history)-idx}: {item['query'][:30]}..."):
|
193 |
-
st.write(f"Time: {item['timestamp']}")
|
194 |
-
st.write(f"Results: {len(item['results'])} repositories")
|
195 |
-
if st.button("Rerun this search", key=f"rerun_{idx}"):
|
196 |
-
st.session_state.rerun_query = item['query']
|
197 |
-
else:
|
198 |
-
st.write("No search history yet")
|
199 |
-
|
200 |
-
st.header("π Usage Statistics")
|
201 |
-
st.write(f"Total Searches: {len(st.session_state.history)}")
|
202 |
-
if st.session_state.feedback:
|
203 |
-
feedback_df = pd.DataFrame(st.session_state.feedback).T
|
204 |
-
feedback_df['Total'] = feedback_df['likes'] + feedback_df['dislikes']
|
205 |
-
st.bar_chart(feedback_df[['likes', 'dislikes']])
|
206 |
|
207 |
# Main interface
|
208 |
user_query = st.text_area(
|
@@ -221,11 +199,8 @@ with col2:
|
|
221 |
if search_button and user_query.strip():
|
222 |
with st.spinner("Finding relevant repositories..."):
|
223 |
# Generate query embedding and get recommendations
|
224 |
-
query_embedding =
|
225 |
-
|
226 |
-
lambda x: cosine_similarity([query_embedding], [x])[0][0]
|
227 |
-
)
|
228 |
-
recommendations = data.nlargest(top_n, 'similarity')
|
229 |
|
230 |
# Save to history
|
231 |
st.session_state.history.append({
|
|
|
175 |
# Precompute embeddings for the subset
|
176 |
data = precompute_embeddings(data, model, tokenizer)
|
177 |
|
|
|
|
|
|
|
178 |
|
179 |
+
# [Previous imports and code remain the same until the UI section]
|
180 |
|
181 |
# Main App Interface
|
182 |
+
st.title("Repository Recommender System π")
|
183 |
+
st.caption("Testing Version - Running on subset of data")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
# Main interface
|
186 |
user_query = st.text_area(
|
|
|
199 |
if search_button and user_query.strip():
|
200 |
with st.spinner("Finding relevant repositories..."):
|
201 |
# Generate query embedding and get recommendations
|
202 |
+
query_embedding = generate_query_embedding(model, tokenizer, user_query) # Fixed this line
|
203 |
+
recommendations = find_similar_repos(query_embedding, data, top_n)
|
|
|
|
|
|
|
204 |
|
205 |
# Save to history
|
206 |
st.session_state.history.append({
|