yashasgupta's picture
Update app.py
2701462 verified
raw
history blame
882 Bytes
import streamlit as st
from langchain import OpenAI
from langchain.chains import LLMChain
from langchain.prompts import ChatPromptTemplate
import os
from langchain_openai import ChatOpenAI
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
st.title("Summarization Application :robot_face:")
options = ["English", "Telugu", "Hindi", "French", "German", "Russian", "Spanish"]
input_language = st.selectbox("Input Language: ", options)
text = st.text_area("Text Input: ")
if st.button("Submit"):
llm = ChatOpenAI(model = "gpt-3.5-turbo",temperature = 0)
prompt = ChatPromptTemplate.from_messages([("system", "You are an expert summarizer for {lang} texts."),
("human", "{text}")])
chain = prompt|llm
response = chain.run({"lang": input_language, "text": text})
st.write("Summary: ")
st.write(response)