Spaces:
Sleeping
Sleeping
File size: 1,228 Bytes
7832925 3ac4f4b 75978fd 3ac4f4b 901b5b4 bb407cf 64fdec3 bb407cf 64fdec3 75978fd 64fdec3 75978fd 764d850 c8e451b ed28350 75978fd 0884634 bb407cf 0884634 3ac4f4b 0884634 3ac4f4b 64fdec3 bb407cf b009423 0884634 bb407cf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
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:")
rainbow_text = """
<div style="font-size:24px; font-weight:bold;">
<span style="color:red;">R</span>
<span style="color:orange;">A</span>
<span style="color:yellow;">I</span>
<span style="color:green;">N</span>
<span style="color:blue;">B</span>
<span style="color:indigo;">O</span>
<span style="color:violet;">W</span>
</div>
"""
st.markdown(rainbow_text, unsafe_allow_html=True)
options1 = ["English","Telugu","Hindi"]
st.selectbox("Input Langauge: ",options1)
options2 = ["Hindi","Telugu","English"]
st.selectbox("Output langauge: ",options2)
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 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)
|