File size: 2,915 Bytes
0ba81ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import streamlit as st
import json

from chat_ai import generate_response_for_pre_indexed_repo, generate_response_for_custom_repo

st.set_page_config(page_title="Tune AI Git Issue Chat")

if 'clicked' not in st.session_state:
    st.session_state.clicked = False


def click_button():
    st.session_state.clicked = True


with st.sidebar:
    option = st.selectbox(
        'What repo you are looking for?',
        ('Pre-Indexed', 'Custom'),
        index=None,
        placeholder="please choose an option"
    )
    if option == 'Pre-Indexed':
        option_of_repo = st.selectbox(
            'Choose any one of the pre-index repo',
            ('Tensorflow', 'Pytorch'),
            index=None,
            placeholder="please choose an option"
        )
        st.write("Select number of top issues you are looking for!")
        number_of_issues = st.number_input('Insert a number')
    elif option == 'Custom':
        repo_link = st.text_area("Please enter your public repo link!")
        st.write("Select number of top issues you are looking for!")
        number_of_issues = st.number_input('Insert a number')

    st.button("Ask Tune AI!", on_click=click_button)

if st.session_state.clicked:
    with st.spinner("Generating, It may take some minutes🫡..."):
        if option == 'Pre-Indexed' and number_of_issues:
            if option_of_repo == "Tensorflow":
                repo_choice = "Tensorflow"
            elif option_of_repo == "Pytorch":
                repo_choice = "Pytorch"
            gpt_response = generate_response_for_pre_indexed_repo(repo_choice, number_of_issues)
            if gpt_response["success"]:
                try:
                    json_data = json.loads(gpt_response["data"])
                    for issue in json_data['issues']:
                        st.markdown(f"**{issue['issue_title']}**", unsafe_allow_html=True)
                        st.write("Rating:", issue['rating']['type'])
                        st.write("Description:", issue['rating']['description'])
                except:
                    st.json(gpt_response["data"])
            else:
                st.write("Sorry we encountered some issues!")
        elif option == 'Custom' and number_of_issues and repo_link:
            gpt_response = generate_response_for_custom_repo(number_of_issues, repo_link)
            if gpt_response["success"]:
                try:
                    json_data = json.loads(gpt_response["data"])
                    for issue in json_data['issues']:
                        st.markdown(f"**{issue['issue_title']}**", unsafe_allow_html=True)
                        st.write("Rating:", issue['rating']['type'])
                        st.write("Description:", issue['rating']['description'])
                except:
                    st.json(gpt_response["data"])
            else:
                st.write("Sorry we encountered some issues!")