broductmanager commited on
Commit
76d190f
·
1 Parent(s): 64ea3b3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +82 -0
app.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain import PromptTemplate
3
+ from langchain.llms import OpenAI
4
+ import math
5
+
6
+
7
+ # LLM loading function
8
+ def load_LLM(openai_api_key):
9
+ llm = OpenAI(openai_api_key=openai_api_key)
10
+ return llm
11
+
12
+
13
+ # Generate content plan with GPT-3
14
+ def generate_content_plan(llm, content_input, video_length, video_style, tone):
15
+ prompt = f"""Generate a {content_type} {video_length}-minute long video content plan based on the article. Prioritize key insights and allocate time to each section based on its complexity, relevance to the overall topic, and fitting within the {video_length} time frame. Specify the time in seconds for each section. The article is as follows: {content_input}
16
+ Make sure to distribute the time effectively among sections to ensure a balanced and informative video within the specified time limit.For sections, ensure that the total duration does not exceed {video_length}. the video is for {video_style} and users are {tone}
17
+ Each section should be described as a JSON-like object: {{ "Title": "section_title", "Description": "description", "Duration": "duration in seconds" }}
18
+
19
+
20
+
21
+
22
+ """
23
+ content_plan = llm(prompt)
24
+ return content_plan
25
+ # Generate detailed content for each section
26
+ def generate_detailed_content(llm, content_input, video_length, video_style, tone, content_type, content_plan):
27
+ prompt = f"""Based on the content plan provided below, create a detailed script for a {video_length}-minute video:
28
+ Content Plan: {content_plan}
29
+
30
+ Please note:
31
+ - 'Title' refers to the title of the section.
32
+ - 'Description' refers to a brief overview of the section.
33
+ - 'Duration' refers to the time allocated to each section in seconds.
34
+
35
+ The script should include:
36
+ - Introductory lines for each section
37
+ - Key points for each section
38
+ - Data or examples to support key points
39
+ - Transitions between sections
40
+ - A closing statement
41
+
42
+ Additional Context:
43
+ - Content Type: {content_type}
44
+ - Video Style: {video_style}
45
+ - Target Audience: {tone}
46
+ - Base Article: {content_input}
47
+ """
48
+
49
+ detailed_content = llm(prompt)
50
+ return detailed_content
51
+
52
+
53
+
54
+ # Streamlit UI
55
+ st.set_page_config(page_title="ScriptMaven📜🧠", page_icon=":robot:")
56
+ st.header("ScriptMaven 📜🧠: Your Edu-Video Blueprint")
57
+
58
+
59
+ openai_api_key = st.text_input("OpenAI API Key", placeholder="Ex: sk-2twmA8tfCb8un4...")
60
+ video_style = st.selectbox('Video Style:', ('YouTube', 'Corporate'))
61
+ tone = st.selectbox('Tone:', ('For Students', 'College student', 'New Employee', 'CxO Level', 'For Teens'))
62
+ video_length = st.selectbox('Video Length:', ('5', '10m', '15m', '20m', '30m'))
63
+ content_type = st.selectbox('Content Type:', ('Case Study', 'Masterclass', 'Documentary', 'How-to Videos', 'Coding', 'Summary', 'Review'))
64
+ content_input = st.text_area("Content Input", placeholder="Your content deserves to be here...")
65
+
66
+
67
+ # Generate plan button
68
+ # ...
69
+ # Generate Content Plan Button
70
+ if st.button("Generate Plan"):
71
+ llm = load_LLM(openai_api_key=openai_api_key)
72
+ content_plan = generate_content_plan(llm, content_input, video_length, video_style, tone)
73
+
74
+ # Display the generated plan
75
+ st.write("Generated Content Plan:")
76
+ st.write(content_plan)
77
+
78
+ # Pass the generated content_plan directly into the next prompt
79
+ detailed_content = generate_detailed_content(llm, content_plan, content_input, video_length, video_style, tone, content_type)
80
+
81
+ st.write("Generated Detailed Scripts:")
82
+ st.write(detailed_content)