File size: 1,773 Bytes
ae40f24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pickle
from functions import recommend_from_dataset,summarize_and_generate
resource = pickle.load(open("resource.pkl",'rb'))


st.title("Micro-Learning Dashboard")
st.subheader('Your Ultimate Study Partner', divider= "rainbow")
st.subheader('_AI is the_ :blue[Solution] :sunglasses:')


option = st.selectbox(
   "",
   resource['topic'],
   index=None,
   placeholder="Select contact Course...",
)

user_query = st.text_input("Or Manually Type Here...")

def display_output(text_summary, userinput):
    # Display the query summary and generated text
    st.write("Your Query:", userinput)
    st.write("Micro AI: ")
    st.write(text_summary['generated_text'])
    
    # Display the related links with their topics
    st.write("Related Links:")
    for link in text_summary["related_links"]:
        topic = link.get('topic', 'No topic available')
        link_value = link.get('link', 'No link available')
        if isinstance(link_value, str):
            st.write(topic + ":")
            for sub_link in link_value.split(", "):
                st.write("- " + sub_link)
        else:
            st.write(topic + ": Link not available")

# Define the behavior when the user clicks the Submit button
if st.button("Submit"):
    if user_query:
        recommendations = recommend_from_dataset(user_query)
        text_summary = summarize_and_generate(user_query, recommendations)
        display_output(text_summary,user_query)
    elif option:
        recommendations = recommend_from_dataset(option)
        text_summary = summarize_and_generate(option, recommendations)
        display_output(text_summary,option)
    else:
        st.write("Please select a course or enter a query.")