yashasgupta's picture
Update app.py
6a7f327 verified
raw
history blame
887 Bytes
import streamlit as st
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
import os
os.environ["OPENAI_API_KEY"] = os.getenv("k1")
st.title("Translation Application :robot_face:")
options1 = ["English","Telugu","Hindi","French","German","Russian","Spanish"]
st.selectbox("Input Langauge: ",options1)
options2 = ["Hindi","Telugu","Spanish","English","German","Russian","French"]
st.selectbox("Output langauge: ",options2)
text = st.text_input("Text Input: ")
if st.button("Submit"):
llm = ChatOpenAI(model = "GPT-4o",temperature = 0)
prompt = ChatPromptTemplate.from_messages([("system","you are a good assistant for translation to {il} to {ol}"),
("human","{i}")])
chain = prompt|llm
re = chain.invoke({"il":options1,"ol":options2, "i":text})
st.write("Response: ")
st.write(re.content)