Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
################################################### | |
pipe = pipeline("text-generation", model='all-MiniLM-L6-v2') | |
def main(): | |
try: | |
st.title("Which Resort is best for you?") | |
weathers = ["Sunny", "Rainy", "Snowy"] | |
activities = ["Skiing", "Hiking", "Swimming", "Relaxing"] | |
weather = st.selectbox("What is the weather like?", weathers) | |
activity = st.selectbox("What activity do you prefer?", activities) | |
input_prompt = f"The weather is {weather.lower()} and I like {activity.lower()}." | |
if st.button('Recommend a Resort'): | |
with st.spinner('Generating recommendation...'): | |
# Generate text based on the input prompt | |
generated_texts = pipe(input_prompt, max_length=50, num_return_sequences=1) | |
recommendation = generated_texts[0]['generated_text'] | |
# Displaying the generated recommendation | |
st.subheader("Recommended Resort:") | |
st.write(recommendation) | |
except Exception as e: | |
st.error(e) | |
################################################### | |
if __name__=="main": | |
main() | |