├── apikey.py └── app.py /apikey.py: -------------------------------------------------------------------------------- 1 | apikey = 'your apikey here' -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | # Bring in deps 2 | import os 3 | from apikey import apikey 4 | 5 | import streamlit as st 6 | from langchain.llms import OpenAI 7 | from langchain.prompts import PromptTemplate 8 | from langchain.chains import LLMChain, SequentialChain 9 | from langchain.memory import ConversationBufferMemory 10 | from langchain.utilities import WikipediaAPIWrapper 11 | 12 | os.environ['OPENAI_API_KEY'] = apikey 13 | 14 | # App framework 15 | st.title('🦜🔗 YouTube GPT Creator') 16 | prompt = st.text_input('Plug in your prompt here') 17 | 18 | # Prompt templates 19 | title_template = PromptTemplate( 20 | input_variables = ['topic'], 21 | template='write me a youtube video title about {topic}' 22 | ) 23 | 24 | script_template = PromptTemplate( 25 | input_variables = ['title', 'wikipedia_research'], 26 | template='write me a youtube video script based on this title TITLE: {title} while leveraging this wikipedia reserch:{wikipedia_research} ' 27 | ) 28 | 29 | # Memory 30 | title_memory = ConversationBufferMemory(input_key='topic', memory_key='chat_history') 31 | script_memory = ConversationBufferMemory(input_key='title', memory_key='chat_history') 32 | 33 | 34 | # Llms 35 | llm = OpenAI(temperature=0.9) 36 | title_chain = LLMChain(llm=llm, prompt=title_template, verbose=True, output_key='title', memory=title_memory) 37 | script_chain = LLMChain(llm=llm, prompt=script_template, verbose=True, output_key='script', memory=script_memory) 38 | 39 | wiki = WikipediaAPIWrapper() 40 | 41 | # Show stuff to the screen if there's a prompt 42 | if prompt: 43 | title = title_chain.run(prompt) 44 | wiki_research = wiki.run(prompt) 45 | script = script_chain.run(title=title, wikipedia_research=wiki_research) 46 | 47 | st.write(title) 48 | st.write(script) 49 | 50 | with st.expander('Title History'): 51 | st.info(title_memory.buffer) 52 | 53 | with st.expander('Script History'): 54 | st.info(script_memory.buffer) 55 | 56 | with st.expander('Wikipedia Research'): 57 | st.info(wiki_research) 58 | --------------------------------------------------------------------------------