graceisa414 commited on
Commit
89cf5ac
·
verified ·
1 Parent(s): 9ac6dd5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -47
app.py CHANGED
@@ -1,48 +1,50 @@
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)
15
-
16
- if "openai_model" not in st.session_state:
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)
32
-
33
- with st.chat_message("assistant"):
34
- message_placeholder = st.empty()
35
- full_response = ""
36
- for response in openai.ChatCompletion.create(
37
- model=st.session_state["openai_model"],
38
- messages=[
39
- {"role": m["role"], "content": m["content"]}
40
- for m in st.session_state.messages
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})
 
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
+
20
+ if "openai_model" not in st.session_state:
21
+ st.session_state["openai_model"] = "gpt-4o-mini"
22
+
23
+ if "messages" not in st.session_state:
24
+ st.session_state.messages = []
25
+
26
+ for message in st.session_state.messages:
27
+ with st.chat_message(message["role"]):
28
+ st.markdown(message["content"])
29
+
30
+ if prompt := st.chat_input("How can I help you today?"):
31
+ st.session_state.messages.append({"role": "system", "content": grounding})
32
+ st.session_state.messages.append({"role": "user", "content": prompt})
33
+ with st.chat_message("user"):
34
+ st.markdown(prompt)
35
+
36
+ with st.chat_message("assistant"):
37
+ message_placeholder = st.empty()
38
+ full_response = ""
39
+ for response in openai.ChatCompletion.create(
40
+ model=st.session_state["openai_model"],
41
+ messages=[
42
+ {"role": m["role"], "content": m["content"]}
43
+ for m in st.session_state.messages
44
+ ],
45
+ stream=True,
46
+ ):
47
+ full_response += response.choices[0].delta.get("content", "")
48
+ message_placeholder.markdown(full_response + "▌")
49
+ message_placeholder.markdown(full_response)
50
  st.session_state.messages.append({"role": "assistant", "content": full_response})