Spaces:
Sleeping
Sleeping
Upload load_pages.py
Browse files75 unmodified lines7677787980818283848586879 unmodified lines97989910010110210358 unmodified lines16216316416516616716816917017117217317417517617717833 unmodified lines21221321421521621721875 unmodified lines# st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto", *, use_container_width=False)st.image(file_str, width=700) #800elif line[:len("Code: ")]=="Code: ":file_str = line[len("Code: "):].strip()with st.expander(label = "Code for this lesson ...", expanded=True, icon=":material/terminal:"):st.markdown(file_str)elif line[:len("HTML: ")]=="HTML: ":print("HTML ",input_directory)9 unmodified linesexcept Exception as err:print(f"Unexpected {err=}, {type(err)=}",file_str)else:components.html(html_str, height=700, width=700, scrolling=True)elif line[:len("Link: ")]=="Link: ":file_str = line[len("Link: "):].strip()58 unmodified linescontent_str = open(os.path.join(input_directory,"Overview.txt"), "r", encoding="UTF-8").read()tab_content = content_str.split("---\n")title = tab_content[0]st.subheader(title)tab_list = ["π"+str(idx+1) for idx,x in enumerate(tab_content[1:])]tabs = st.tabs(tab_list)for idx,tab in enumerate(tabs):with tab:format_text(tab_content[idx+1], input_directory)# AI Bot Interfaceif prompt := st.chat_input("I would like to learn about ..."):AI_gen_response(prompt)33 unmodified linesst.page_link("pages/Module_08.py", label="Dimensionality Reduction and Feature Selection", icon="πͺ")st.page_link("pages/Module_09.py", label="Clustering and User Segmentation", icon="πͺ")st.page_link("pages/Module_10.py", label="Model Improvement and Ethical Considerations", icon="βοΈ")st.page_link("pages/Module_11.py", label="Real-World Deployment and Use Cases", icon="π")with st.expander("Your Profile", expanded=False, icon=":material/settings_accessibility:"):profile_str = open(os.path.join(st.session_state["start_dir"],"pages","assets","profile.txt"), "r", encoding="UTF-8").read()75 unmodified lines767778798081828384858687888990919293949 unmodified lines10410510610710810911058 unmodified lines16917017117217317417517617717817918018118218318418518618718818919019119233 unmodified lines22622722822923023123223375 unmodified lines# st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto", *, use_container_width=False)st.image(file_str, width=700) #800elif line[:len("iframe: ")]=="iframe: ":print("Running iframe")file_str = line[len("iframe: "):].strip() # Get web sitefile_str = file_str[1:-1] # Remove string delimitersprint("Loading iframe:",file_str)components.iframe(file_str,500,500)elif line[:len("Code: ")]=="Code: ":file_str = line[len("Code: "):].strip()with st.expander(label = "Code for this lesson ...", expanded=True, icon=":material/terminal:"):st.markdown(file_str)elif line[:len("HTML: ")]=="HTML: ": # An HTML page - eg Web Widgetprint("HTML ",input_directory)9 unmodified linesexcept Exception as err:print(f"Unexpected {err=}, {type(err)=}",file_str)else:components.html(html_str, height=500, width=500, scrolling=True)elif line[:len("Link: ")]=="Link: ":file_str = line[len("Link: "):].strip()58 unmodified linescontent_str = open(os.path.join(input_directory,"Overview.txt"), "r", encoding="UTF-8").read()tab_content = content_str.split("---\n")# Display Module title if one is given, otherwise blanktitle = tab_content[0].strip()if len(title)>0:st.subheader(title)# Draw tabs according to page counttab_list = ["π"+str(idx+1) for idx,x in enumerate(tab_content[1:])]tabs = st.tabs(tab_list)# For each tab, render the appropriate contentfor idx,tab in enumerate(tabs):with tab:format_text(tab_content[idx+1], input_directory)# Add AI Bot Interface to bottom of pageif prompt := st.chat_input("I would like to learn about ..."):AI_gen_response(prompt)33 unmodified linesst.page_link("pages/Module_08.py", label="Dimensionality Reduction and Feature Selection", icon="πͺ")st.page_link("pages/Module_09.py", label="Clustering and User Segmentation", icon="πͺ")st.page_link("pages/Module_10.py", label="Model Improvement and Ethical Considerations", icon="βοΈ")st.page_link("pages/Module_11.py", label="Real-World Deployment and Use Cases", icon="π")st.page_link("pages/Bonus.py", label="Bonus Content", icon="π")with st.expander("Your Profile", expanded=False, icon=":material/settings_accessibility:"):profile_str = open(os.path.join(st.session_state["start_dir"],"pages","assets","profile.txt"), "r", encoding="UTF-8").read()
pages/load_pages.py+21-6