Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,22 @@
|
|
1 |
import streamlit as st
|
2 |
-
from langchain import OpenAI
|
3 |
-
from langchain.chains import LLMChain
|
4 |
-
from langchain.prompts import ChatPromptTemplate
|
5 |
-
import os
|
6 |
from langchain_openai import ChatOpenAI
|
|
|
|
|
7 |
|
8 |
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
|
9 |
|
10 |
-
|
11 |
st.title("Summarization Application :robot_face:")
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
input_language = st.selectbox("Input Language: ", options)
|
16 |
-
|
17 |
-
text = st.text_area("Text Input: ")
|
18 |
|
19 |
if st.button("Submit"):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
("human", "{text}")])
|
24 |
|
25 |
-
chain = prompt|llm
|
26 |
|
27 |
-
response = chain.
|
28 |
|
29 |
st.write("Summary: ")
|
30 |
-
st.write(response)
|
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
2 |
from langchain_openai import ChatOpenAI
|
3 |
+
from langchain_core.prompts import ChatPromptTemplate
|
4 |
+
import os
|
5 |
|
6 |
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
|
7 |
|
|
|
8 |
st.title("Summarization Application :robot_face:")
|
9 |
|
10 |
+
text = st.text_area("Text Input: ", height=200)
|
|
|
|
|
|
|
|
|
11 |
|
12 |
if st.button("Submit"):
|
13 |
+
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
|
14 |
+
prompt = ChatPromptTemplate.from_messages([("system", "You are a good assistant for summarization."),
|
15 |
+
("human", "{i}")])
|
|
|
16 |
|
17 |
+
chain = prompt | llm
|
18 |
|
19 |
+
response = chain.invoke({"i": text})
|
20 |
|
21 |
st.write("Summary: ")
|
22 |
+
st.write(response.content)
|