|
import streamlit as st |
|
from langchain.chat_models import ChatOpenAI |
|
from langchain.prompts.chat import ChatPromptTemplate |
|
|
|
import os |
|
|
|
os.environ["OPENAI_API_KEY"] = os.getenv("k1") |
|
|
|
st.title("Summarization Application :robot_face:") |
|
|
|
options = ["English","Telugu","Hindi","French","German","Russian","Spanish"] |
|
|
|
input_langauge = st.selectbox("Input Langauge: ",options) |
|
|
|
|
|
text = st.text_input("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} text."), |
|
("human","{text}")]) |
|
|
|
chain = prompt|llm |
|
|
|
re = chain.invoke({"lang":input_langauge, "text":text}) |
|
|
|
st.write("Response: ") |
|
|
|
st.write(re.content) |