denisp1/AI-Quantum
1
1import streamlit as st 2import gradio as gr3import IPython4import streamlit as st5import streamlit.components.v1 as components6from IPython.display import IFrame7 8#quantum imports:9import qiskit10from qiskit import QuantumCircuit, QuantumRegister, execute11 12src='' # URL parameter to change the iframe url13 14def SetIframeURL(option_selected):15 if (option_selected=='QCEngine'):16 src='https://oreilly-qc.github.io?p=2-1'17 if (option_selected=='Grok'):18 src='https://javafxpert.github.io/grok-bloch/'19 if (option_selected=='Playground'):20 src='https://davidbkemp.github.io/quantum-gate-playground/'21 if (option_selected=='Circuit'):22 src='https://algassert.com/quirk#circuit={%22cols%22:[[%22H%22],[%22Bloch%22],[%22Measure%22]]}'23 24 # Render iframe contents25 #st.set_page_config(layout="wide")26 width = st.sidebar.slider("Width", 200, 1500, 800, 100)27 height = st.sidebar.slider("Height", 200, 1500, 900, 100)28 st.components.v1.iframe(src, width, height, scrolling=True)29 30# query params exist31try:32 options = ['QCEngine', 'Grok', 'Playground', 'Circuit']33 query_params = st.experimental_get_query_params()34 query_option = query_params['option'][0] #throws an exception when visiting http://host:port35 option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))36 if option_selected:37 st.experimental_set_query_params(option=option_selected)38 SetIframeURL(option_selected)39 40# run when query params don't exist. e.g on first launch41except: # catch exception and set query param to predefined value42 options = ['QCEngine', 'Grok', 'Playground', 'Circuit']43 st.experimental_set_query_params(option=options[1]) # defaults to dog44 query_params = st.experimental_get_query_params()45 query_option = query_params['option'][0]46 option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))47 if option_selected:48 st.experimental_set_query_params(option=option_selected)49 SetIframeURL(option_selected)50 51def LoadGradioAIModels():52 title = "AI Quantum - QGAN and QCEngine"53 description = "Using Superposition Advantage from Quantum for QGAN AI."54 article = "<p style='text-align: center'></p>"55 56 examples = [57 ["Scientific breakthroughs in treatment of HIV/AIDS may be solved in our lifetime using a procedure called [MASK] modulation which strengthens the immune system to fight the disease."],["A disease called [MASK] disease involves progressive memory loss and has new treatments to improve memory and delay progression of the disease."],["[MASK] refers to the uncontrolled growth of abnormal cells in the body. With chemotherapy and radiation therapy have improvements and replacements that destroy cancer cells before they become resistant to current treatment methods."],["The hereditary disease [MASK] is caused by mucus abnormally thick preventing lungs and pancreas from doing their jobs correctly."],["[MASK] or atherosclerosis is the buildup of cholesterol, fatty cells, and inflammatory deposits in the arteries. Stem cells, mechanical devices, and lowering cholesterol and blood pressure levels are helping prevention."]]58 