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
d20b1e77
Commit
d20b1e77
authored
Jan 27, 2026
by
Vũ Hoàng Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project state
parent
d21e9eec
Changes
73
Show whitespace changes
Inline
Side-by-side
Showing
73 changed files
with
15039 additions
and
15043 deletions
+15039
-15043
.gitignore
.gitignore
+55
-55
.gitlab-ci.yml
.gitlab-ci.yml
+19
-19
.pre-commit-config.yaml
.pre-commit-config.yaml
+10
-10
.dockerignore
backend/.dockerignore
+10
-10
.editorconfig
backend/.editorconfig
+23
-23
.gitignore
backend/.gitignore
+4
-4
5.10.0
backend/5.10.0
+6
-6
API_DOCUMENTATION.md
backend/API_DOCUMENTATION.md
+144
-144
Dockerfile.dev
backend/Dockerfile.dev
+31
-31
Dockerfile.prod
backend/Dockerfile.prod
+21
-21
Makefile
backend/Makefile
+37
-37
__init__.py
backend/__init__.py
+3
-3
__init__.py
backend/agent/__init__.py
+13
-13
controller.py
backend/agent/controller.py
+164
-164
graph.py
backend/agent/graph.py
+159
-159
helper.py
backend/agent/helper.py
+173
-173
mock_controller.py
backend/agent/mock_controller.py
+297
-301
models.py
backend/agent/models.py
+57
-57
__init__.py
backend/agent/nodes/__init__.py
+7
-7
prompt.py
backend/agent/prompt.py
+36
-36
system_prompt.txt
backend/agent/system_prompt.txt
+434
-434
__init__.py
backend/agent/tools/__init__.py
+9
-9
brand_knowledge_tool.py
backend/agent/tools/brand_knowledge_tool.py
+83
-83
customer_info_tool.py
backend/agent/tools/customer_info_tool.py
+58
-58
data_retrieval_tool.py
backend/agent/tools/data_retrieval_tool.py
+270
-270
get_tools.py
backend/agent/tools/get_tools.py
+25
-25
product_search_helpers.py
backend/agent/tools/product_search_helpers.py
+163
-163
save.py
backend/agent/tools/save.py
+384
-384
cache_analytics_route.py
backend/api/cache_analytics_route.py
+126
-126
chatbot_route.py
backend/api/chatbot_route.py
+108
-108
conservation_route.py
backend/api/conservation_route.py
+153
-153
prompt_route.py
backend/api/prompt_route.py
+83
-83
__init__.py
backend/common/__init__.py
+1
-1
cache.py
backend/common/cache.py
+161
-161
canifa_api.py
backend/common/canifa_api.py
+99
-102
conversation_manager.py
backend/common/conversation_manager.py
+309
-310
add_context_to_sizes.py
backend/common/datadb/add_context_to_sizes.py
+72
-72
ingest_knowledge.py
backend/common/datadb/ingest_knowledge.py
+117
-117
tonghop.txt
backend/common/datadb/tonghop.txt
+1879
-1879
tonghop_with_context.txt
backend/common/datadb/tonghop_with_context.txt
+1879
-1879
embedding_service.py
backend/common/embedding_service.py
+132
-132
image_storage.py
backend/common/image_storage.py
+67
-67
langfuse_client.py
backend/common/langfuse_client.py
+107
-107
llm_factory.py
backend/common/llm_factory.py
+149
-149
message_limit.py
backend/common/message_limit.py
+314
-314
openai_client.py
backend/common/openai_client.py
+63
-63
reset_limit.py
backend/common/reset_limit.py
+58
-58
starrocks_connection.py
backend/common/starrocks_connection.py
+253
-253
user_identity.py
backend/common/user_identity.py
+133
-133
config.py
backend/config.py
+143
-143
add_context_to_sizes.py
backend/datadb/add_context_to_sizes.py
+72
-72
ingest_knowledge.py
backend/datadb/ingest_knowledge.py
+117
-117
tonghop.txt
backend/datadb/tonghop.txt
+1879
-1879
tonghop_with_context.txt
backend/datadb/tonghop_with_context.txt
+1879
-1879
docker-compose.dev.yml
backend/docker-compose.dev.yml
+32
-32
docker-compose.prod.yml
backend/docker-compose.prod.yml
+34
-34
CACHE_PERFORMANCE_OPTIMIZATION.md
backend/docs/CACHE_PERFORMANCE_OPTIMIZATION.md
+211
-211
SEMANTIC_CACHE.md
backend/docs/SEMANTIC_CACHE.md
+399
-399
SEMANTIC_CACHE_SUMMARY.md
backend/docs/SEMANTIC_CACHE_SUMMARY.md
+265
-265
docx.md
backend/docx.md
+27
-27
entrypoint.sh
backend/entrypoint.sh
+18
-18
hyde_pure_query.txt
backend/logs/hyde_pure_query.txt
+26
-26
nginx.conf.example
backend/nginx.conf.example
+106
-106
plan.md
backend/plan.md
+39
-39
promtail-config.yaml
backend/promtail-config.yaml
+19
-19
pyproject.toml
backend/pyproject.toml
+69
-69
pyrightconfig.json
backend/pyrightconfig.json
+19
-19
pyscn.yaml
backend/pyscn.yaml
+31
-31
readme.md
backend/readme.md
+368
-368
requirements.txt
backend/requirements.txt
+133
-133
run.py
backend/run.py
+171
-171
run.txt
backend/run.txt
+17
-17
server.py
backend/server.py
+7
-3
No files found.
.gitignore
View file @
d20b1e77
.gitlab-ci.yml
View file @
d20b1e77
.pre-commit-config.yaml
View file @
d20b1e77
backend/.dockerignore
View file @
d20b1e77
backend/.editorconfig
View file @
d20b1e77
backend/.gitignore
View file @
d20b1e77
backend/5.10.0
View file @
d20b1e77
backend/API_DOCUMENTATION.md
View file @
d20b1e77
backend/Dockerfile.dev
View file @
d20b1e77
backend/Dockerfile.prod
View file @
d20b1e77
backend/Makefile
View file @
d20b1e77
backend/__init__.py
View file @
d20b1e77
backend/agent/__init__.py
View file @
d20b1e77
backend/agent/controller.py
View file @
d20b1e77
backend/agent/graph.py
View file @
d20b1e77
backend/agent/helper.py
View file @
d20b1e77
backend/agent/mock_controller.py
View file @
d20b1e77
...
...
@@ -15,7 +15,7 @@ from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
from
langchain_core.runnables
import
RunnableConfig
from
common.conversation_manager
import
ConversationManager
,
get_conversation_manager
from
common.langfuse_client
import
get_callback_handler
,
langfuse_trace_context
from
common.langfuse_client
import
get_callback_handler
from
common.llm_factory
import
create_llm
from
config
import
DEFAULT_MODEL
...
...
@@ -73,8 +73,6 @@ async def chat_controller(
)
try
:
# 🔥 Wrap graph execution với langfuse_trace_context để set user_id cho tất cả observations
with
langfuse_trace_context
(
user_id
=
user_id
,
session_id
=
user_id
):
# TỐI ƯU: Chạy Graph
result
=
await
graph
.
ainvoke
(
initial_state
,
config
=
exec_config
)
...
...
@@ -106,7 +104,6 @@ async def chat_controller(
except
(
json
.
JSONDecodeError
,
Exception
)
as
e
:
# Nếu AI trả về text thường (hiếm khi xảy ra trong JSON mode) thì ignore
logger
.
warning
(
f
"Could not parse AI response as JSON: {e}"
)
pass
# BACKGROUND TASK: Lưu history nhanh gọn
background_tasks
.
add_task
(
...
...
@@ -266,7 +263,6 @@ async def mock_chat_controller(
)
try
:
with
langfuse_trace_context
(
user_id
=
user_id
,
session_id
=
user_id
):
# Chạy Graph với tools THẬT
result
=
await
graph
.
ainvoke
(
initial_state
,
config
=
exec_config
)
...
...
backend/agent/models.py
View file @
d20b1e77
backend/agent/nodes/__init__.py
View file @
d20b1e77
backend/agent/prompt.py
View file @
d20b1e77
backend/agent/system_prompt.txt
View file @
d20b1e77
backend/agent/tools/__init__.py
View file @
d20b1e77
backend/agent/tools/brand_knowledge_tool.py
View file @
d20b1e77
backend/agent/tools/customer_info_tool.py
View file @
d20b1e77
backend/agent/tools/data_retrieval_tool.py
View file @
d20b1e77
backend/agent/tools/get_tools.py
View file @
d20b1e77
backend/agent/tools/product_search_helpers.py
View file @
d20b1e77
backend/agent/tools/save.py
View file @
d20b1e77
backend/api/cache_analytics_route.py
View file @
d20b1e77
backend/api/chatbot_route.py
View file @
d20b1e77
backend/api/conservation_route.py
View file @
d20b1e77
backend/api/prompt_route.py
View file @
d20b1e77
backend/common/__init__.py
View file @
d20b1e77
backend/common/cache.py
View file @
d20b1e77
backend/common/canifa_api.py
View file @
d20b1e77
...
...
@@ -10,10 +10,8 @@ import httpx
logger
=
logging
.
getLogger
(
__name__
)
# URL API Canifa
CANIFA_CUSTOMER_API
=
"https://vsf2.canifa.com/v1/magento/customer"
# GraphQL Query Body giả lập (để lấy User Info)
CANIFA_QUERY_BODY
=
[
{
"customer"
:
"customer-custom-query"
,
...
...
@@ -24,7 +22,6 @@ CANIFA_QUERY_BODY = [
{},
]
async
def
verify_canifa_token
(
token
:
str
)
->
dict
[
str
,
Any
]
|
None
:
"""
Verify token với API Canifa (Magento).
...
...
@@ -42,7 +39,7 @@ async def verify_canifa_token(token: str) -> dict[str, Any] | None:
headers
=
{
"accept"
:
"application/json, text/plain, */*"
,
"content-type"
:
"application/json"
,
"Cookie"
:
f
"vsf-customer={token}"
,
# Quan trọng: Gửi token dưới dạng Cookie
"Cookie"
:
f
"vsf-customer={token}"
,
}
try
:
...
...
backend/common/conversation_manager.py
View file @
d20b1e77
import
asyncio
import
json
import
logging
import
asyncio
from
datetime
import
datetime
,
date
from
datetime
import
datetime
from
typing
import
Any
import
psycopg
...
...
@@ -147,8 +147,7 @@ class ConversationManager:
final_query
=
sql
.
SQL
(
" "
)
.
join
(
query_parts
)
pool
=
await
self
.
_get_pool
()
async
with
pool
.
connection
()
as
conn
:
async
with
conn
.
cursor
()
as
cursor
:
async
with
pool
.
connection
()
as
conn
,
conn
.
cursor
()
as
cursor
:
await
cursor
.
execute
(
final_query
,
tuple
(
params
))
results
=
await
cursor
.
fetchall
()
...
...
backend/common/datadb/add_context_to_sizes.py
View file @
d20b1e77
backend/common/datadb/ingest_knowledge.py
View file @
d20b1e77
backend/common/datadb/tonghop.txt
View file @
d20b1e77
backend/common/datadb/tonghop_with_context.txt
View file @
d20b1e77
backend/common/embedding_service.py
View file @
d20b1e77
backend/common/image_storage.py
View file @
d20b1e77
backend/common/langfuse_client.py
View file @
d20b1e77
backend/common/llm_factory.py
View file @
d20b1e77
backend/common/message_limit.py
View file @
d20b1e77
backend/common/openai_client.py
View file @
d20b1e77
backend/common/reset_limit.py
View file @
d20b1e77
backend/common/starrocks_connection.py
View file @
d20b1e77
backend/common/user_identity.py
View file @
d20b1e77
backend/config.py
View file @
d20b1e77
backend/datadb/add_context_to_sizes.py
View file @
d20b1e77
backend/datadb/ingest_knowledge.py
View file @
d20b1e77
backend/datadb/tonghop.txt
View file @
d20b1e77
backend/datadb/tonghop_with_context.txt
View file @
d20b1e77
backend/docker-compose.dev.yml
View file @
d20b1e77
backend/docker-compose.prod.yml
View file @
d20b1e77
backend/docs/CACHE_PERFORMANCE_OPTIMIZATION.md
View file @
d20b1e77
backend/docs/SEMANTIC_CACHE.md
View file @
d20b1e77
backend/docs/SEMANTIC_CACHE_SUMMARY.md
View file @
d20b1e77
backend/docx.md
View file @
d20b1e77
backend/entrypoint.sh
View file @
d20b1e77
backend/logs/hyde_pure_query.txt
View file @
d20b1e77
backend/nginx.conf.example
View file @
d20b1e77
backend/plan.md
View file @
d20b1e77
backend/promtail-config.yaml
View file @
d20b1e77
backend/pyproject.toml
View file @
d20b1e77
backend/pyrightconfig.json
View file @
d20b1e77
backend/pyscn.yaml
View file @
d20b1e77
backend/readme.md
View file @
d20b1e77
backend/requirements.txt
View file @
d20b1e77
backend/run.py
View file @
d20b1e77
backend/run.txt
View file @
d20b1e77
...
...
@@ -12,6 +12,6 @@ docker restart chatbot-backend && docker logs -f chatbot-backend
docker logs -f chatbot-backend
docker restart c
hatbot-backend
docker restart c
anifa_backend
sudo docker compose -f docker-compose.prod.yml up -d --build
backend/server.py
View file @
d20b1e77
...
...
@@ -20,7 +20,7 @@ from common.langfuse_client import get_langfuse_client
from
common.middleware
import
middleware_manager
from
config
import
PORT
# Configure Logging
# Configure Logging
P
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
"
%(asctime)
s [
%(levelname)
s]
%(name)
s:
%(message)
s"
,
...
...
@@ -67,12 +67,16 @@ app.include_router(conservation_router)
app
.
include_router
(
chatbot_router
)
app
.
include_router
(
prompt_router
)
from
api.mock_api_route
import
router
as
mock_router
app
.
include_router
(
mock_router
)
print
(
"✅ Mock API Router mounted at /api/mock"
)
# --- MOCK API FOR LOAD TESTING ---
try
:
from
api.mock_api_route
import
router
as
mock_router
app
.
include_router
(
mock_router
)
app
.
include_router
(
mock_router
,
prefix
=
"/api"
)
print
(
"✅ Mock API Router mounted at /api/mock"
)
except
ImportError
:
print
(
"⚠️ Mock Router not found, skipping..."
)
...
...
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