github_recap / app.py
za3karia's picture
Update app.py
bc0e66f verified
raw
history blame
7.17 kB
import streamlit as st
import reveal_slides as rs
import time
from functions import *
# Initialize session state variables if they don't exist
if 'recap_period' not in st.session_state:
st.session_state['recap_period'] = 'month'
if 'repo_type' not in st.session_state:
st.session_state['repo_type'] = 'public'
if 'private_token' not in st.session_state:
st.session_state['private_token'] = ''
if 'branch_option' not in st.session_state:
st.session_state['branch_option'] = 'all'
if 'selected_branches' not in st.session_state:
st.session_state['selected_branches'] = []
if 'selected_contributor' not in st.session_state:
st.session_state['selected_contributor'] = ''
if 'commits' not in st.session_state:
st.session_state['commits'] = []
if 'sync' not in st.session_state:
st.session_state['sync'] = False
if 'Recap' not in st.session_state:
st.session_state['Recap'] = False
if 'Summaries' not in st.session_state:
st.session_state['Summaries'] = []
if 'Summaries_state' not in st.session_state:
st.session_state['Summaries_state'] = False
markdown = r"""### Achievements
- **Implementation of New Features**: Added dynamic configuration reloading and support for more PostgreSQL versions.
- **Bug Fixes and Stability Improvements**: Resolved critical bugs for better stability and performance.
- **Documentation and Community Engagement**: Enhanced documentation and engaged with the community for support.
---
### Skills Demonstrated
**Technical Skills**:
- Proficiency in Python and SQL.
- Deep understanding of PostgreSQL and High Availability.
- Experience with Git for code management.
**Soft Skills**:
- **Problem-Solving**: Effective troubleshooting of complex issues.
- **Collaboration**: Strong teamwork and communication within the team and community.
- **Continuous Learning**: Updated knowledge on PostgreSQL and High Availability.
---
### Areas for Improvement
- **Automated Testing**: Greater contribution to automated tests could improve reliability.
- **Performance Optimization**: Focus on optimization for better efficiency in large-scale deployments.
- **Leadership in Design Discussions**: More active participation in discussions could showcase leadership and innovative thinking.
"""
if 'markdown' not in st.session_state:
st.session_state['markdown'] = "False"
# App title
st.title("GitHub Contributors Recap")
# Recap period selection
st.session_state['recap_period'] = st.selectbox("Choose recap period", options=["month", "3 months", "6 months", "year"], index=0)
# Repo type selection
st.session_state['repo_type'] = st.selectbox("Choose repo type", options=["public", "private"], index=0)
# If repo type is private, request for private token
if st.session_state['repo_type'] == "private":
st.session_state['private_token'] = st.text_input("Enter private token")
# Repository selection
st.session_state['reponame'] = st.text_input("reponame")
if st.button("sync"):
st.session_state['sync'] = True
st.session_state['Recap'] = False
st.session_state['contributors_list'] = get_contributors(st.session_state['reponame'], updated_token=st.session_state['private_token'])
st.session_state['branches_list'] = get_repo_branches(st.session_state['reponame'], updated_token=st.session_state['private_token'])
# Load button to fetch repo data (simulated with mock data)
if st.session_state['sync']:
if not st.session_state['Recap']:
st.session_state['Summaries_state'] = False
st.session_state['selected_branches'] = st.session_state['branches_list']
st.session_state['selected_contributor'] = [] # Reset selected contributor
# Branch selection
branch_option = st.radio("Select branches:", options=["all", "specific"])
if branch_option == "specific":
st.session_state['selected_branches'] = st.multiselect("Select branches", options=st.session_state['branches_list'], default=st.session_state['branches_list'])
# Contributor selection
st.session_state['selected_contributor'] = st.selectbox("Select contributor name", options=st.session_state['contributors_list'])
# Get recap button
if st.button("Get Recap"):
with st.spinner('fetching commits'):
st.session_state['commits'] = get_contributor_commits(st.session_state['reponame'], st.session_state['selected_contributor'], st.session_state['recap_period'],st.session_state['selected_branches'], updated_token=st.session_state['private_token'])
print(st.session_state['commits'])
with st.spinner('AI summarizing commits'):
st.session_state['summaries'] = process_commits_with_openai_summaries(st.session_state['commits'])
st.session_state['markdown'] = generate_contributor_report_prompt(st.session_state['summaries'])
print(st.session_state['commits'])
print(st.session_state['markdown'])
# st.session_state['markdown'] = get_markdown(st.session_state['commits'])
# st.session_state['sync'] = False
st.session_state['Recap'] = True
# print(len(st.session_state['commits']))
else:
st.session_state['Summaries_state'] = True
if st.session_state['Recap']:
# rs.slides(markdown, height=500)
rs.slides(str(st.session_state['markdown']).replace("\\", "\\\\"), height=500)
# Chat prompt (future feature)
# st.text_input("Ask any question about the contributor:", on_change=None, key="chat_prompt")
st.session_state["question"] = st.text_input("Ask any question about the contributor:", on_change=None, key="chat_prompt")
if st.button("ask"):
st.session_state["response"] = chat_complete(f"given the following summaries of this contributor's commits {str(st.session_state['summaries'])} answer the following question: {str(st.session_state['question'])}")
st.write(str(st.session_state["response"]))
# if st.session_state['Recap']:
# # get_contributor_commits(repo_name, contributor, period, updated_token=None)
# print(st.session_state['commits'])
# print(len(st.session_state['commits']))
# if st.session_state['commits']:
# st.text(str(len(st.session_state['commits'])), " commits fetched")
# else:
# with st.spinner('fetching commits'):
# st.session_state['commits'] = get_contributor_commits(st.session_state['reponame'], st.session_state['selected_contributor'], st.session_state['recap_period'],st.session_state['selected_branches'], updated_token=st.session_state['private_token'])
# print(st.session_state['commits'])
# print(len(st.session_state['commits']))
# # st.text("fetching commits")
# # Placeholder for GitHub markdown content
# rs.slides(markdown, height=500)
# # Chat prompt (future feature)
# st.text_input("Ask any question about the contributor:", on_change=None, key="chat_prompt")
# if st.button("ask"):
# st.write("Feature coming soon!")