File size: 3,490 Bytes
6f27a32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
77
78
import LLM_Helper
import streamlit as st
import UI_Helper
from PIL import Image

# Page icon
icon = Image.open('logo.png')

# Page config
st.set_page_config(page_title="Book Name Genrator",
                   page_icon=icon,
                   layout="wide"
                   )

company_logo_path = 'logo.png'
st.image(company_logo_path, width=50)

st.title("Book Name Generator")
#st.sidebar.title("What you want")

def main():
    global submitted, prompt, selected_values2, response
    selected_value1 = UI_Helper.radio_button()
    if selected_value1 == '':
        submitted = st.button('Submit')
    elif selected_value1 == 'Education':
        input_text = UI_Helper.text_box()
        selected_value3 = UI_Helper.radio_button2()
        if input_text == '':
            response = LLM_Helper.Book_Name1(selected_value1)
            design = "#" * (len(response)*2)
            #prompt = f"I want to read a book related to Education, Give me one name only with year with writer name."
            submitted = st.button('Submit')
        else:
            if selected_value3 == 'All':
                response = LLM_Helper.Book_Name2(selected_value1,input_text)
                design = "#" * (len(response)*2)
                #prompt = f"I want to read a book related to Education and the topic i want is {input_text}, Give me one name only with year with writer name."
                submitted = st.button('Submit')
            else:
                entered_number = UI_Helper.number_input()
                response = LLM_Helper.Book_Name3(selected_value1,input_text,entered_number)
                design = "#" * (len(response)*2)
                #prompt = f"I want to read a book of Education related to {input_text} published in {entered_number}, Give me one name only with year with writer name."
                submitted = st.button('Submit')
    elif selected_value1 == 'Non Education':
        selected_values2 = UI_Helper.dropdown_with_checkbox()
        selected_value3 = UI_Helper.radio_button2()
        if selected_value3 == 'All':
            response = LLM_Helper.Book_Name4(selected_value1,selected_values2)
            design = "#" * (len(response)*2)
            #prompt = f"I want to read a book of combined genres like {', '.join(selected_values2)}, Give me one name only with year with writer name."
            submitted = st.button('Submit')
        else:
            entered_number = UI_Helper.number_input()
            response = LLM_Helper.Book_Name5(selected_value1,selected_values2,entered_number)
            design = "#" * (len(response)*2)
            #prompt = f"I want to read a book of combined genres like {', '.join(selected_values2)} published in {entered_number}, Give me one name only with year with writer name."
            submitted = st.button('Submit')


    if submitted:
        if selected_value1 == '':
            st.error(f'Plese selet either Education or Non Education')
        elif selected_value1 == 'Education':
            st.write(design)
            st.write("## " + response + " ##")
            st.write(design)
        elif selected_value1 == 'Non Education' and len(selected_values2) >= 1:
            st.write(design)
            st.write("## " + response + " ##")
            st.write(design)
        elif len(selected_values2) == 0:
            st.error('Please enter some geners name from list.')
        else:
            st.error('Something went wrong please try again.')
if __name__ == "__main__":
    main()