Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,30 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from langchain
|
| 3 |
-
from langchain.
|
| 4 |
-
|
| 5 |
import os
|
| 6 |
|
| 7 |
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
|
| 8 |
|
| 9 |
-
st.title("Summarization Application :robot_face:")
|
| 10 |
-
|
| 11 |
-
options = ["English","Telugu","Hindi","French","German","Russian","Spanish"]
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
("human","{text}")])
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
st.write(
|
|
|
|
|
|
| 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 |
|
| 7 |
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
llm = OpenAI(api_key = os.environ["OPENAI_API_KEY"],model="gpt-3.5-turbo", temperature=0)
|
| 11 |
|
| 12 |
|
| 13 |
+
st.title("Summarization Application :robot_face:")
|
| 14 |
|
| 15 |
+
options = ["English", "Telugu", "Hindi", "French", "German", "Russian", "Spanish"]
|
| 16 |
|
| 17 |
+
input_language = st.selectbox("Input Language: ", options)
|
| 18 |
|
| 19 |
+
text = st.text_area("Text Input: ")
|
|
|
|
| 20 |
|
| 21 |
+
if st.button("Submit"):
|
| 22 |
+
prompt = ChatPromptTemplate.from_messages([("system", "You are an expert summarizer for {lang} texts."),
|
| 23 |
+
("human", "{text}")])
|
| 24 |
|
| 25 |
+
chain = LLMChain(prompt=prompt, llm=llm)
|
| 26 |
|
| 27 |
+
response = chain.run({"lang": input_language, "text": text})
|
| 28 |
|
| 29 |
+
st.write("Summary: ")
|
| 30 |
+
st.write(response)
|