Spaces:
Sleeping
Sleeping
Commit ·
a216a0d
1
Parent(s): 7eb99e8
refactor: Update display format in tool call and result messages for consistency
Browse files- app.py +4 -4
- backend/systemprompt.py +8 -2
- backend/tools.py +42 -4
- backend/tts.py +2 -1
app.py
CHANGED
|
@@ -85,7 +85,7 @@ def format_history_for_chatbot(history):
|
|
| 85 |
id = tool_calls[0]['id']
|
| 86 |
func_name = tool_calls[0]['function']['name']
|
| 87 |
func_args = tool_calls[0]['function']['arguments']
|
| 88 |
-
display_content = f"
|
| 89 |
# display_content = (
|
| 90 |
# f"**Calling Tool:**\n"
|
| 91 |
# f"```json\n"
|
|
@@ -103,7 +103,7 @@ def format_history_for_chatbot(history):
|
|
| 103 |
# Display a user-friendly message for the tool result
|
| 104 |
id = turn.get("tool_call_id")
|
| 105 |
result_content = json.dumps(json.loads(content), indent=2, ensure_ascii=False)
|
| 106 |
-
display_content = f"
|
| 107 |
# display_content = (
|
| 108 |
# f"**Tool Result:**\n"
|
| 109 |
# f"```json\n"
|
|
@@ -133,12 +133,12 @@ def revert_to_openai_format(formatted_history):
|
|
| 133 |
# Pre-compile regex patterns for efficiency
|
| 134 |
# Pattern to find a tool call message
|
| 135 |
tool_call_pattern = re.compile(
|
| 136 |
-
r"
|
| 137 |
re.DOTALL # Use DOTALL in case arguments contain newlines
|
| 138 |
)
|
| 139 |
# Pattern to find a tool result message
|
| 140 |
tool_result_pattern = re.compile(
|
| 141 |
-
r"
|
| 142 |
re.DOTALL
|
| 143 |
)
|
| 144 |
|
|
|
|
| 85 |
id = tool_calls[0]['id']
|
| 86 |
func_name = tool_calls[0]['function']['name']
|
| 87 |
func_args = tool_calls[0]['function']['arguments']
|
| 88 |
+
display_content = f"<id>{id}</id><func_name>{func_name}</func_name><func_args>{func_args}</func_args>"
|
| 89 |
# display_content = (
|
| 90 |
# f"**Calling Tool:**\n"
|
| 91 |
# f"```json\n"
|
|
|
|
| 103 |
# Display a user-friendly message for the tool result
|
| 104 |
id = turn.get("tool_call_id")
|
| 105 |
result_content = json.dumps(json.loads(content), indent=2, ensure_ascii=False)
|
| 106 |
+
display_content = f"<id>{id}</id><content>{content}</content>"
|
| 107 |
# display_content = (
|
| 108 |
# f"**Tool Result:**\n"
|
| 109 |
# f"```json\n"
|
|
|
|
| 133 |
# Pre-compile regex patterns for efficiency
|
| 134 |
# Pattern to find a tool call message
|
| 135 |
tool_call_pattern = re.compile(
|
| 136 |
+
r"<id>(.*?)</id><func_name>(.*?)</func_name><func_args>(.*?)</func_args>",
|
| 137 |
re.DOTALL # Use DOTALL in case arguments contain newlines
|
| 138 |
)
|
| 139 |
# Pattern to find a tool result message
|
| 140 |
tool_result_pattern = re.compile(
|
| 141 |
+
r"<id>(.*?)</id><content>(.*?)</content>",
|
| 142 |
re.DOTALL
|
| 143 |
)
|
| 144 |
|
backend/systemprompt.py
CHANGED
|
@@ -91,8 +91,13 @@ Stage 2: Buying and get info:
|
|
| 91 |
- This phrase when user comfirm that they want to buy the promotion or product.
|
| 92 |
- Ask how many product do they want.
|
| 93 |
- After get quantity, call the "summary_order" will return the promotion_id,quantity and total_price. Confirm user again that the info is correct. **Do not tell promotion_id to the user, map to the name of the promotion in the promotion description. state the user that "เก็ยเงินปลายทาง" is the only payment method available.
|
| 94 |
-
- After user
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
- After get all the personal data, confirm user 1 last time that the info is correct.
|
| 97 |
Stage 3: Send order to the backend system
|
| 98 |
- After all the info correct, call "purchase_product" to send order to the system
|
|
@@ -107,6 +112,7 @@ Stage 4: After sales service
|
|
| 107 |
- Always remember that your response will be given to the tts system to read out loud, avoid using complex or non smooth to read words.
|
| 108 |
- ตอบเป็นประโยคสั้นๆ **ALWAYS** end the sentence with "|" token to indicate the end of the sentence for TTS system. each sentence should not be longer than 20 words.
|
| 109 |
- Do not give the promotion_id to the user, use as a argument of summary_order only.
|
|
|
|
| 110 |
|
| 111 |
"""
|
| 112 |
# 7. Consider the whole conversation,
|
|
|
|
| 91 |
- This phrase when user comfirm that they want to buy the promotion or product.
|
| 92 |
- Ask how many product do they want.
|
| 93 |
- After get quantity, call the "summary_order" will return the promotion_id,quantity and total_price. Confirm user again that the info is correct. **Do not tell promotion_id to the user, map to the name of the promotion in the promotion description. state the user that "เก็ยเงินปลายทาง" is the only payment method available.
|
| 94 |
+
- After the user confirms the order, proceed to collect personal information for shipping. **Ask for and confirm each detail one at a time, in the following order**:
|
| 95 |
+
** ASK ONE BY ONE **
|
| 96 |
+
1. First name (assume that user is thai)
|
| 97 |
+
2. Last name
|
| 98 |
+
3. Shipping address (in this sequence: จังหวัด → เขต/อำเภอ → แขวง/ตำบล → ถนน → หมู่บ้าน/ชื่ออาคาร → ซอย → บ้านเลขที่)
|
| 99 |
+
4. Postal code
|
| 100 |
+
5. Customer telephone number
|
| 101 |
- After get all the personal data, confirm user 1 last time that the info is correct.
|
| 102 |
Stage 3: Send order to the backend system
|
| 103 |
- After all the info correct, call "purchase_product" to send order to the system
|
|
|
|
| 112 |
- Always remember that your response will be given to the tts system to read out loud, avoid using complex or non smooth to read words.
|
| 113 |
- ตอบเป็นประโยคสั้นๆ **ALWAYS** end the sentence with "|" token to indicate the end of the sentence for TTS system. each sentence should not be longer than 20 words.
|
| 114 |
- Do not give the promotion_id to the user, use as a argument of summary_order only.
|
| 115 |
+
- if you unable to answer or recognize what user ask more than 3 times, call "call_admin" to escalate the issue to human agent.
|
| 116 |
|
| 117 |
"""
|
| 118 |
# 7. Consider the whole conversation,
|
backend/tools.py
CHANGED
|
@@ -18,7 +18,7 @@ TOOL_DEFINITIONS =[
|
|
| 18 |
"type": "function",
|
| 19 |
"function": {
|
| 20 |
"name": "get_promotion_description",
|
| 21 |
-
"description": "Use when
|
| 22 |
"parameters": {
|
| 23 |
"type": "object",
|
| 24 |
"properties": {
|
|
@@ -32,7 +32,7 @@ TOOL_DEFINITIONS =[
|
|
| 32 |
"type": "function",
|
| 33 |
"function": {
|
| 34 |
"name": "summary_order",
|
| 35 |
-
"description": "Summarise promotions when
|
| 36 |
"parameters": {
|
| 37 |
"type": "object",
|
| 38 |
"properties": {
|
|
@@ -53,7 +53,7 @@ TOOL_DEFINITIONS =[
|
|
| 53 |
"type": "function",
|
| 54 |
"function": {
|
| 55 |
"name": "purchase_product",
|
| 56 |
-
"description": "Call after
|
| 57 |
"parameters": {
|
| 58 |
"type": "object",
|
| 59 |
"properties": {
|
|
@@ -429,8 +429,46 @@ def execute_tool(name: str, arguments: Dict[str, Any]) -> str:
|
|
| 429 |
if __name__ == "__main__":
|
| 430 |
result = call_admin(
|
| 431 |
cause="ตัวอย่างปัญหา: ไม่สามารถทำรายการสั่งซื้อได้",
|
| 432 |
-
chat_history=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
|
|
|
|
| 434 |
|
| 435 |
)
|
| 436 |
print(result)
|
|
|
|
| 18 |
"type": "function",
|
| 19 |
"function": {
|
| 20 |
"name": "get_promotion_description",
|
| 21 |
+
"description": "Use when user asks about product or promotion details.",
|
| 22 |
"parameters": {
|
| 23 |
"type": "object",
|
| 24 |
"properties": {
|
|
|
|
| 32 |
"type": "function",
|
| 33 |
"function": {
|
| 34 |
"name": "summary_order",
|
| 35 |
+
"description": "Summarise promotions when user confirms they want to buy.",
|
| 36 |
"parameters": {
|
| 37 |
"type": "object",
|
| 38 |
"properties": {
|
|
|
|
| 53 |
"type": "function",
|
| 54 |
"function": {
|
| 55 |
"name": "purchase_product",
|
| 56 |
+
"description": "Call after user confirms their personal information and want to place an order.",
|
| 57 |
"parameters": {
|
| 58 |
"type": "object",
|
| 59 |
"properties": {
|
|
|
|
| 429 |
if __name__ == "__main__":
|
| 430 |
result = call_admin(
|
| 431 |
cause="ตัวอย่างปัญหา: ไม่สามารถทำรายการสั่งซื้อได้",
|
| 432 |
+
chat_history=[{'role': 'assistant', 'metadata': None, 'content': 'สวัสดีค่ะณภัทร 1577Homeshopping ยินดีให้บริการค่ะ', 'options': None},
|
| 433 |
+
{'role': 'user', 'metadata': None, 'content': 'เอ่ออยากได้โปรโมชั่นที่ราคาถูกที่สุดครับ', 'options': None},
|
| 434 |
+
{'role': 'assistant', 'content': None, 'tool_calls': [{'id': 'function-call-10876890856948869365', 'type': 'function', 'function': {'name': 'get_promotion_description', 'arguments': '{"permission":"yes"}'}}]},
|
| 435 |
+
{'role': 'tool', 'tool_call_id': 'function-call-10876890856948869365', 'content': '{"status": "ok", "description": "\\nตัวอย่างรายการสินค้า จาก www.1577shop.com\\n\\n**[2ฟรี2] Trylagina 12X (ไตรลาจิน่า 12X) เซรั่มคืนความอ่อนเยาว์ (30g.) 2 กระปุก ฟรี เซรั่ม (5g.) 2 กระปุก**\\nPromotion_id = \\"00001\\"\\n\\n**Original price was: ฿9,400.00. Current price is: ฿2,900.00.-70%**\\n\\nThe Sense of Youth Infinity รู้สึกถึงความอ่อนเยาว์ไม่มีที่สิ้นสุด TRYLAGINA Age-Defying Collagen Serum 12X การพัฒนาที่ไม่สิ้นสุด สู่ผลิตภัณฑ์ที่ยอดเยี่ยม เพื่อให้คุณได้สัมผัสความอ่อนเยาว์ ตามแบบฉบับของ ไตรลาจีน่า เซรั่มสูตรใหม่ ดีขึ้น 12 เท่า\\n*เมื่อเทียบเท่ากับการใช้ Trylagina Intensive Collagen Mask 12 ครั้ง ช่วยฟื้นบำรุงอย่างล้ำลึก ถึง 5 มิติ เผยผิวใหม่อ่อนเยาว์กว่าที่เคย\\n-90% ของผู้ทดลองใช้พบว่าริ้วรอยลดลง และกระชับขึ้น\\n-87% ของผู้ทดลองใช้พบว่าผิวได้รับความชุ่มชื้นทันทีที่ใช้\\n-82% ของผู้ทดลองใช้พบว่าผิวกระจ่างใสใน 7 วัน\\n\\n5 สารสกัดสําคัญ ที่คิดค้นมาเพื่อแก้ปัญหาผิว\\n1. 5D Matrixcolla ช่วยกระตุ้นการสร้าง Collagen ให้ผิวคืน “ความอ่อนเยาว์”\\n2. HyWhite® ช่วยลดเลือนฝ้า กระ จุดด่างดำ และ a-Linoleic Acid มีคุณสมบัติช่วยให้ผิวขาวกระจ่างใส เพิ่มความสม่ำเสมอให้กับสีผิว\\n3. สารสกัดยีสต์จาก ดอกโฮยาคาร์โนซ่า เติมความแข็งแรงให้กับผิว มอบความแข็งแรงให้กับผิวจากภายใน ช่วยให้ผิวสุขภาพดี เปล่งปลั่ง\\n4. PatcH2O® ช่วยให้ผิวชุ่มชื่นทันที พร้อมล็อกผิวให้ฉ่ำน้ำยาวนาน ถึง 5 วัน หรือ 120 ชั่วโมง *เมื่อใช้เป็นประจำต่อเนื่อง และ สามารถปกป้องผิวจาก มลภาวะฝุ่น PM2.5\\n5. สาหร่ายซุยเซ็นจิ จากประเทศญี่ปุ่น ซึ่งเติบโตในแหล่งน้ำที่อุดมไปด้วยแร่ธาตุจากภูเขาไฟอะโซะ (Aso) เกาะคิวชู (Kyoshu) ช่วยปลอบประโลมผิว ให้ผิวรู้สึกผ่อนคลาย\\nเลขที่ได้รับจดแจ้ง : 11-1-6600001843\\n\\nสิ่งที่คุณจะได้รับ\\n1.Trylagina Age-Defying Collagen Serum 12X ขนาด 30 g. 2 กระปุก\\n2.Trylagina Age-Defying Collagen Serum 12X ขนาด 5 g. 2 กระปุก\\n\\nhttps://www.1577shop.co.th/product/1577-shop-tgn-03\\n-------\\n## (1 ใหญ่) Minus 20 ไมนัสทเวนตี้ ครีมเกล็ดทองคำ ผิวตึง ฉ่ำ ไบร์ท | 30 กรัม\\npromotion-id = \\"00002\\"\\n\\n**Original price was: ฿3,200.00.Current price is: ฿1,890.00.-41%**\\n\\nMinus20 Advanced Youth Anti-Wrinkle Cream\\nครีมบำรุงผิวหน้า ไมนัสทเวนตี้ แอดวานซ์ ยูธ แอนไท ริงเคิล ครีม\\n\\nครีมสูตรเฉพาะเพื่อผิววัย 40+ 50+ 60+ ช่วยตอบโจทย์ปัญหาผิวสาวไทยวัยกลางคน ที่ผ่านช่วงเวลาแห่งการเปลี่ยนแปลง ส่งผลให้มีริ้วรอยร่องลึก ผิวแห้ง หน้าหมองคล้ำ มีฝ้า จุดด่างดำฝังลึก และที่ครีมเดิมที่คุณเคยใช้อาจไม่ได้ผลต่อไป เพราะเราเข้าใจทุกปัญหาจึงพัฒนาไมนัสทเวนตี้มาเป็นสูตรแอดวานซ์ ยูธ เพื่อให้คุณได้สัมผัสผลลัพธ์ผิวที่\\n✨ ตึงกว่าเดิม ริ้วรอยร่องลึกจางลง\\n✨ ฉ่ำกว่าเดิม ชุ่มชื้นอิ่มน้ำยาวนานมากกว่า 24 ชั่วโมง\\n✨ ไบร์ทกว่าเดิม หน้าและดูกระจ่างใส จุดด่างดำจางลง\\n\\nไมนัสทเวนตี้ คัดสรรสารสกัดที่ช่วยตอบโจทย์ปัญหาผิววัยเราอย่างตรงจุดการันตีคุณภาพกลไกลการทำสารของสารกัดด้วยได้รับรางวัลโนเบล แต่ยังอ่อนโยนเหมาะกับทุกสภาพผิว\\n\\nเนื้อผสมครีมเกล็ดทองคำบริสุทธิ์ 99.99% อนุภาคทองละเอียดซึมลึก สัมผัสบางเบา เกลี่ยง่าย ซึมไว ไม่เหนียว ไม่เหนอะหนะ\\n\\n*ผลลัพธ์ขึ้นอยู่กับแต่ละสภาพผิวแต่ละบุคคล\\n• เลขที่ใบรับจดเเจ้ง : 74-1-6600008720\\n• ขนาด 30 กรัม\\n\\n✨วิธีใช้:\\n• หลังล้างหน้าทาครีมไมนัสทเวนตี้ในปริมาณที่เหมาะสม\\n• แตะและลูบไล้เบาๆลงบนผิวหน้าและลำคอ\\n• ใช้ทาเช้าและเย็น เป็นประจำทุกวัน\\n\\n✨เคล็ดลับ :\\n• เก็บครีมบำรุงผิวในอุณหภูมิที่เหมาะสม\\n• ทาครีมกันแดดเป็นประจำทุกวัน เพื่อปกป้องผิวจากแสงแดด\\n\\nสิ่งที่จะได้รับ\\n1. Minus20 Advanced Youth Anti-Wrinkle Cream (30g) จำนวน 1 กระปุก\\n\\n[https://www.1577shop.co.th/product/1577-shop-msn-001](https:/www.1577shop.co.th/product/1577-shop-msn-001)\\n-------\\n## [2ฟรี2] Minus 20 (ไมนัสทเวนตี้) ครีมเกล็ดทองคำ ผิวตึง ฉ่ำ ไบร์ท | เซตขายดี\\npromotion_id = \\"00003\\n\\n**Original price was: ฿8,180.00.Current price is: ฿2,900.00.-65%**\\n\\nMinus20 Advanced Youth Anti-Wrinkle Cream\\nครีมบำรุงผิวหน้า ไมนัสทเวนตี้ แอดวานซ์ ยูธ แอนไท ริงเคิล ครีมครีมสูตรเฉพาะเพื่อผิววัย 40+ 50+ 60+ ช่วยตอบโจทย์ปัญหาผิวสาวไทยวัยกลางคน ที่ผ่านช่วงเวลาแห่งการเปลี่ยนแปลง ส่งผลให้มีริ้วรอยร่องลึก ผิวแห้ง หน้าหมองคล้ำ มีฝ้า จุดด่างดำฝังลึก และที่ครีมเดิมที่คุณเคยใช้อาจไม่ได้ผลต่อไป เพราะเราเข้าใจทุกปัญหาจึงพัฒนาไมนัสทเวนตี้มาเป็นสูตรแอดวานซ์ ยูธ เพื่อให้คุณได้สัมผัสผลลัพธ์ผิวที่\\n✨ ตึงกว่าเดิม ริ้วรอยร่องลึกจางลง\\n✨ ฉ่ำกว่าเดิม ชุ่มชื้นอิ่มน้ำยาวนานมากกว่า 24 ชั่วโมง\\n✨ ไบร์ทกว่าเดิม หน้าและดูกระจ่างใส จุดด่างดำจางลงไมนัสทเวนตี้ คัดสรรสารสกัดที่ช่วยตอบโจทย์ปัญหาผิววัยเราอย่างตรงจุดการันตีคุณภาพกลไกลการทำสารของสารกัดด้วยได้รับรางวัลโนเบล แต่ยังอ่อนโยนเหมาะกับทุกสภาพผิวเนื้อผสมครีมเกล็ดทองคำบริสุทธิ์ 99.99% อนุภาคทองละเอียดซึมลึก สัมผัสบางเบา เกลี่ยง่าย ซึมไว ไม่เหนียว ไม่เหนอะหนะ*ผลลัพธ์ขึ้นอยู่กับแต่ละสภาพผิวแต่ละบุคคล\\n• เลขที่ใบรับจดเเจ้ง : 74-1-6600008720\\n• ขนาด 30 กรัม\\n\\n✨วิธีใช้:\\n• หลังล้างหน้าทาครีมไมนัสทเวนตี้ในปริมาณที่เหมาะสม\\n• แตะและลูบไล้เบาๆลงบนผิวหน้าและลำคอ\\n• ใช้ทาเช้าและเย็น เป็นประจำทุกวัน\\n\\n✨เคล็ดลับ :\\n• เก็บครีมบำรุงผิวในอุณหภูมิที่เหมาะสม\\n• ทาครีมกันแดดเป็นประจำทุกวัน เพื่อปกป้องผิวจากแสงแดด\\n\\nสิ่งที่จะได้รับ\\n1. Minus20 Advanced Youth Anti-Wrinkle Cream (30g) จำนวน 2 กระปุก\\n2. Minus20 Advanced Youth Anti-Wrinkle Cream (8g) จำนวน 2 กระปุก\\n\\nhttps://www.1577shop.co.th/product/1577-shop-mns-003\\n-------\\n## [2ฟรี1] Trylagina 12X (ไตรลาจิน่า 12X) เซรั่มคืนความอ่อนเยาว์ (30g.) 2 กระปุก ฟรี ทริปเปิลไมเซล่ามูสโฟม (150ml.)\\npromotion-id = \\"00004\\"\\n\\n**Original price was: ฿8,800.00. Current price is: ฿2,900.00.-68%**\\n\\nThe Sense of Youth Infinity รู้สึกถึงความอ่อนเยาว์ไม่มีที่สิ้นสุด\\nTRYLAGINA Age-Defying Collagen Serum 12X การพัฒนาที่ไม่สิ้นสุด สู่ผลิตภัณฑ์ที่ยอดเยี่ยม เพื่อให้คุณได้สัมผัสความอ่อนเยาว์ ตามแบบฉบับของ ไตรลาจีน่า ผสาน 5 สารสกัดสําคัญ ที่คิดค้นมาเพื่อแก้ปัญหาผิว\\n\\n-90% ของผู้ทดลองใช้พบว่าริ้วรอยลดลง และกระชับขึ้น\\n-87% ของผู้ทดลองใช้พบว่าผิวได้รับความชุ่มชื้นทั��ทีที่ใช้\\n-82% ของผู้ทดลองใช้พบว่าผิวกระจ่างใสใน 7 วัน\\n\\n*สิ่งที่คุณจะได้รับ\\n1.Trylagina Age-Defying Collagen Serum 12X ขนาด 30 g. 2 กระปุก\\n2.Trylagina Triple Micellar Mousse Foam ขนาด 150 ml. 1 ขวด\\n\\n[https://www.1577shop.co.th/product/1577-shop-tgn-04](https:/www.1577shop.co.th/product/1577-shop-tgn-04)\\n-------\\n## [2ฟรี1] Trylagina 12X (ไตรลาจิน่า 12X) เซรั่มคืนความอ่อนเยาว์ (30g.) 2 กระปุก ฟรี ครีมกันแดด (30g.)\\npromotion_id = \\"00005\\"\\n\\n**Original price was: ฿8,690.00.Current price is: ฿2,900.00.-67%**\\n\\nThe Sense of Youth Infinity รู้สึกถึงความอ่อนเยาว์ไม่มีที่สิ้นสุด\\nTRYLAGINA Age-Defying Collagen Serum 12X การพัฒนาที่ไม่สิ้นสุด สู่ผลิตภัณฑ์ที่ยอดเยี่ยม เพื่อให้คุณได้สัมผัสความอ่อนเยาว์ ตามแบบฉบับของ ไตรลาจีน่า ผสาน 5 สารสกัดสําคัญ ที่คิดค้นมาเพื่อแก้ปัญหาผิว\\n\\n-90% ของผู้ทดลองใช้พบว่าริ้วรอยลดลง และกระชับขึ้น\\n-87% ของผู้ทดลองใช้พบว่าผิวได้รับความชุ่มชื้นทันทีที่ใช้\\n-82% ของผู้ทดลองใช้พบว่าผิวกระจ่างใสใน 7 วัน\\n\\n*สิ่งที่คุณจะได้รับ\\n1. Trylagina Age-Defying Collagen Serum 12X ขนาด (30g.) 1 กระปุก\\n2. Trylagina Age Defense Sunscreen Serum SPF50+ PA++++ ขนาด (30g.) 1 หลอด\\n\\nhttps://www.1577shop.co.th/product/1577-shop-tgn-05\\n-------\\nTRYLAGINA Age-Defying Collagen Serum 12X การพัฒนาที่ไม่สิ้นสุด สู่ผลิตภัณฑ์ที่ยอดเยี่ยม เพื่อให้คุณได้สัมผัสความอ่อนเยาว์ ตามแบบฉบับของ ไตรลาจีน่า เซรั่มสูตรใหม่ ดีขึ้น 12 เท่า *เมื่อเทียบเท่ากับการใช้ Trylagina Intensive Collagen Mask 12 ครั้ง ช่วยฟื้นบำรุงอย่างล้ำลึก ถึง 5 มิติ เผยผิวใหม่อ่อนเยาว์กว่าที่เคย\\n\\n-90% ของผู้ทดลองใช้พบว่าริ้วรอยลดลง และกระชับขึ้น\\n-87% ของผู้ทดลองใช้พบว่าผิวได้รับความชุ่มชื้นทันทีที่ใช้\\n-82% ของผู้ทดลองใช้พบว่าผิวกระจ่างใสใน 7 วัน\\n\\n5 สารสกัดสําคัญ ที่คิดค้นมาเพื่อแก้ปัญหาผิว\\n1. 5D Matrixcolla ช่วยกระตุ้นการสร้าง Collagen ให้ผิวคืน “ความอ่อนเยาว์”\\n2. HyWhite® ช่วยลดเลือนฝ้า กระ จุดด่างดำ และ a-Linoleic Acid มีคุณสมบัติช่วยให้ผิวขาวกระจ่างใส เพิ่มความสม่ำเสมอให้กับสีผิว\\n3. สารสกัดยีสต์จาก ดอกโฮยาคาร์โนซ่า เติมความแข็งแรงให้กับผิว มอบความแข็งแรงให้กับผิวจากภายใน ช่วยให้ผิวสุขภาพดี เปล่งปลั่ง\\n4. PatcH2O® ช่วยให้ผิวชุ่มชื่นทันที พร้อมล็อกผิวให้ฉ่ำน้ำยาวนาน ถึง 5 วัน หรือ 120 ชั่วโมง *เมื่อใช้เป็นประจำต่อเนื่อง และ สามารถปกป้องผิวจาก มลภาวะฝุ่น PM2.5\\n5. สาหร่ายซุยเซ็นจิ จากประเทศญี่ปุ่น ซึ่งเติบโตในแหล่งน้ำที่อุดมไปด้วยแร่ธาตุจากภูเขาไฟอะโซะ (Aso) เกาะคิวชู (Kyoshu) ช่วยปลอบประโลมผิว ให้ผิวรู้สึกผ่อนคลาย\\n\\n��อแนะนําวิธีการใช้ผลิตภัณฑ์ เพื่อการฟื้นฟูผิวอย่างเต็มประสิทธิภาพ\\nSTEP 1 หลังทำความสะอาดผิวหน้า เตรียมผิวพร้อมรับการบำรุง ใช้ไม้พายตักเซรั่มลงบนหลังมือ\\nSTEP 2 แต้มเซรั่มลงบนผิวหน้า 5 จุด ได้แก่บริเวณ หน้าผาก ปลายจมูก พวงแก้มซ้าย พวงแก้มขวา และปลายคาง\\nSTEP 3 ลูบไล้เซรั่มด้วยปลายนิ้วทั้งสองข้าง เพื่อปลดปล่อยคุณค่าของสารสกัด จากนั้นจึงกดเบาๆ ลงบนผิวหน้าและลำคอ ใช้ทั้งเช้าและเย็น\\nเลขที่ได้รับจดแจ้ง : 11-1-6600001843"}'}, {'role': 'assistant', 'metadata': None, 'content': 'ตอนนี้มีโปรโมชั่น Trylagina 12X เซรั่มคืนความอ่อนเยาว์ค่ะ| เป็นเซรั่มสูตรใหม่ดีขึ้น 12 เท่า| ปกติ 9,400 บาทเหลือเพียง 2,900 บาทค่ะ| แล้วก็มี Minus 20 ครีมเกล็ดทองคำ| ผิวตึงฉ่ำไบร์ท| ขนาด 30 กรัมค่ะ| ปกติ 3,200 บาทเหลือ 1,890 บาทค่ะ| สนใจโปรโมชั่นไหนดีคะ|', 'options': None}, {'role': 'user', 'metadata': None, 'content': 'เอาไมนัส Taventy ครับ', 'options': None}, {'role': 'assistant', 'metadata': None, 'content': 'ลูกค้าสนใจรับเป็นตัว Minus 20 ครีมเกล็ดทองคำ| ผิวตึงฉ่ำไบร์ท| ขนาด 30 กรัมใช่ไหมคะ| รับกี่กระปุกดีคะ|', 'options': None}, {'role': 'user', 'metadata': None, 'content': 'หนึ่งครับ', 'options': None}, {'role': 'assistant', 'content': None, 'tool_calls': [{'id': 'function-call-16782869619373994503', 'type': 'function', 'function': {'name': 'summary_order', 'arguments': '{"quantity":1,"promotion_id":"00002"}'}}]}, {'role': 'tool', 'tool_call_id': 'function-call-16782869619373994503', 'content': '{"status": "ok", "promotion_id": "00002", "unit_price": 1890, "quantity": 1, "total_price": 1890, "currency": "THB"}'}, {'role': 'assistant', 'metadata': None, 'content': 'รับเป็น Minus 20 ครีมเกล็ดทองคำ| 1 กระปุกนะคะ| ทั้งหมด 1,890 บาทค่ะ| การชำระเงินเป็นการเก็บเงินปลายทางอย่างเดียวนะคะ| ไม่ทราบว่าข้อมูลถูกต้องไหมคะ|', 'options': None},
|
| 436 |
+
{'role': 'user', 'metadata': None, 'content': 'โถครับ', 'options': None},
|
| 437 |
+
{'role': 'assistant', 'metadata': None, 'content': 'ขออนุญาตสอบถามชื่อจริงลูกค้าก่อนเลยนะคะ|', 'options': None},
|
| 438 |
+
{'role': 'user', 'metadata': None, 'content': 'จุลจักรครับ', 'options': None},
|
| 439 |
+
{'role': 'assistant', 'metadata': None, 'content': 'ขอชื่อเล่นหรือชื่อจริงอีกครั้งนะคะ|', 'options': None},
|
| 440 |
+
{'role': 'user', 'metadata': None, 'content': 'จุลจักรครับ', 'options': None},
|
| 441 |
+
{'role': 'assistant', 'metadata': None, 'content': 'สะกดให้หน่อยได้ไหมคะ|', 'options': None},
|
| 442 |
+
{'role': 'user', 'metadata': None, 'content': 'ถูกแล้วครับ', 'options': None},
|
| 443 |
+
{'role': 'assistant', 'metadata': None, 'content': 'ขอทราบชื่อจริงเป็นภาษาไทยอีกครั้งนะคะ|', 'options': None},
|
| 444 |
+
{'role': 'user', 'metadata': None, 'content': 'จุลจักรอี', 'options': None},
|
| 445 |
+
{'role': 'assistant', 'metadata': None, 'content': 'เป็น จุลจักรนะคะ| แล้วนามสกุลล่ะคะ|', 'options': None},
|
| 446 |
+
{'role': 'user', 'metadata': None, 'content': 'กาญจนาเอกินครับ', 'options': None},
|
| 447 |
+
{'role': 'assistant', 'metadata': None, 'content': 'นามสกุลกาญจนาเอกินนะคะ| ขอที่อยู่สำหรับจัดส่งสินค้าเลยนะคะ| รบกวนแจ้งเป็นจังหวัดก่อนเลยค่ะ|', 'options': None},
|
| 448 |
+
{'role': 'user', 'metadata': None, 'content': 'กรุงเทพครับ', 'options': None},
|
| 449 |
+
{'role': 'assistant', 'metadata': None, 'content': 'เขตหรืออำเภออะไรคะ|', 'options': None},
|
| 450 |
+
{'role': 'user', 'metadata': None, 'content': 'น้องเจ้าครับ', 'options': None},
|
| 451 |
+
{'role': 'assistant', 'metadata': None, 'content': 'เขตหนองจอกนะคะ| แขวงหรือตำบลอะไรดีคะ|', 'options': None},
|
| 452 |
+
{'role': 'user', 'metadata': None, 'content': 'ลําปักชีครับ', 'options': None},
|
| 453 |
+
{'role': 'assistant', 'metadata': None, 'content': 'แขวงลำผักชีนะคะ| ถนนอะไรคะ|', 'options': None},
|
| 454 |
+
{'role': 'user', 'metadata': None, 'content': 'สวินทวงศ์ครับ', 'options': None},
|
| 455 |
+
{'role': 'assistant', 'metadata': None, 'content': 'ถนนสุวินทวงศ์นะคะ| มีหมู่บ้านหรือชื่ออาคารไหมคะ|', 'options': None},
|
| 456 |
+
{'role': 'user', 'metadata': None, 'content': 'หมู่บ้านฟลล่าวิวครับ', 'options': None},
|
| 457 |
+
{'role': 'assistant', 'metadata': None, 'content': 'หมู่บ้านฟลอร่าวิลล์นะคะ| ซอยล่ะคะ|', 'options': None},
|
| 458 |
+
{'role': 'user', 'metadata': None, 'content': 'สวินทวงศ์สามสิบแปดครับ', 'options': None},
|
| 459 |
+
{'role': 'assistant', 'metadata': None, 'content': 'ซอยสุวินทวงศ์ 38 นะคะ| บ้านเลขที่อะไรคะ|', 'options': None},
|
| 460 |
+
{'role': 'user', 'metadata': None, 'content': 'เก้าสิบสองทับสิบห้าครับ', 'options': None},
|
| 461 |
+
{'role': 'assistant', 'metadata': None, 'content': 'บ้านเลขที่ 92/15 นะคะ| รหัสไปรษณีย์อะไรคะ|', 'options': None},
|
| 462 |
+
{'role': 'user', 'metadata': None, 'content': 'หนึ่งศูนย์ห้าสามศูนย์ครับ', 'options': None},
|
| 463 |
+
{'role': 'assistant', 'metadata': None, 'content': 'รหัสไปรษณีย์ 10530 นะคะ| ขอเบอร์โทรศัพท์ติดต่อด้วยค่ะ|', 'options': None},
|
| 464 |
+
{'role': 'user', 'metadata': None, 'content': 'ส่วนหกสาม เจ็ดห้าสาม หนึ่งสามเจ็ดเก้า', 'options': None},
|
| 465 |
+
{'role': 'assistant', 'metadata': None, 'content': 'เบอร์ 063-753-1379 นะคะ| สรุปข้อมูลการสั่งซื้อนะคะ| สินค้าคือ Minus 20 ครีมเกล็ดทองคำ| จำนวน 1 กระปุก| ชื่อจุลจักรกาญจนาเอกิน| ที่อยู่ 92/15 หมู่บ้านฟลอร่าวิลล์ซอยสุวินทวงศ์ 38 ถนนสุวินทวงศ์แขวงลำผักชีเขตหนองจอกกรุงเทพฯ 10530| เบอร์โทรศัพท์ 063-753-1379| ข้อมูลทั้งหมดถูกต้องนะคะ|', 'options': None},
|
| 466 |
+
{'role': 'user', 'metadata': None, 'content': 'โทรครับ', 'options': None},
|
| 467 |
+
{'role': 'assistant', 'content': None, 'tool_calls': [{'id': 'function-call-9238332831786515181', 'type': 'function', 'function': {'name': 'purchase_product', 'arguments': '{"tel":"0637531379","name":"จุลจักร","address":"92/15 หมู่บ้านฟลอร่าวิลล์ซอยสุวินทวงศ์ 38 ถนนสุวินทวงศ์ แขวงลำผักชี เขตหนองจอก กรุงเทพฯ 10530","surname":"กาญจนาเอกิน","quantity":1,"promotion_id":"00002"}'}}]},
|
| 468 |
+
{'role': 'tool', 'tool_call_id': 'function-call-9238332831786515181', 'content': '{"status": "success", "data": {"status": "success", "message": "Order info received and appended to history"}}'}, {'role': 'assistant', 'metadata': None, 'content': 'คำสั่งซื้อเรียบร้อยแล้วค่ะ| ขอบคุณที่ใช้บริการ 1577 Homeshopping นะคะ| ลูกค้าจะได้รับสินค้าภายใน 5-7 วันทำการค่ะ| มีอะไรให้ช่วยอีกไหมคะ|', 'options': None},
|
| 469 |
+
{'role': 'user', 'content': 'ขอคุยกับแอดมินหน่อยครับ'}]
|
| 470 |
|
| 471 |
+
|
| 472 |
|
| 473 |
)
|
| 474 |
print(result)
|
backend/tts.py
CHANGED
|
@@ -41,7 +41,8 @@ def synthesize_text(text: str, lang = 'th' , speed = 2.0):
|
|
| 41 |
' 4.': ' สี่.', '/n4.': ' สี่.', ' 10.': ' สิบ.', '/n10.': ' สิบ.',
|
| 42 |
'พ.ศ.': 'พอศอ', '. ': ' ', '-19': ' 19', 'เพื่อยก': 'เพื่อ ยก',
|
| 43 |
'√': 'เครื่องหมายติ๊กถูก', '=>': 'จากนั้นเลือก', 'รอกด': 'รอ กด', ' ณ ': ' นะ ',
|
| 44 |
-
'[2ฟรี1]': 'สองฟรีหนึ่ง', "+": 'บวก', "12X": "สิบสองเอ็กซ์", "12x": "สิบสองเอ็กซ์",'[2ฟร2]': 'สองฟรีสอง'
|
|
|
|
| 45 |
|
| 46 |
}
|
| 47 |
for old, new in replacements.items():
|
|
|
|
| 41 |
' 4.': ' สี่.', '/n4.': ' สี่.', ' 10.': ' สิบ.', '/n10.': ' สิบ.',
|
| 42 |
'พ.ศ.': 'พอศอ', '. ': ' ', '-19': ' 19', 'เพื่อยก': 'เพื่อ ยก',
|
| 43 |
'√': 'เครื่องหมายติ๊กถูก', '=>': 'จากนั้นเลือก', 'รอกด': 'รอ กด', ' ณ ': ' นะ ',
|
| 44 |
+
'[2ฟรี1]': 'สองฟรีหนึ่ง', "+": 'บวก', "12X": "สิบสองเอ็กซ์", "12x": "สิบสองเอ็กซ์",'[2ฟร2]': 'สองฟรีสอง',
|
| 45 |
+
"/": "ทับ"
|
| 46 |
|
| 47 |
}
|
| 48 |
for old, new in replacements.items():
|