Amazing-Python-Scripts

Форк
0
65 строк · 1.8 Кб
1
import streamlit as st
2
from utils import generate_script
3

4
# Applying Styling
5
st.markdown("""
6
<style>
7
div.stButton > button:first-child {
8
    background-color: #0099ff;
9
    color:#ffffff;
10
}
11
div.stButton > button:hover {
12
    background-color: #00ff00;
13
    color:#FFFFFF;
14
    }
15
</style>""", unsafe_allow_html=True)
16

17

18
# Creating Session State Variable
19
if 'API_Key' not in st.session_state:
20
    st.session_state['API_Key'] = ''
21

22

23
st.title('❤️ YouTube Script Writing Tool')
24

25
# Sidebar to capture the OpenAi API key
26
st.sidebar.title("😎🗝️")
27
st.session_state['API_Key'] = st.sidebar.text_input(
28
    "What's your API key?", type="password")
29
st.sidebar.image('./Youtube.jpg', width=300, use_column_width=True)
30

31

32
# Captures User Inputs
33
# The box for the text prompt
34
prompt = st.text_input('Please provide the topic of the video', key="prompt")
35
# The box for the text prompt
36
video_length = st.text_input(
37
    'Expected Video Length 🕒 (in minutes)', key="video_length")
38
creativity = st.slider(
39
    'Words limit ✨ - (0 LOW || 1 HIGH)', 0.0, 1.0, 0.2, step=0.1)
40

41
submit = st.button("Generate Script for me")
42

43

44
if submit:
45

46
    if st.session_state['API_Key']:
47
        search_result, title, script = generate_script(
48
            prompt, video_length, creativity, st.session_state['API_Key'])
49
        # Let's generate the script
50
        st.success('Hope you like this script ❤️')
51

52
        # Display Title
53
        st.subheader("Title:🔥")
54
        st.write(title)
55

56
        # Display Video Script
57
        st.subheader("Your Video Script:📝")
58
        st.write(script)
59

60
        # Display Search Engine Result
61
        st.subheader("Check Out - DuckDuckGo Search:🔍")
62
        with st.expander('Show me 👀'):
63
            st.info(search_result)
64
    else:
65
        st.error("Ooopssss!!! Please provide API key.....")
66

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.