Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain.chat_models import ChatOpenAI
|
| 3 |
+
from langchain.prompts.chat import ChatPromptTemplate
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
|
| 9 |
+
|
| 10 |
+
st.title("Summarization Application :robot_face:")
|
| 11 |
+
|
| 12 |
+
options = ["English","Telugu","Hindi","French","German","Russian","Spanish"]
|
| 13 |
+
|
| 14 |
+
input_langauge = st.selectbox("Input Langauge: ",options)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
text = st.text_input("Text Input: ")
|
| 18 |
+
|
| 19 |
+
if st.button("Submit"):
|
| 20 |
+
|
| 21 |
+
llm = ChatOpenAI(model = "gpt-3.5-turbo",temperature = 0)
|
| 22 |
+
|
| 23 |
+
prompt = ChatPromptTemplate.from_messages([("system","you are an expert summarizer for {lang} text"),
|
| 24 |
+
("human","{text}")])
|
| 25 |
+
|
| 26 |
+
chain = prompt|llm
|
| 27 |
+
|
| 28 |
+
re = chain.invoke({"lang":input_langauge, "text":text})
|
| 29 |
+
|
| 30 |
+
st.write("Response: ")
|
| 31 |
+
|
| 32 |
+
st.write(re.content)
|