phildunphy14 commited on
Commit
8b5b8d2
·
verified ·
1 Parent(s): 1a57656

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -21
app.py CHANGED
@@ -66,17 +66,47 @@ with col2:
66
  with col1:
67
  st.image("taylor_1.jpg")
68
 
69
- if st.button("Generate Affirmation", key="generate_affirmation"):
70
- # prompt = """My name is aditi, i have 2 pets named Jamun and Misri and i do not like going to gym because i expect results too quickly.
71
- # In few days i see no gains and get irritated and give up. This time around i have decided to take it slow and
72
- # do it more for feeling better, reduce resting heart rate, overall feeling fitter little bit everyday.
73
- # Your job is to give me positive affirmations like taylor swift would talk to me in the theme i described of taking it slow and doing it more for happiness and feeling fit.
74
- # Try to include taylor swift song lyrics in few places not forcefully but relevant to the overall content.
75
- # Important is i am giving all this as context, i don't want output to use any of the words i have written so that it feel fake or forceful.
76
- # The structure is basically conversational like taylor swift talking to me about my life and pets and not bullet points.
77
- # """
78
 
 
 
 
 
 
 
 
 
 
 
 
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  def get_astrology_sign(birth_date):
82
  # Zodiac signs divided by the date ranges
@@ -123,25 +153,26 @@ if st.button("Generate Affirmation", key="generate_affirmation"):
123
  In few days i see no gains and get irritated and give up. This time around i have decided to take it slow and \n
124
  do it more for feeling better, reduce resting heart rate, overall feeling fitter little bit everyday.\n
125
  Here\'s my horoscope information for Today {}\n\n
126
- Taking all this above context , Your job is to give me positive affirmations like taylor swift would talk to me in the theme of starting with fewn lines about my horoscope and then talk about my fitness goals.\n
 
127
  Try to include taylor swift song lyrics in few places not forcefully but relevant to the overall content. \n
128
  I don\'t want output to use exactly these words i have written so that it does not feel fake or forceful.\n
129
- The structure should be conversational like taylor swift talking to me about my life and pets and not bullet points or third person.'''.format(horoscope_text)
130
-
131
-
132
- messages = [{"role": "user", "content": prompt}]
133
- response = chat(messages)
134
- affirmation = response["content"]
 
 
135
  with col1:
136
  st.markdown(f'<div class="affirmation-box"><p class="horoscope-text">{horoscope_text}</p></div>', unsafe_allow_html=True)
137
  with col2:
138
- st.markdown(f'<div class="affirmation-box"><p class="affirmation-text">{affirmation}</p></div>', unsafe_allow_html=True)
139
-
140
-
141
- groq_api_key = os.getenv['groq_api_token']
142
-
143
 
 
144
 
 
145
 
146
 
147
 
 
66
  with col1:
67
  st.image("taylor_1.jpg")
68
 
69
+ context = st.text_input("Tell taylor about your day for context")
70
+
71
+ groq_api_key = os.getenv['groq_api_token']
72
+
73
+ from groq import Groq
74
+
75
+ client = Groq(
76
+ api_key=groq_api_key,
77
+ )
78
 
79
+ def llama3_8b(prompt, temperature=0.0, input_print=True):
80
+ chat_completion = client.chat.completions.create(
81
+ messages=[
82
+ {
83
+ "role": "user",
84
+ "content": prompt,
85
+ }
86
+ ],
87
+ model="llama3-8b-8192",
88
+ temperature=temperature,
89
+ )
90
 
91
+ return (chat_completion.choices[0].message.content)
92
+
93
+ def llama3_70b(prompt, temperature=0.0, input_print=True):
94
+ chat_completion = client.chat.completions.create(
95
+ messages=[
96
+ {
97
+ "role": "user",
98
+ "content": prompt,
99
+ }
100
+ ],
101
+ model="llama3-70b-8192",
102
+ temperature=temperature,
103
+ )
104
+
105
+ return (chat_completion.choices[0].message.content)
106
+
107
+
108
+
109
+ if st.button("Generate Affirmation", key="generate_affirmation"):
110
 
111
  def get_astrology_sign(birth_date):
112
  # Zodiac signs divided by the date ranges
 
153
  In few days i see no gains and get irritated and give up. This time around i have decided to take it slow and \n
154
  do it more for feeling better, reduce resting heart rate, overall feeling fitter little bit everyday.\n
155
  Here\'s my horoscope information for Today {}\n\n
156
+ I have also described how my day has been {}\n\n
157
+ Taking all this above context , Your job is to give me positive affirmations like taylor swift would talk to me in the theme of starting with few lines about my life in general and then talk about my fitness goals.\n
158
  Try to include taylor swift song lyrics in few places not forcefully but relevant to the overall content. \n
159
  I don\'t want output to use exactly these words i have written so that it does not feel fake or forceful.\n
160
+ The structure should be conversational like taylor swift talking to me about my life and pets and not bullet points or third person. Also do not include actions in itallic words, just keep it to conversations.'''.format(horoscope_text,context)
161
+
162
+ # messages = [{"role": "user", "content": prompt}]
163
+ # response = chat(messages)
164
+ # affirmation = response["content"]
165
+
166
+ output = llama3_70b(prompt)
167
+
168
  with col1:
169
  st.markdown(f'<div class="affirmation-box"><p class="horoscope-text">{horoscope_text}</p></div>', unsafe_allow_html=True)
170
  with col2:
171
+ st.markdown(f'<div class="affirmation-box"><p class="affirmation-text">{output}</p></div>', unsafe_allow_html=True)
 
 
 
 
172
 
173
+
174
 
175
+
176
 
177
 
178