DariaKhot commited on
Commit
b44c3dc
1 Parent(s): 2ab515e

Add application file

Browse files
Files changed (1) hide show
  1. app.py +16 -24
app.py CHANGED
@@ -3,34 +3,26 @@ from transformers import pipeline
3
 
4
 
5
  ###################################################
6
- pipe = pipeline("text-generation", model='all-MiniLM-L6-v2')
 
7
 
8
 
9
- def main():
10
- try:
11
- st.title("Which Resort is best for you?")
12
 
13
- weathers = ["Sunny", "Rainy", "Snowy"]
14
- activities = ["Skiing", "Hiking", "Swimming", "Relaxing"]
15
- weather = st.selectbox("What is the weather like?", weathers)
16
- activity = st.selectbox("What activity do you prefer?", activities)
17
- input_prompt = f"The weather is {weather.lower()} and I like {activity.lower()}."
18
 
19
- if st.button('Recommend a Resort'):
20
- with st.spinner('Generating recommendation...'):
21
- # Generate text based on the input prompt
22
- generated_texts = pipe(input_prompt, max_length=50, num_return_sequences=1)
23
- recommendation = generated_texts[0]['generated_text']
24
 
25
- # Displaying the generated recommendation
26
- st.subheader("Recommended Resort:")
27
- st.write(recommendation)
28
 
29
- except Exception as e:
30
- st.error(e)
31
-
32
- ###################################################
33
- if __name__=="main":
34
- main()
35
-
36
 
 
3
 
4
 
5
  ###################################################
6
+ model_name = "sentence-transformers/all-MiniLM-L6-v2"
7
+ pipe = pipeline("text-generation", model=model_name)
8
 
9
 
10
+ st.title("Which Resort is best for you?")
 
 
11
 
12
+ weathers = ["Sunny", "Rainy", "Snowy"]
13
+ activities = ["Skiing", "Hiking", "Swimming", "Relaxing"]
14
+ weather = st.selectbox("What is the weather like?", weathers)
15
+ activity = st.selectbox("What activity do you prefer?", activities)
16
+ input_prompt = f"The weather is {weather.lower()} and I like {activity.lower()}."
17
 
18
+ if st.button('Recommend a Resort'):
19
+ with st.spinner('Generating recommendation...'):
20
+ # Generate text based on the input prompt
21
+ generated_texts = pipe(input_prompt, max_length=50, num_return_sequences=1)
22
+ recommendation = generated_texts[0]['generated_text']
23
 
24
+ # Displaying the generated recommendation
25
+ st.subheader("Recommended Resort:")
26
+ st.write(recommendation)
27
 
 
 
 
 
 
 
 
28