dk-crazydiv commited on
Commit
db05837
·
1 Parent(s): 98b7672

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cohere
3
+ import os
4
+ load_dotenv()
5
+
6
+ co = cohere.Client(os.getenv('COHERE_API_KEY'))
7
+
8
+ # Initialization
9
+ if 'output' not in st.session_state:
10
+ st.session_state['output'] = 'Output:'
11
+
12
+ def generate_hashtags(input):
13
+ if len(input) == 0:
14
+ return None
15
+ response = co.generate(
16
+ model='large',
17
+ prompt='Given a post, this program will generate relevant hashtags.\n\nPost: Why are there no country songs about software engineering\nHashtag: #softwareengineering #code \n--\nPost: Your soulmate is in the WeWork you decided not to go to\nHashtag: #wework #work \n--\nPost: If shes talking to you once a day im sorry bro thats not flirting that standup\nHashtag: #standup #funny \n--\nPost: {}\nHashtags:'.format(input),
18
+ max_tokens=20,
19
+ temperature=0.5,
20
+ k=0,
21
+ p=1,
22
+ frequency_penalty=0,
23
+ presence_penalty=0,
24
+ stop_sequences=["--"],
25
+ return_likelihoods='NONE')
26
+
27
+ st.session_state['output'] = response.generations[0].text
28
+ st.balloons()
29
+
30
+
31
+ st.title('Hashtag Generator')
32
+ st.subheader('Boilerplate for Co:here, Streamlit, Streamlit Cloud')
33
+ st.write('''This is a simple **Streamlit** app that generates hashtags from a small Post title caption.''')
34
+
35
+ input = st.text_area('Enter your post title caption here', height=100)
36
+ st.button('Generate Hashtags', on_click = generate_hashtags(input))
37
+ st.write(st.session_state.output)