frankjosh commited on
Commit
37a13eb
Β·
verified Β·
1 Parent(s): c60740f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -30
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
- # Rest of your UI code remains the same...
183
 
184
  # Main App Interface
185
- st.title("Enhanced Repository Recommender System πŸš€")
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 = generate_embedding(model, tokenizer, user_query)
225
- data['similarity'] = data['embedding'].apply(
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({