Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chatbot canifa
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
chatbot canifa
Commits
bacfd1d4
Commit
bacfd1d4
authored
Feb 27, 2026
by
Vũ Hoàng Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: strengthen stock check prompt - enforce check_is_stock for 'con size' queries
parent
deac59b1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
37 deletions
+42
-37
system_prompt.txt
backend/agent/system_prompt.txt
+24
-4
test_knowledge_search.py
backend/tests/test_knowledge_search.py
+18
-33
No files found.
backend/agent/system_prompt.txt
View file @
bacfd1d4
...
@@ -1141,14 +1141,29 @@ price_max = 400000
...
@@ -1141,14 +1141,29 @@ price_max = 400000
---
---
### 5.5.5. 📏 PHÂN BIỆT "CÓ SIZE GÌ" vs "CÒN SIZE GÌ" (QUAN TRỌNG!)
### 5.5.5. 📏 PHÂN BIỆT "CÓ SIZE GÌ" vs "CÒN SIZE GÌ" (
CỰC KỲ
QUAN TRỌNG!)
**
2 câu hỏi này KHÁC NHAU HOÀN TOÀN — bot PHẢI phân biệt
:**
**
⚠️ 2 câu hỏi này KHÁC NHAU HOÀN TOÀN — bot PHẢI phân biệt CHÍNH XÁC
:**
| Câu hỏi | Ý nghĩa | Hành động |
| Câu hỏi | Ý nghĩa | Hành động |
|----------|---------|-----------|
|----------|---------|-----------|
| "Có size gì?" / "Size nào?" | SP được sản xuất những size nào? | **Liệt kê từ `size_scale`** trong data tool đã trả về |
| "Có size gì?" / "Size nào?" | SP được sản xuất những size nào? | **Liệt kê từ `size_scale`** trong data tool đã trả về |
| "Còn size gì?" / "Size M còn không?" / "Hết size chưa?" | Size nào CÒN HÀNG? | **GỌI `check_is_stock`** để check tồn kho thật |
| "**Còn** size gì?" / "**Còn** những size nào?" / "Size M **còn** không?" / "**Hết** size chưa?" / "**Còn hàng** không?" | Size nào CÒN HÀNG? | **BẮT BUỘC GỌI `check_is_stock`** |
**⛔ CẤM TUYỆT ĐỐI:** Khi khách hỏi có chữ "CÒN" hoặc "HẾT", KHÔNG ĐƯỢC trả lời từ `size_scale`. PHẢI gọi `check_is_stock` trước!
**VÍ DỤ QUAN TRỌNG:**
```
Khách: "Mẫu này còn những size nào?" ← CÓ CHỮ "CÒN" → BẮT BUỘC GỌI check_is_stock!
❌ SAI: "Có size S, M, L, XL, XXL nhé!" (trả từ size_scale, KHÔNG check tồn kho thật)
✅ ĐÚNG: Gọi check_is_stock → "Dạ hiện size S, M, L vẫn còn hàng. Size XL và XXL tạm hết ạ!"
Khách: "Mẫu này có size gì?" ← KHÔNG có chữ "CÒN" → Liệt kê từ size_scale
✅ ĐÚNG: "Có size S, M, L, XL, XXL nhé!"
```
**TRIGGER WORDS BẮT BUỘC GỌI `check_is_stock`:**
"còn hàng", "hết hàng", "còn size", "còn những size", "size nào còn", "còn bán", "hết chưa", "còn không", "check tồn", "kiểm tra tồn", "còn màu", "hết màu"
---
---
...
@@ -1176,18 +1191,23 @@ price_max = 400000
...
@@ -1176,18 +1191,23 @@ price_max = 400000
**BẮT BUỘC gọi `check_is_stock` với SKU + size cụ thể:**
**BẮT BUỘC gọi `check_is_stock` với SKU + size cụ thể:**
**TRIGGER WORDS:** "còn hàng", "hết hàng", "còn size", "
size M còn không", "check tồn kho", "còn bán không
"
**TRIGGER WORDS:** "còn hàng", "hết hàng", "còn size", "
còn những size nào", "size M còn không", "check tồn kho", "còn bán không", "hết chưa
"
```
```
Khách: "Mã [6IT25W010] còn size M không?"
Khách: "Mã [6IT25W010] còn size M không?"
→ Bot GỌI check_is_stock(sku="6IT25W010", size="M")
→ Bot GỌI check_is_stock(sku="6IT25W010", size="M")
→ Trả lời theo kết quả: "Dạ size M vẫn còn hàng ạ!" hoặc "Dạ size M hết rồi, còn L và XL thôi ạ!"
→ Trả lời theo kết quả: "Dạ size M vẫn còn hàng ạ!" hoặc "Dạ size M hết rồi, còn L và XL thôi ạ!"
Khách: "Mẫu này còn những size nào?"
→ Bot GỌI check_is_stock(sku=SKU_từ_context)
→ Trả lời: "Dạ hiện còn size S, M, L ạ! Size XL tạm hết."
Khách: "Cái áo vừa xem còn hàng không?"
Khách: "Cái áo vừa xem còn hàng không?"
→ Bot đọc SUMMARY_HISTORY → biết SKU → GỌI check_is_stock
→ Bot đọc SUMMARY_HISTORY → biết SKU → GỌI check_is_stock
→ Trả lời chính xác
→ Trả lời chính xác
```
```
---
---
#### 💡 VÍ DỤ THỰC TẾ:
#### 💡 VÍ DỤ THỰC TẾ:
...
...
backend/tests/test_knowledge_search.py
View file @
bacfd1d4
"""Check Hoàng Mai in store table"""
"""Push updated system prompt to Langfuse"""
import
asyncio
,
sys
,
os
import
os
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
from
dotenv
import
load_dotenv
from
common.starrocks_connection
import
get_db_connection
load_dotenv
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))),
".env"
))
from
langfuse
import
Langfuse
async
def
main
():
prompt_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))),
sr
=
get_db_connection
()
"agent"
,
"system_prompt.txt"
)
rows
=
await
sr
.
execute_query_async
(
"""
with
open
(
prompt_path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
SELECT store_name, address, city, state, phone_number, schedule_name
content
=
f
.
read
()
FROM shared_source.chatbot_rsa_store_schedule_with_text_embedding
WHERE LOWER(city) LIKE '
%
hoàng mai
%
'
OR LOWER(address) LIKE '
%
hoàng mai
%
'
OR LOWER(store_name) LIKE '
%
hoàng mai
%
'
"""
)
print
(
f
"Found: {len(rows)}"
)
for
r
in
rows
:
print
(
r
)
# Also check Phúc Yên
lf
=
Langfuse
()
print
(
"
\n
=== PHÚC YÊN ==="
)
lf
.
create_prompt
(
rows2
=
await
sr
.
execute_query_async
(
"""
name
=
"canifa-stylist-system-prompt"
,
SELECT store_name, address, city, state
prompt
=
content
,
FROM shared_source.chatbot_rsa_store_schedule_with_text_embedding
labels
=
[
"production"
],
WHERE LOWER(city) LIKE '
%
phúc yên
%
' OR LOWER(state) LIKE '
%
vĩnh phúc
%
'
tags
=
[
"canifa"
,
"system-prompt"
],
"""
)
type
=
"text"
,
print
(
f
"Found: {len(rows2)}"
)
)
for
r
in
rows2
:
print
(
"✅ System prompt pushed to Langfuse!"
)
print
(
r
)
loop
=
asyncio
.
new_event_loop
()
asyncio
.
set_event_loop
(
loop
)
try
:
loop
.
run_until_complete
(
main
())
finally
:
loop
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment