Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7859c6a

Browse files
Merge pull request avinashkranjan#2509 from avinashkranjan/deepsource-transform-8ed010ff
format code with autopep8
2 parents 020684c + 248db18 commit 7859c6a

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

‎YT Script Writing Tool/app.py‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import streamlit as st
1+
import streamlit as st
22
from utils import generate_script
33

44
# Applying Styling
@@ -17,43 +17,49 @@
1717

1818
# Creating Session State Variable
1919
if 'API_Key' not in st.session_state:
20-
st.session_state['API_Key'] =''
20+
st.session_state['API_Key'] =''
2121

2222

23-
st.title('❤️ YouTube Script Writing Tool')
23+
st.title('❤️ YouTube Script Writing Tool')
2424

2525
# Sidebar to capture the OpenAi API key
2626
st.sidebar.title("😎🗝️")
27-
st.session_state['API_Key']= st.sidebar.text_input("What's your API key?",type="password")
28-
st.sidebar.image('./Youtube.jpg',width=300, use_column_width=True)
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)
2930

3031

3132
# Captures User Inputs
32-
prompt = st.text_input('Please provide the topic of the video',key="prompt") # The box for the text prompt
33-
video_length = st.text_input('Expected Video Length 🕒 (in minutes)',key="video_length") # The box for the text prompt
34-
creativity = st.slider('Words limit ✨ - (0 LOW || 1 HIGH)', 0.0, 1.0, 0.2,step=0.1)
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)
3540

3641
submit = st.button("Generate Script for me")
3742

3843

3944
if submit:
40-
45+
4146
if st.session_state['API_Key']:
42-
search_result,title,script = generate_script(prompt,video_length,creativity,st.session_state['API_Key'])
43-
#Let's generate the script
47+
search_result, title, script = generate_script(
48+
prompt, video_length, creativity, st.session_state['API_Key'])
49+
# Let's generate the script
4450
st.success('Hope you like this script ❤️')
4551

46-
#Display Title
52+
#Display Title
4753
st.subheader("Title:🔥")
4854
st.write(title)
4955

50-
#Display Video Script
56+
#Display Video Script
5157
st.subheader("Your Video Script:📝")
5258
st.write(script)
5359

54-
#Display Search Engine Result
60+
#Display Search Engine Result
5561
st.subheader("Check Out - DuckDuckGo Search:🔍")
56-
with st.expander('Show me 👀'):
62+
with st.expander('Show me 👀'):
5763
st.info(search_result)
5864
else:
59-
st.error("Ooopssss!!! Please provide API key.....")
65+
st.error("Ooopssss!!! Please provide API key.....")

‎YT Script Writing Tool/utils.py‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,40 @@
44
from langchain.tools import DuckDuckGoSearchRun
55

66
# Function to generate video script
7-
def generate_script(prompt,video_length,creativity,api_key):
8-
7+
8+
9+
def generate_script(prompt, video_length, creativity, api_key):
10+
911
# Template for generating 'Title'
1012
title_template = PromptTemplate(
11-
input_variables=['subject'],
13+
input_variables=['subject'],
1214
template='Please come up with a title for a YouTube video on the {subject}.'
13-
)
15+
)
1416

1517
# Template for generating 'Video Script' using search engine
1618
script_template = PromptTemplate(
17-
input_variables=['title', 'DuckDuckGo_Search','duration'],
19+
input_variables=['title', 'DuckDuckGo_Search','duration'],
1820
template='Create a script for a YouTube video based on this title for me. TITLE: {title} of duration: {duration} minutes using this search data {DuckDuckGo_Search} '
1921
)
2022

21-
#Setting up OpenAI LLM
22-
llm = OpenAI(temperature=creativity,openai_api_key=api_key,
23-
model_name='gpt-3.5-turbo')
24-
25-
#Creating chain for 'Title' & 'Video Script'
23+
#Setting up OpenAI LLM
24+
llm = OpenAI(temperature=creativity,openai_api_key=api_key,
25+
model_name='gpt-3.5-turbo')
26+
27+
#Creating chain for 'Title' & 'Video Script'
2628
title_chain = LLMChain(llm=llm, prompt=title_template, verbose=True)
2729
script_chain = LLMChain(llm=llm, prompt=script_template, verbose=True)
2830

29-
3031
# https://python.langchain.com/docs/modules/agents/tools/integrations/ddg
3132
search = DuckDuckGoSearchRun()
3233

3334
# Executing the chains we created for 'Title'
3435
title = title_chain.run(prompt)
3536

3637
# Executing the chains we created for 'Video Script' by taking help of search engine 'DuckDuckGo'
37-
search_result = search.run(prompt)
38-
script = script_chain.run(title=title, DuckDuckGo_Search=search_result,duration=video_length)
38+
search_result = search.run(prompt)
39+
script = script_chain.run(
40+
title=title, DuckDuckGo_Search=search_result, duration=video_length)
3941

4042
# Returning the output
41-
return search_result,title,script
43+
return search_result,title,script

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /