dk-crazydiv commited on
Commit
8bb13bf
·
2 Parent(s): a584f19 53d6b99

Merge branch 'main' of https://huggingface.co/spaces/fortuna-hackathon/positive-reframing into main

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -2,9 +2,20 @@ import streamlit as st
2
  import cohere
3
  import os
4
 
 
 
 
 
 
 
 
 
5
  co = cohere.Client(os.getenv('COHERE_API_KEY'))
6
 
7
  # Initialization
 
 
 
8
 
9
  def generate_hashtags(input):
10
  if len(input) == 0:
@@ -36,11 +47,25 @@ def generate_hashtags(input):
36
  st.title('Positive Reframing Generator')
37
  st.write('''This is a simple **Streamlit** app that generates the input sentence with a positive spin to it''')
38
 
39
- input = st.text_area('Enter your post title caption here', height=100)
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  category = st.radio(
42
  "Please select a category",
43
- ('growth', 'remove_negations', 'self_affirmation', 'detect_rhetoric'))
 
 
44
 
45
  if st.button('Reframe'):
46
  output = generate_hashtags(input)
 
2
  import cohere
3
  import os
4
 
5
+
6
+ # 'growth', 'remove_negations', 'self_affirmation'
7
+ EXAMPLES = {
8
+ "I lost my Job": ("I lost my Job.", 'growth'),
9
+ "I lost my Dog": ("I lost my Dog.", 'self_affirmation'),
10
+ }
11
+ categories = ['growth', 'remove_negations', 'self_affirmation', 'detect_rhetoric']
12
+
13
  co = cohere.Client(os.getenv('COHERE_API_KEY'))
14
 
15
  # Initialization
16
+ def fill_example_caption(**kwargs):
17
+ print(f"Called with {kwargs}")
18
+ print(f"selectbox {prompt}")
19
 
20
  def generate_hashtags(input):
21
  if len(input) == 0:
 
47
  st.title('Positive Reframing Generator')
48
  st.write('''This is a simple **Streamlit** app that generates the input sentence with a positive spin to it''')
49
 
50
+ prompts = ["Choose"] + list(EXAMPLES.keys())
51
+ prompt = st.selectbox(
52
+ 'Examples (select from this list)',
53
+ prompts,
54
+ index=0,
55
+ )
56
+ if prompt == "Choose":
57
+ input_val = ""
58
+ input_cat = categories[0]
59
+ else:
60
+ input_val = EXAMPLES[prompt][0]
61
+ input_cat = EXAMPLES[prompt][1]
62
+ input = st.text_area('Enter your post title caption or select from examples', input_val, height=100)
63
 
64
  category = st.radio(
65
  "Please select a category",
66
+ categories,
67
+ categories.index(input_cat),
68
+ )
69
 
70
  if st.button('Reframe'):
71
  output = generate_hashtags(input)