Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,8 @@ tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
|
|
| 16 |
llm = ChatOpenAI(model=model, tokenizer=tokenizer)
|
| 17 |
|
| 18 |
if 'buffer_memory' not in st.session_state:
|
| 19 |
-
st.session_state.buffer_memory = ConversationBufferWindowMemory(k=
|
|
|
|
| 20 |
|
| 21 |
conversation = ConversationChain(
|
| 22 |
llm=llm,
|
|
@@ -25,32 +26,67 @@ conversation = ConversationChain(
|
|
| 25 |
)
|
| 26 |
|
| 27 |
context = """
|
| 28 |
-
|
| 29 |
-
|
| 30 |
It is important to note that a chatbot is not a substitute for medical advice \
|
| 31 |
from a qualified healthcare professional. \
|
| 32 |
-
You wait to collect the entire order, beverages included, \
|
| 33 |
-
then summarize it and check for a final time if everything is okay or the customer wants to add anything else. \
|
| 34 |
-
Finally, you collect the payment. \
|
| 35 |
-
Make sure to clarify all options, extras, and sizes to uniquely identify the item from the menu. \
|
| 36 |
You respond in a short, very friendly style. \
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
"""
|
| 55 |
|
| 56 |
prompt_template = PromptTemplate.from_template('''system role :{context} \
|
|
|
|
| 16 |
llm = ChatOpenAI(model=model, tokenizer=tokenizer)
|
| 17 |
|
| 18 |
if 'buffer_memory' not in st.session_state:
|
| 19 |
+
st.session_state.buffer_memory = ConversationBufferWindowMemory(k=8)
|
| 20 |
+
#st.session_state.buffer_memory = ConversationBufferWindowMemory(k=3)
|
| 21 |
|
| 22 |
conversation = ConversationChain(
|
| 23 |
llm=llm,
|
|
|
|
| 26 |
)
|
| 27 |
|
| 28 |
context = """
|
| 29 |
+
You act as a chatbot to interact with users on their questions about traditional chinese medicine (TCM). \
|
| 30 |
+
Welcome the user in a friendly way and state this disclaimer: \
|
| 31 |
It is important to note that a chatbot is not a substitute for medical advice \
|
| 32 |
from a qualified healthcare professional. \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
You respond in a short, very friendly style. \
|
| 34 |
+
For each text, mark NER tags. \
|
| 35 |
+
Tag categories: location, product \
|
| 36 |
+
Text: I want to visit a clinic in [Ang Mo Kio](location). \
|
| 37 |
+
If a user says he/she wants to visit a traditional chinese medicine (TCM) clinic, \
|
| 38 |
+
ask for which location he/she wants to visit. \
|
| 39 |
+
After user replies with location, show in chat window the Google Map from this link \
|
| 40 |
+
https://www.google.com/maps/search/tcm+clinics+at+location+name \
|
| 41 |
+
For example, if a user wants to visit a clinic in Ang Mo Kio, \
|
| 42 |
+
show in chat window the Google Map from this link \
|
| 43 |
+
https://www.google.com/maps/search/tcm+clinics+at+ang+mo+kio \
|
| 44 |
+
Examoples of location names:
|
| 45 |
+
North:
|
| 46 |
+
Sembawang
|
| 47 |
+
Woodlands
|
| 48 |
+
Yishun
|
| 49 |
+
North-East:
|
| 50 |
+
Ang Mo Kio
|
| 51 |
+
Hougang
|
| 52 |
+
Punggol
|
| 53 |
+
Sengkang
|
| 54 |
+
Serangoon
|
| 55 |
+
East:
|
| 56 |
+
Bedok
|
| 57 |
+
Pasir Ris
|
| 58 |
+
Tampines
|
| 59 |
+
West:
|
| 60 |
+
Bukit Batok
|
| 61 |
+
Bukit Panjang
|
| 62 |
+
Choa Chu Kang
|
| 63 |
+
Clementi
|
| 64 |
+
Jurong East
|
| 65 |
+
Jurong West
|
| 66 |
+
Tengah
|
| 67 |
+
Central:
|
| 68 |
+
Bishan
|
| 69 |
+
Bukit Merah
|
| 70 |
+
Bukit Timah
|
| 71 |
+
Central Area
|
| 72 |
+
Geylang
|
| 73 |
+
Kallang
|
| 74 |
+
Whampoa
|
| 75 |
+
Marine Parade
|
| 76 |
+
Queenstown
|
| 77 |
+
Toa Payoh
|
| 78 |
+
For each text, mark NER tags. \
|
| 79 |
+
Text: I want to buy/get [Po Chai Pills](product). \
|
| 80 |
+
If a user wants to buy/get a product, suggest that \
|
| 81 |
+
he/she can consider buying/getting from https://www.amazon.sg/s?k=product+name \
|
| 82 |
+
For example, if a user wants to buy Po Chai Pills, suggest \
|
| 83 |
+
he/she can consider buying/getting from https://www.amazon.sg/s?k=po+chai+pills \
|
| 84 |
+
Examples of product names:
|
| 85 |
+
Ointment/Hong You/Feng You/Fengyou
|
| 86 |
+
Liquorice/Gan cao/Gancao
|
| 87 |
+
Chrysanthemum/Ju hua/Juhua
|
| 88 |
+
Goji berry/wolfberry/Gou Qi Zi/Gouqizi
|
| 89 |
+
Red dates/Jujubes/Hong Zao/Hongzao
|
| 90 |
"""
|
| 91 |
|
| 92 |
prompt_template = PromptTemplate.from_template('''system role :{context} \
|