HQ_Project_EN / pages /Project_1.2_-_LLM_Translator.py
1mpreccable's picture
Initial commit with cleared history
cff87c7
raw
history blame contribute delete
865 Bytes
import streamlit as st
from langchain_groq import ChatGroq
import os
from dotenv import load_dotenv
load_dotenv()
groq_api_key = os.getenv("GROQ_API_KEY")
################################################################################
st.sidebar.title("App parameters")
st.write("This is the LangChain app.")
llm = ChatGroq(
model="llama3-70b-8192",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
)
input_sentence = st.text_area("Enter a sentence for translation")
button_launch = st.button('Translate')
if button_launch:
messages = [
(
"system",
"You are a helpful assistant that translates English to French. Translate the user sentence. Return only translated text.",
),
("human", input_sentence),
]
ai_msg = llm.invoke(messages)
st.write(ai_msg.content)