Spaces:
Sleeping
Sleeping
| import streamlit as Xu1_s_YRKyqBPG3Rtk | |
| import streamlit.components.v1 as FGLj98Tj6htb62 | |
| import requests as YKOZ_a8m0IIteB | |
| import os as jaXQLEPpNYN7fZESeln | |
| import time as lcPr1_RGGQ2u | |
| import streamlit as ppc5pYLQY3Wy | |
| import base64 as lZWuvN67Tq1Oajrh | |
| from streamlit_mic_recorder import mic_recorder as CzoBrxqsRXK9KL_a | |
| from notion_client import Client as NRO13Z5uLx6R_Si | |
| import pandas as jCokbZAoxaSH | |
| g6arVBaEwweAfW = 'drinktoomuchsax/whisper-small-hi' | |
| hmKkYB0Vy36V_5 = 'en' | |
| from threading import Thread as f3eMfSGlpjm | |
| jaXQLEPpNYN7fZESeln.environ['COQUI_TOS_AGREED'] = '1' | |
| jaXQLEPpNYN7fZESeln.environ['TRAINER_TELEMETRY'] = '0' | |
| kOSXYC9sqLGQY1 = jaXQLEPpNYN7fZESeln.environ.get('HF_TOKEN', None) | |
| YUdSktaTyqsUjKc7Tp = jaXQLEPpNYN7fZESeln.environ.get('BASETEN_API', None) | |
| JZKqaWbvk3ke5VhmDPFa = jaXQLEPpNYN7fZESeln.environ.get('BASETEN_KEY', None) | |
| vw0Pfd841JokahKHG = jaXQLEPpNYN7fZESeln.environ.get('NOTION_API_KEY', None) | |
| x9in5mTsHJo = jaXQLEPpNYN7fZESeln.environ.get('NOTION_DB_ID', None) | |
| wHoUZ_TWQ5 = NRO13Z5uLx6R_Si(auth=f'{vw0Pfd841JokahKHG}') | |
| D2L9ohN562 = f'{x9in5mTsHJo}' | |
| mUlXNhmWaZ4.set_page_config(layout='wide') | |
| mUlXNhmWaZ4.markdown('\n <link href="https://fonts.googleapis.com/css?family=Amatic+SC:400,700|Dosis:400,500,700&subset=latin,latin-ext" rel="stylesheet">\n <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">\n <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">\n <style>\n body {\n font-family: \'Dosis\', sans-serif;\n }\n h1, h2, h3 {\n font-family: \'Amatic SC\', cursive;\n }\n .calculator button {\n width: 100%;\n padding: 20px;\n font-size: 24px;\n margin: 5px;\n }\n </style>\n', unsafe_allow_html=True) | |
| mUlXNhmWaZ4.markdown('<h1 class="display-4 text-center">My Streamlit Application</h1><p class="lead text-center">Integrating Streamlit with Bootstrap Carousel</p>', unsafe_allow_html=True) | |
| iZUZOs4rLk1ngHu, vdScuo8h42VU4Lc, zqq2ZomNZnpltfYQVG = mUlXNhmWaZ4.columns([3, 3, 3]) | |
| with iZUZOs4rLk1ngHu: | |
| mUlXNhmWaZ4.markdown('<h3><i class="fa fa-calculator"></i> Calculator</h3>', unsafe_allow_html=True) | |
| Tstven2mcRzUMKBBJ = [['7', '8', '9', '/'], ['4', '5', '6', '\\*'], ['1', '2', '3', '\\-'], ['C', '0', '.', '\\+'], ['=']] | |
| if 'calc_input' not in mUlXNhmWaZ4.session_state: | |
| mUlXNhmWaZ4.session_state.calc_input = '' | |
| def J9MON3lkNKkvdDlLXQv1(VU6Ayctj5YBYuOgvGg0): | |
| VU6Ayctj5YBYuOgvGg0 = VU6Ayctj5YBYuOgvGg0.replace('\\', '') | |
| try: | |
| athlnHoJS0oDHiuH = eval(VU6Ayctj5YBYuOgvGg0) | |
| return str(athlnHoJS0oDHiuH) | |
| except ZeroDivisionError: | |
| return 'Error: Division by zero' | |
| except Exception: | |
| return 'Error' | |
| for uMvxfOPTjWHGImIb in Tstven2mcRzUMKBBJ: | |
| hfJXWtwczPea2YLmu = mUlXNhmWaZ4.columns(len(uMvxfOPTjWHGImIb)) | |
| for s_7ZN_0n1PrKfPIwpqJj, lNFeoCtqUXOy2c in enumerate(uMvxfOPTjWHGImIb): | |
| if lNFeoCtqUXOy2c and hfJXWtwczPea2YLmu[s_7ZN_0n1PrKfPIwpqJj].button(lNFeoCtqUXOy2c): | |
| if lNFeoCtqUXOy2c == '=': | |
| mUlXNhmWaZ4.session_state.calc_input = J9MON3lkNKkvdDlLXQv1(mUlXNhmWaZ4.session_state.calc_input) | |
| elif lNFeoCtqUXOy2c == 'C': | |
| mUlXNhmWaZ4.session_state.calc_input = '' | |
| else: | |
| mUlXNhmWaZ4.session_state.calc_input += lNFeoCtqUXOy2c.replace('\\', '') | |
| mUlXNhmWaZ4.text_input('Calculation', mUlXNhmWaZ4.session_state.calc_input, key='display', disabled=True) | |
| with vdScuo8h42VU4Lc: | |
| mUlXNhmWaZ4.markdown('<h3><i class="fa fa-image"></i> Gen Image</h3>', unsafe_allow_html=True) | |
| lWipDlsimjcQkHxm = f'{JZKqaWbvk3ke5VhmDPFa}' | |
| mUnZAiZho9J9HbpX = mUlXNhmWaZ4.text_input('Negative Prompt', 'blurry, text, low quality') | |
| L8kiwV6VFlV = mUlXNhmWaZ4.text_input('Positive Prompt', 'An igloo on a snowy day, 4k, hd') | |
| PnkIkPhMCssU5 = mUlXNhmWaZ4.text_input('ControlNet Image URL', 'https://storage.googleapis.com/logos-bucket-01/baseten_logo.png') | |
| if mUlXNhmWaZ4.button('Generate Prompt'): | |
| LUTP9A6agfaJg = YKOZ_a8m0IIteB.post('https://model-7wlx9oew.api.baseten.co/production/predict', headers={'Authorization': f'Api-Key {lWipDlsimjcQkHxm}'}, json={'workflow_values': {'negative_prompt': mUnZAiZho9J9HbpX, 'positive_prompt': L8kiwV6VFlV, 'controlnet_image': PnkIkPhMCssU5}}) | |
| if LUTP9A6agfaJg.status_code == 200: | |
| athlnHoJS0oDHiuH = LUTP9A6agfaJg.json().get('result') | |
| if athlnHoJS0oDHiuH: | |
| GcwRbIkSJLQFwB_gQllf = athlnHoJS0oDHiuH[0].get('data') | |
| if GcwRbIkSJLQFwB_gQllf: | |
| e_wUUpvS8VU7tXTD2bU0 = lZWuvN67Tq1Oajrh.b64decode(GcwRbIkSJLQFwB_gQllf) | |
| mUlXNhmWaZ4.image(e_wUUpvS8VU7tXTD2bU0, caption='Generated Image', use_column_width=True) | |
| else: | |
| mUlXNhmWaZ4.error('No image data found in the response.') | |
| else: | |
| mUlXNhmWaZ4.error('No result found in the response.') | |
| else: | |
| mUlXNhmWaZ4.error(f'Error: {LUTP9A6agfaJg.status_code}, {LUTP9A6agfaJg.text}') | |
| with zqq2ZomNZnpltfYQVG: | |
| mUlXNhmWaZ4.markdown('<h3><i class="fa fa-pencil"></i> Chat with Mistral</h3>', unsafe_allow_html=True) | |
| GmV4HbtNJj = mUlXNhmWaZ4.text_input('Enter Prompt', key='prompt3', value='Why is Sky Blue?') | |
| if mUlXNhmWaZ4.button('Submit', key='submit3'): | |
| PymA0olldX4 = {'prompt': GmV4HbtNJj} | |
| ECd6h8vVwG3X8i0 = {'Authorization': f'Api-Key {JZKqaWbvk3ke5VhmDPFa}'} | |
| LUTP9A6agfaJg = YKOZ_a8m0IIteB.post(f'{YUdSktaTyqsUjKc7Tp}', headers=ECd6h8vVwG3X8i0, json=PymA0olldX4) | |
| if LUTP9A6agfaJg.status_code == 200: | |
| mUlXNhmWaZ4.write(f'**Response:** {LUTP9A6agfaJg.json()}') | |
| else: | |
| mUlXNhmWaZ4.write('Failed to get a response') | |
| iZUZOs4rLk1ngHu, q0ArazFNq5gsvq, zqq2ZomNZnpltfYQVG = mUlXNhmWaZ4.columns([1, 3, 1]) | |
| with q0ArazFNq5gsvq: | |
| with mUlXNhmWaZ4.form(key='data_entry_form'): | |
| ZDkINyurNi = mUlXNhmWaZ4.text_input('Name') | |
| TzvwY1x5YPa = mUlXNhmWaZ4.number_input('Age', min_value=0) | |
| bKE8a3tiZnQYsW = mUlXNhmWaZ4.text_input('Location') | |
| i4WtDCNwkaoqf75U = mUlXNhmWaZ4.form_submit_button(label='Submit') | |
| def qUAmCp2ARaYU(ZDkINyurNi, TzvwY1x5YPa, bKE8a3tiZnQYsW): | |
| pLOTJqAxCJUz = {'Name': {'title': [{'text': {'content': ZDkINyurNi}}]}, 'Age': {'number': TzvwY1x5YPa}, 'Location': {'rich_text': [{'text': {'content': bKE8a3tiZnQYsW}}]}} | |
| wHoUZ_TWQ5.pages.create(parent={'database_id': D2L9ohN562}, properties=pLOTJqAxCJUz) | |
| if i4WtDCNwkaoqf75U: | |
| qUAmCp2ARaYU(ZDkINyurNi, TzvwY1x5YPa, bKE8a3tiZnQYsW) | |
| mUlXNhmWaZ4.success('Data submitted to Notion!') | |
| def sI9qDd8eeYG9r6w9j(): | |
| XVjjwr7OVLvdtQLHuZI = wHoUZ_TWQ5.databases.query(database_id=D2L9ohN562) | |
| BDRUGpilyt = [] | |
| for athlnHoJS0oDHiuH in XVjjwr7OVLvdtQLHuZI['results']: | |
| ZDkINyurNi = athlnHoJS0oDHiuH['properties']['Name']['title'][0]['text']['content'] if athlnHoJS0oDHiuH['properties']['Name']['title'] else 'No Name' | |
| TzvwY1x5YPa = athlnHoJS0oDHiuH['properties']['Age']['number'] if athlnHoJS0oDHiuH['properties']['Age']['number'] is not None else 'No Age' | |
| bKE8a3tiZnQYsW = athlnHoJS0oDHiuH['properties']['Location']['rich_text'][0]['text']['content'] if athlnHoJS0oDHiuH['properties']['Location']['rich_text'] else 'No Location' | |
| BDRUGpilyt.append({'Name': ZDkINyurNi, 'Age': TzvwY1x5YPa, 'Location': bKE8a3tiZnQYsW}) | |
| return ATX4t7wg934Howfn.DataFrame(BDRUGpilyt) | |
| mUlXNhmWaZ4.subheader('Stored Data') | |
| gMoI0_JhjNG = sI9qDd8eeYG9r6w9j() | |
| mUlXNhmWaZ4.table(gMoI0_JhjNG) | |
| l1q117tznAWJz7 = '\n <style>\n #MainMenu {visibility: hidden; }\n footer {visibility: hidden;}\n header {visibility: hidden;}\n </style>\n ' | |
| mUlXNhmWaZ4.markdown(l1q117tznAWJz7, unsafe_allow_html=True) | |