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
17077cdf
Commit
17077cdf
authored
Feb 12, 2026
by
Vũ Hoàng Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: skip response cache for /chat-dev endpoint
parent
4e384443
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
2 deletions
+5
-2
controller.py
backend/agent/controller.py
+3
-2
product_mapping.py
backend/agent/tools/product_mapping.py
+1
-0
chatbot_route.py
backend/api/chatbot_route.py
+1
-0
No files found.
backend/agent/controller.py
View file @
17077cdf
...
@@ -42,6 +42,7 @@ async def chat_controller(
...
@@ -42,6 +42,7 @@ async def chat_controller(
return_user_insight
:
bool
=
False
,
return_user_insight
:
bool
=
False
,
is_authenticated
:
bool
=
False
,
# New: để track user vs guest
is_authenticated
:
bool
=
False
,
# New: để track user vs guest
device_id
:
str
|
None
=
None
,
# Device ID từ request (có cả khi authenticated)
device_id
:
str
|
None
=
None
,
# Device ID từ request (có cả khi authenticated)
skip_cache
:
bool
=
False
,
# Skip response cache (for dev endpoint)
)
->
dict
:
)
->
dict
:
"""
"""
Controller main logic for non-streaming chat requests.
Controller main logic for non-streaming chat requests.
...
@@ -63,7 +64,7 @@ async def chat_controller(
...
@@ -63,7 +64,7 @@ async def chat_controller(
logger
.
info
(
"chat_controller start: model=
%
s, key=
%
s"
,
model_name
,
identity_key
)
logger
.
info
(
"chat_controller start: model=
%
s, key=
%
s"
,
model_name
,
identity_key
)
# ====================== CACHE LAYER ======================
# ====================== CACHE LAYER ======================
if
REDIS_CACHE_TURN_ON
:
if
REDIS_CACHE_TURN_ON
and
not
skip_cache
:
cached_response
=
await
redis_cache
.
get_response
(
user_id
=
identity_key
,
query
=
query
)
cached_response
=
await
redis_cache
.
get_response
(
user_id
=
identity_key
,
query
=
query
)
if
cached_response
:
if
cached_response
:
logger
.
info
(
"CACHE HIT key=
%
s"
,
identity_key
)
logger
.
info
(
"CACHE HIT key=
%
s"
,
identity_key
)
...
@@ -303,7 +304,7 @@ async def chat_controller(
...
@@ -303,7 +304,7 @@ async def chat_controller(
if
user_insight_dict
is
not
None
:
if
user_insight_dict
is
not
None
:
response_payload
[
"user_insight"
]
=
user_insight_dict
response_payload
[
"user_insight"
]
=
user_insight_dict
if
REDIS_CACHE_TURN_ON
:
if
REDIS_CACHE_TURN_ON
and
not
skip_cache
:
await
redis_cache
.
set_response
(
user_id
=
identity_key
,
query
=
query
,
response_data
=
response_payload
,
ttl
=
300
)
await
redis_cache
.
set_response
(
user_id
=
identity_key
,
query
=
query
,
response_data
=
response_payload
,
ttl
=
300
)
background_tasks
.
add_task
(
background_tasks
.
add_task
(
...
...
backend/agent/tools/product_mapping.py
View file @
17077cdf
...
@@ -64,6 +64,7 @@ PRODUCT_LINE_MAP: dict[str, list[str]] = {
...
@@ -64,6 +64,7 @@ PRODUCT_LINE_MAP: dict[str, list[str]] = {
"Bộ quần áo"
:
[
"bộ quần áo"
,
"đồ bộ"
],
"Bộ quần áo"
:
[
"bộ quần áo"
,
"đồ bộ"
],
"Bộ mặc nhà"
:
[
"bộ mặc nhà"
,
"đồ ngủ"
,
"đồ mặc nhà"
],
"Bộ mặc nhà"
:
[
"bộ mặc nhà"
,
"đồ ngủ"
,
"đồ mặc nhà"
],
"Blazer"
:
[
"blazer"
],
"Blazer"
:
[
"blazer"
],
"Tất"
:
[
"tất"
,
"vớ"
,
"bao chân"
,
"vớ chân"
,
"tất chân"
],
}
}
# ==============================================================================
# ==============================================================================
...
...
backend/api/chatbot_route.py
View file @
17077cdf
...
@@ -107,6 +107,7 @@ async def fashion_qa_chat_dev(request: Request, req: QueryRequest, background_ta
...
@@ -107,6 +107,7 @@ async def fashion_qa_chat_dev(request: Request, req: QueryRequest, background_ta
return_user_insight
=
False
,
return_user_insight
=
False
,
is_authenticated
=
is_authenticated
,
# Pass auth status for Langfuse metadata
is_authenticated
=
is_authenticated
,
# Pass auth status for Langfuse metadata
device_id
=
device_id
,
# Luôn truyền device_id để lưu vào Langfuse metadata
device_id
=
device_id
,
# Luôn truyền device_id để lưu vào Langfuse metadata
skip_cache
=
True
,
# Dev endpoint: luôn gọi LLM mới, không cache
)
)
usage_info
=
await
message_limit_service
.
increment
(
usage_info
=
await
message_limit_service
.
increment
(
...
...
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