“Create a Streamlit app called ‘GitHub Issue Recommender’ that helps users find similar GitHub issues using a pre-trained neural network. The app should have the following functionality and layout: • A text input field for users to search GitHub issues by keyword (case-insensitive). • A dropdown to select a specific issue from the search results. • A slider to adjust the number of recommendations to display (between 1 and 10, default 5). • Display the top recommendations in a table showing the index, similarity score, and issue title. • Include a bar chart to visualize the similarity scores of the top recommendations. • Use Plotly for the bar chart visualization. The app should be clean, responsive, and intuitive, with concise labels and a clear workflow. Use Python and Streamlit best practices to generate the code.”
To upload files, please first save the app
import streamlit as st
import plotly.express as px
# from issue_recommender import GithubIssueRecommender
st.set_page_config(page_title="GitHub Issue Recommender", layout="wide")
# Initialize the recommender system
@st.cache_resource
def load_recommender():
return GithubIssueRecommender()
recommender = load_recommender()
# App title and description
st.title("GitHub Issue Recommender")
st.markdown("""
This app helps you find similar GitHub issues using a pre-trained neural network.
Enter a keyword to search for issues, then select a specific issue to get recommendations.
""")
# Search input
search_query = st.text_input("Search GitHub issues by keyword", "").lower()
if search_query:
# Get search results
search_results = recommender.search_issues(search_query)
if search_results:
# Issue selection dropdown
issue_options = {f"{issue['title']} (#{issue['number']})": idx
for idx, issue in enumerate(search_results)}
selected_issue = st.selectbox(
"Select an issue to find similar ones",
options=list(issue_options.keys())
)
# Number of recommendations slider
num_recommendations = st.slider(
"Number of recommendations",
min_value=1,
max_value=10,
value=5
)
if selected_issue:
# Get recommendations
issue_idx = issue_options[selected_issue]
recommendations = recommender.get_recommendations(
search_results[issue_idx],
n_recommendations=num_recommendations
)
# Display recommendations
st.subheader("Similar Issues")
# Create DataFrame for the table
recommendations_df = pd.DataFrame(
recommendations,
columns=["Similarity Score", "Issue Title", "Issue Number", "URL"]
)
# Display table
st.dataframe(
recommendations_df[["Issue Title", "Similarity Score", "URL"]],
hide_index=False,
use_container_width=True
)
# Create bar chart
fig = px.bar(
recommendations_df,
x="Issue Title",
y="Similarity Score",
title="Similarity Scores for Recommended Issues",
labels={"Issue Title": "Issue", "Similarity Score": "Similarity"},
)
fig.update_layout(
xaxis_tickangle=-45,
showlegend=False,
height=400
)
st.plotly_chart(fig, use_container_width=True)
else:
st.info("No issues found matching your search query. Try different keywords.")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?