|
import streamlit as st |
|
from langchain import OpenAI |
|
from langchain.chains import LLMChain |
|
from langchain.prompts import ChatPromptTemplate |
|
import os |
|
|
|
os.environ["OPENAI_API_KEY"] = os.getenv("k1") |
|
|
|
|
|
llm = OpenAI(api_key = os.environ["OPENAI_API_KEY"],model="gpt-3.5", temperature=0) |
|
|
|
|
|
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"): |
|
prompt = ChatPromptTemplate.from_messages([("system", "You are an expert summarizer for {lang} texts."), |
|
("human", "{text}")]) |
|
|
|
chain = LLMChain(prompt=prompt, llm=llm) |
|
|
|
response = chain.run({"lang": input_language, "text": text}) |
|
|
|
st.write("Summary: ") |
|
st.write(response) |
|
|