Spaces:
Sleeping
Sleeping
File size: 5,364 Bytes
1b1411a b3f0b17 ba53b4e 1b1411a ba53b4e 8b5b8d2 ba53b4e 8b5b8d2 ba53b4e 8b5b8d2 ba53b4e 1b1411a ba53b4e 1b1411a ba53b4e 1b1411a ba53b4e 1b1411a ba53b4e 1b1411a ba53b4e 8b5b8d2 ba53b4e 8b5b8d2 ba53b4e 8b5b8d2 1b1411a 8b5b8d2 1b1411a 8b5b8d2 1b1411a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
import streamlit as st
import requests
import json
import os
import threading
import subprocess
import requests
from bs4 import BeautifulSoup
st.set_page_config(page_title="Affirmations", page_icon=":muscle:", layout="wide")
st.markdown(
"""
<style>
.stApp {
background-color: #e9e5d9;
}
.title {
font-size: 36px;
font-weight: bold;
text-align: center;
margin-bottom: 20px;
}
.image-container {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.affirmation-box {
background-color: #ffffff;
padding: 20px;
border-radius: 10px;
margin-top: 20px;
text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.affirmation-text {
font-family: 'Helvetica', sans-serif;
font-size: 18px;
color: #333333;
}
.stButton button {
background-color: #ff0000;
color: #ffffff;
font-size: 16px;
padding: 10px 20px;
border-radius: 5px;
margin-top: 20px;
width: 100%;
}
</style>
""",
unsafe_allow_html=True
)
col1, col2 = st.columns(2)
st.title("Taylor Swift's Gym Affirmations")
with col2:
st.image("https://www.rollingstone.com/wp-content/uploads/2023/05/GettyImages-1482443875.jpeg?w=1581&h=1054&crop=1")
with col1:
st.image("taylor_1.jpg")
context = st.text_input("Tell taylor about your day for context")
groq_api_key = os.getenv['groq_api_token']
from groq import Groq
client = Groq(
api_key=groq_api_key,
)
def llama3_8b(prompt, temperature=0.0, input_print=True):
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model="llama3-8b-8192",
temperature=temperature,
)
return (chat_completion.choices[0].message.content)
def llama3_70b(prompt, temperature=0.0, input_print=True):
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model="llama3-70b-8192",
temperature=temperature,
)
return (chat_completion.choices[0].message.content)
if st.button("Generate Affirmation", key="generate_affirmation"):
def get_astrology_sign(birth_date):
# Zodiac signs divided by the date ranges
zodiac_dates = [
((1, 20), (2, 18), "11"),
((2, 19), (3, 20), "12"),
((3, 21), (4, 19), "1"),
((4, 20), (5, 20), "2"),
((5, 21), (6, 20), "3"),
((6, 21), (7, 22), "4"),
((7, 23), (8, 22), "5"),
((8, 23), (9, 22), "6"),
((9, 23), (10, 22), "7"),
((10, 23), (11, 21), "8"),
((11, 22), (12, 21), "9"),
((12, 22), (1, 19), "10")
]
month = birth_date.month
day = birth_date.day
for start, end, sign in zodiac_dates:
if (month == start[0] and day >= start[1]) or (month == end[0] and day <= end[1]):
return sign
return "Unknown"
def get_horoscope(zodiac_sign):
day = 'tomorrow'
url = (
"https://www.horoscope.com/us/horoscopes/general/"
f"horoscope-general-daily-{day}.aspx?sign={zodiac_sign}"
)
soup = BeautifulSoup(requests.get(url).content, "html.parser")
horoscope_text = soup.find("div", class_="main-horoscope").p.text
return horoscope_text
# Cancer
owner_sign = "4"
horoscope_text = get_horoscope(owner_sign)
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\n
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
do it more for feeling better, reduce resting heart rate, overall feeling fitter little bit everyday.\n
Here\'s my horoscope information for Today {}\n\n
I have also described how my day has been {}\n\n
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
Try to include taylor swift song lyrics in few places not forcefully but relevant to the overall content. \n
I don\'t want output to use exactly these words i have written so that it does not feel fake or forceful.\n
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)
# messages = [{"role": "user", "content": prompt}]
# response = chat(messages)
# affirmation = response["content"]
output = llama3_70b(prompt)
with col1:
st.markdown(f'<div class="affirmation-box"><p class="horoscope-text">{horoscope_text}</p></div>', unsafe_allow_html=True)
with col2:
st.markdown(f'<div class="affirmation-box"><p class="affirmation-text">{output}</p></div>', unsafe_allow_html=True)
|