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()