Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai company
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
0
Merge Requests
0
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
ai company
Commits
5fe080db
Commit
5fe080db
authored
May 13, 2026
by
Vũ Hoàng Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: clean up scratch files and prepare production DB
parent
159099af
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
11 deletions
+85
-11
chatbot_canifa
backend/chatbot_canifa
+0
-1
run_sqlite_concat.py
backend/database/run_sqlite_concat.py
+12
-9
gemini_wrap.py
backend/gemini_wrap.py
+72
-0
uv.lock
backend/uv.lock
+1
-1
No files found.
chatbot_canifa
@
f9b10ebe
Subproject commit f9b10ebef38a7af9ffb488678084f0ebac581afc
backend/database/run_sqlite_concat.py
View file @
5fe080db
...
...
@@ -11,19 +11,19 @@ def update_sqlite_colors():
cursor
=
conn
.
cursor
()
query
=
"""
UPDATE sr__test_db__magento_product_dimension_with_text_embedding
UPDATE sr__test_db__magento_product_dimension_with_text_embedding
SET description_data_full = json_set(
description_data_full,
'$.mau_sac',
description_data_full,
'$.mau_sac',
(
SELECT GROUP_CONCAT(DISTINCT master_color)
FROM sr__test_db__magento_product_dimension_with_text_embedding sub
SELECT GROUP_CONCAT(DISTINCT master_color)
FROM sr__test_db__magento_product_dimension_with_text_embedding sub
WHERE sub.magento_ref_code = sr__test_db__magento_product_dimension_with_text_embedding.magento_ref_code
AND sub.master_color IS NOT NULL
AND sub.master_color IS NOT NULL
AND sub.master_color != ''
)
)
WHERE description_data_full IS NOT NULL
WHERE description_data_full IS NOT NULL
AND json_valid(description_data_full) = 1;
"""
...
...
@@ -37,8 +37,8 @@ def update_sqlite_colors():
# Test 1 mã
cursor
.
execute
(
"""
SELECT magento_ref_code, json_extract(description_data_full, '$.mau_sac')
FROM sr__test_db__magento_product_dimension_with_text_embedding
SELECT magento_ref_code, json_extract(description_data_full, '$.mau_sac')
FROM sr__test_db__magento_product_dimension_with_text_embedding
WHERE magento_ref_code = '1AK25C001' LIMIT 1
"""
)
sample
=
cursor
.
fetchone
()
...
...
@@ -52,3 +52,6 @@ def update_sqlite_colors():
if
__name__
==
"__main__"
:
update_sqlite_colors
()
backend/gemini_wrap.py
0 → 100644
View file @
5fe080db
import
subprocess
import
logging
import
itertools
import
threading
logger
=
logging
.
getLogger
(
__name__
)
# Round-robin xoay vòng qua 7 model để tận dụng hết quota
MODELS
=
[
"gemini-3.1-flash-lite-preview"
,
# 3.1 lite # 2.5 lite
"gemini-3-flash-preview"
,
# 3.0 flash
"gemini-3.1-pro-preview"
,
# 3.1 pro
"gemini-2.5-pro"
,
# 2.5 pro
"gemma-4-31b-it"
,
# Gemma 4 31B
"gemma-4-26b-a4b-it"
,
# Gemma 4 26B
]
_model_cycle
=
itertools
.
cycle
(
MODELS
)
_model_lock
=
threading
.
Lock
()
def
_next_model
():
with
_model_lock
:
return
next
(
_model_cycle
)
def
run_gemini_cli
(
prompt
:
str
,
model
:
str
=
None
)
->
str
:
"""
Wrapper gọi trực tiếp Gemini CLI của hệ thống qua subprocess.
Sử dụng cờ -p (hoặc --prompt) để chạy ở chế độ non-interactive (headless).
Tự động xoay vòng model nếu không truyền model cụ thể.
"""
try
:
import
shutil
import
os
chosen_model
=
model
or
_next_model
()
# Tìm đường dẫn thực tế của lệnh gemini.CMD
gemini_cmd
=
shutil
.
which
(
"gemini"
)
if
not
gemini_cmd
:
return
"Error: Không tìm thấy lệnh gemini"
# Tìm đường dẫn file JS gốc của Gemini CLI
gemini_js
=
os
.
path
.
join
(
os
.
path
.
dirname
(
gemini_cmd
),
"node_modules"
,
"@google"
,
"gemini-cli"
,
"bundle"
,
"gemini.js"
)
# Gọi trực tiếp qua Node.js (không qua shell CMD) để không bị lỗi khi prompt chứa dấu ngoặc kép JSON
result
=
subprocess
.
run
(
[
"node"
,
gemini_js
,
"-p"
,
prompt
,
"--model"
,
chosen_model
],
capture_output
=
True
,
text
=
True
,
encoding
=
"utf-8"
,
check
=
True
)
logger
.
info
(
f
"Dùng model: {chosen_model}"
)
return
result
.
stdout
.
strip
()
except
subprocess
.
CalledProcessError
as
e
:
logger
.
error
(
f
"Lỗi khi gọi Gemini CLI: {e.stderr}"
)
print
(
f
"Error output: {e.stderr}"
)
return
""
except
FileNotFoundError
:
logger
.
error
(
"Không tìm thấy lệnh 'gemini'. Hãy chắc chắn Gemini CLI đã được cài đặt và nằm trong PATH."
)
return
""
if
__name__
==
"__main__"
:
print
(
"Đang test Gemini CLI Wrapper..."
)
test_prompt
=
"Xin chào, hãy trả lời ngắn gọn trong 1 câu: bạn có thể sinh JSON được không?"
print
(
f
"Prompt: {test_prompt}"
)
response
=
run_gemini_cli
(
test_prompt
)
print
(
"
\n
--- KẾT QUẢ TỪ GEMINI CLI ---"
)
print
(
response
)
print
(
"-----------------------------"
)
backend/uv.lock
View file @
5fe080db
version = 1
revision = 3
requires-python = ">=3.1
4
"
requires-python = ">=3.1
2
"
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