-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlangchain_autogpt.py
33 lines (27 loc) · 1 KB
/
langchain_autogpt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from apikey import apikey
import streamlit as st
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain, SimpleSequentialChain
os.environ['OPENAI_API_KEY'] = apikey
st.title('🦜️🔗 Langchain AutoGPT')
prompt = st.text_input("Plug in your prompt here")
#Prompt templates
title_template = PromptTemplate(
input_variables= ['topic'],
template = 'write me a youtube video title about {topic}'
)
script_template = PromptTemplate(
input_variables= ['title'],
template = 'write me a youtube video script based on this title: {title}'
)
#Lllms
llm = OpenAI(temperature=0.5)
title_chain = LLMChain(llm=llm, prompt=title_template, verbose=True)
script_chain = LLMChain(llm=llm, prompt=script_template, verbose=True)
simpleSequentialChain= SimpleSequentialChain(chains=[title_chain,script_chain], verbose=True)
#Show stuff to the screen if there's a prompt
if prompt:
response = simpleSequentialChain.run(prompt)
st.write(response)