graceisa414 commited on
Commit
cb19945
·
verified ·
1 Parent(s): d276a1f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -18
app.py CHANGED
@@ -1,21 +1,14 @@
1
  import openai
2
  import streamlit as st
 
3
 
4
- st.title("GeniusHairBot2.0")
5
 
 
6
  openai.api_key = st.secrets["OPENAI_API_KEY"]
 
 
7
 
8
- grounding = """
9
- Start by greeting them kindly. Next, ask what their main frustrations are with their hair and which areas they'd like to improve.\
10
- Frizz: caused by lack of moisture or humidity. Suggest a hydrating serum or leave-in conditioner like Moroccanoil Frizz Control.\
11
- Dryness: When hair feels brittle, often due to a lack of natural moisture. Recommend deep conditioning treatments like SheaMoisture Intensive Hydration Hair Masque and sulfate-free shampoos.\
12
- Split Ends/Breakage: Suggest regular trims and Olaplex No.7 Bonding Oil to repair and strengthen hair. For breakage, recommend Aphogee Two-Step Protein Treatment to rebuild damaged hair.\
13
- Thinning/Loss: Hair thinning can be due to genetics or stress. Recommend Nioxin System Kit to stimulate scalp and support hair growth.Oily Hair: Excess oil production leads to greasy hair. Neutrogena Anti-Residue Shampoo can help clarify without overstimulating oil glands. \
14
- Dandruff: For flaky scalps, suggest Head & Shoulders Clinical Strength Shampoo to relieve itching and irritation.Tangles: The Wet Brush Detangler works wonders for tangled hair without causing damage.\
15
- Heat Damage: TRESemmé Thermal Creations Heat Tamer Spray protects from heat up to 450°F, reducing brittleness.Volume: For flat hair, Living Proof Full Dry Volume Blast adds instant texture and fullness.\
16
- Shrinkage: Camille Rose Curl Maker elongates and defines curls for a natural, stretched look.\
17
- Lastly, thank them for asking for advice, and wish them luck on their hair health journey! ( do not answer questions unrelated to hair)\
18
- """
19
  image = Image.open('logo.png')
20
 
21
  st.image(image)
@@ -24,14 +17,15 @@ if "openai_model" not in st.session_state:
24
  st.session_state["openai_model"] = "gpt-4o-mini"
25
 
26
  if "messages" not in st.session_state:
27
- st.session_state.messages = []
 
28
 
29
  for message in st.session_state.messages:
30
- with st.chat_message(message["role"]):
31
- st.markdown(message["content"])
 
32
 
33
- if prompt := st.chat_input("How can I help you today?"):
34
- st.session_state.messages.append({"role": "system", "content": grounding})
35
  st.session_state.messages.append({"role": "user", "content": prompt})
36
  with st.chat_message("user"):
37
  st.markdown(prompt)
@@ -47,7 +41,8 @@ if prompt := st.chat_input("How can I help you today?"):
47
  ],
48
  stream=True,
49
  ):
50
- full_response += response.choices[0].delta.get("content", "")
51
  message_placeholder.markdown(full_response + "▌")
52
  message_placeholder.markdown(full_response)
 
53
  st.session_state.messages.append({"role": "assistant", "content": full_response})
 
1
  import openai
2
  import streamlit as st
3
+ from PIL import Image
4
 
5
+ st.title("Carvalho Pizzeria")
6
 
7
+ # Streamlit Secrets
8
  openai.api_key = st.secrets["OPENAI_API_KEY"]
9
+ grounding = st.secrets["GROUNDING"]
10
+
11
 
 
 
 
 
 
 
 
 
 
 
 
12
  image = Image.open('logo.png')
13
 
14
  st.image(image)
 
17
  st.session_state["openai_model"] = "gpt-4o-mini"
18
 
19
  if "messages" not in st.session_state:
20
+ st.session_state.messages = []
21
+ st.session_state.messages.append({"role": "system", "content": grounding})
22
 
23
  for message in st.session_state.messages:
24
+ if message["role"] != "system":
25
+ with st.chat_message(message["role"]):
26
+ st.markdown(message["content"])
27
 
28
+ if prompt := st.chat_input("How can I help you today?"):
 
29
  st.session_state.messages.append({"role": "user", "content": prompt})
30
  with st.chat_message("user"):
31
  st.markdown(prompt)
 
41
  ],
42
  stream=True,
43
  ):
44
+ full_response += response.choices[0].delta.get("content", "").replace('\\$','$').replace('$','\\$')
45
  message_placeholder.markdown(full_response + "▌")
46
  message_placeholder.markdown(full_response)
47
+ print(full_response)
48
  st.session_state.messages.append({"role": "assistant", "content": full_response})