Duy Tran commited on
Commit
b411e30
·
1 Parent(s): 777e659

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+
4
+ from langchain import OpenAI, PromptTemplate
5
+ from langchain.chains import LLMChain
6
+
7
+ st.set_page_config(
8
+ page_title="LangChain Demo",
9
+ page_icon="🔗",
10
+ layout="wide",
11
+ )
12
+ st.title("LangChain Demo")
13
+
14
+ OPENAI_KEY = st.sidebar.text_input("Enter your OpenAI API key to start", type="password")
15
+ temperature = st.sidebar.slider("Temperature", min_value=0.0, max_value=1.0, value=0.1, step=0.01)
16
+ model_name = st.sidebar.selectbox("Model", ["text-ada-001", "davinci", "curie", "babbage", "ada", "text-davinci-002"])
17
+ template = st.sidebar.text_area("Enter your prompt template", value="Write a title for a Youtube video about {content} with {style} style.")
18
+
19
+ if OPENAI_KEY:
20
+ os.environ["OPENAI_API_KEY"] = OPENAI_KEY
21
+
22
+ llm = OpenAI(temperature=temperature,model_name=model_name)
23
+
24
+ prompt_template = PromptTemplate(
25
+ input_variables=["content", "style"],
26
+ template=template,
27
+ )
28
+
29
+ chain = LLMChain(llm=llm, prompt=prompt_template)
30
+
31
+ content = st.text_input("Enter your content", value="Deep Learning in 1 minutes")
32
+ style = st.text_input("Enter your style", value="funny")
33
+
34
+
35
+ if st.button('Generate'):
36
+ text_response = chain.run(content= content, style=style)
37
+ st.write(text_response)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ langchain
2
+ openai