Giang07's picture
Update app.py
5f546a5 verified
raw
history blame contribute delete
No virus
737 Bytes
import streamlit as st
from model_utils import load_model, create_pipeline, generate_text
# Load model and tokenizer
st.write("Loading model...")
model, tokenizer = load_model()
hf_pipeline = create_pipeline(model, tokenizer)
st.write("Model loaded successfully!")
# Streamlit application
st.title("Hugging Face Model with LangChain and Streamlit")
# Text input field
input_text = st.text_input("Enter text to translate:")
# Button to generate response
if st.button("Translate"):
if input_text:
# Generate response using LangChain
response = generate_text(hf_pipeline, input_text)
# Display the response
st.write("Translated text:", response)
else:
st.write("Please enter some text.")