Spaces:
Running
Running
| 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) |