mathslearn commited on
Commit
4001d07
·
verified ·
1 Parent(s): 373948d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -24
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=3)
 
20
 
21
  conversation = ConversationChain(
22
  llm=llm,
@@ -25,32 +26,67 @@ conversation = ConversationChain(
25
  )
26
 
27
  context = """
28
- Act as a ChatBot to interact with users on their questions about traditional chinese medicine (TCM). \
29
- First welcome the user in a friendly way and state this disclaimer: \
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
- The menu includes:
38
- burgers 12.95, 10.00, 7.00
39
- frankfurts 10.95, 9.25, 6.50
40
- sandwiches 11.95, 9.75, 6.75
41
- fries 4.50, 3.50
42
- salad 7.25
43
- Toppings:
44
- extra cheese 2.00,
45
- mushrooms 1.50
46
- martra sausage 3.00
47
- canadian bacon 3.50
48
- romesco sauce 1.50
49
- peppers 1.00
50
- Drinks:
51
- coke 3.00, 2.00, 1.00
52
- sprite 3.00, 2.00, 1.00
53
- vichy catalan 5.00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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} \