Team Ai
Apppublic

broductmanager/scriptmaven

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
eduPlan.py86 linesDownload Raw Back to root
1 2 3 4import streamlit as st5from langchain import PromptTemplate6from langchain.llms import OpenAI7import math8 9 10# LLM loading function11def load_LLM(openai_api_key):12    llm = OpenAI(openai_api_key=openai_api_key)13    return llm14 15 16# Generate content plan with GPT-317def generate_content_plan(llm, content_input, video_length, video_style, tone):18    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}19    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}20    Each section should be described as a JSON-like object: {{ "Title": "section_title", "Description": "description", "Duration": "duration in seconds" }}21 22 23 24 25    """26    content_plan = llm(prompt)27    return content_plan28# Generate detailed content for each section29def generate_detailed_content(llm, content_input, video_length, video_style, tone, content_type, content_plan):30    prompt = f"""Based on the content plan provided below, create a detailed script for a {video_length}-minute video:31    Content Plan: {content_plan}32 33    Please note:34    - 'Title' refers to the title of the section.35    - 'Description' refers to a brief overview of the section.36    - 'Duration' refers to the time allocated to each section in seconds.37 38    The script should include:39    - Introductory lines for each section40    - Key points for each section41    - Data or examples to support key points42    - Transitions between sections43    - A closing statement44 45    Additional Context:46    - Content Type: {content_type}47    - Video Style: {video_style}48    - Target Audience: {tone}49    - Base Article: {content_input}50    """51    52    detailed_content = llm(prompt)53    return detailed_content54 55 56 57# Streamlit UI58st.set_page_config(page_title="ScriptMaven📜🧠", page_icon=":robot:")59st.header("ScriptMaven 📜🧠: Your Edu-Video Blueprint")60 61 62openai_api_key = st.text_input("OpenAI API Key", "Ex: sk-2twmA8tfCb8un4...")63video_style = st.selectbox('Video Style:', ('YouTube', 'Corporate'))64tone = st.selectbox('Tone:', ('For Students', 'Director Level', 'New Employee Level', 'CEO Level', 'For Teens'))65video_length = st.selectbox('Video Length:', ('5', '10m', '15m', '20m', '30m'))66content_type = st.selectbox('Content Type:', ('Case Study', 'Masterclass', 'Documentary', 'How-to Videos', 'Coding', 'Summary', 'Review'))67content_input = st.text_area("Content Input", "Your content...")68 69 70# Generate plan button71# ...72# Generate Content Plan Button73if st.button("Generate Plan"):74    llm = load_LLM(openai_api_key=openai_api_key)75    content_plan = generate_content_plan(llm, content_input, video_length, video_style, tone)76 77    # Display the generated plan78    st.write("Generated Content Plan:")79    st.write(content_plan)80 81    # Pass the generated content_plan directly into the next prompt82    detailed_content = generate_detailed_content(llm, content_plan, content_input, video_length, video_style, tone, content_type)83    84    st.write("Generated Detailed Scripts:")85    st.write(detailed_content)86