Spaces:
Running
Running
Commit ·
d796362
1
Parent(s): bb81714
Revert "Thử dùng app_old.py để kiểm tra tính năng multimodal"
Browse filesThis reverts commit bb81714c275c5ce0e18f1c0605cd91256c56ff4c.
- app.py +40 -4
- app_new.py → app_old.py +4 -40
app.py
CHANGED
|
@@ -11,7 +11,7 @@ import uuid
|
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
|
| 13 |
|
| 14 |
-
API_BASE_URL =
|
| 15 |
|
| 16 |
|
| 17 |
@dataclass
|
|
@@ -26,6 +26,7 @@ class ConversationState:
|
|
| 26 |
product_model_search: bool = False
|
| 27 |
method: str = "dense" # "dense", "sparse", "hybrid"
|
| 28 |
is_enhance_query: bool = False # New field for query enhancement toggle
|
|
|
|
| 29 |
# New fields for delayed cleanup - now using asyncio
|
| 30 |
pending_cleanup: bool = False
|
| 31 |
cleanup_task: Optional[asyncio.Task] = None
|
|
@@ -42,6 +43,7 @@ class ConversationState:
|
|
| 42 |
self.product_model_search = False
|
| 43 |
self.method = "dense"
|
| 44 |
self.is_enhance_query = False
|
|
|
|
| 45 |
# Reset cleanup fields but don't touch tasks
|
| 46 |
self.pending_cleanup = False
|
| 47 |
self.last_activity = datetime.now()
|
|
@@ -196,6 +198,12 @@ class StateManager:
|
|
| 196 |
"""Toggle query enhancement mode"""
|
| 197 |
state.is_enhance_query = not state.is_enhance_query
|
| 198 |
state.last_activity = datetime.now()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
@staticmethod
|
| 201 |
async def cycle_search_method(state: ConversationState):
|
|
@@ -221,7 +229,8 @@ class StateManager:
|
|
| 221 |
"selected_model": state.selected_model,
|
| 222 |
"product_model_search": state.product_model_search,
|
| 223 |
"method": state.method,
|
| 224 |
-
"is_enhance_query": state.is_enhance_query
|
|
|
|
| 225 |
}
|
| 226 |
return status
|
| 227 |
|
|
@@ -262,7 +271,8 @@ class ChatService:
|
|
| 262 |
"session_id": state.session_id,
|
| 263 |
"llm_model": state.selected_model,
|
| 264 |
"debug": "Normal",
|
| 265 |
-
"is_enhance_query": str(state.is_enhance_query).lower()
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
# Use multipart form data for image upload
|
|
@@ -281,7 +291,8 @@ class ChatService:
|
|
| 281 |
"product_model_search": str(state.product_model_search).lower(),
|
| 282 |
"method": state.method,
|
| 283 |
"llm_model": state.selected_model,
|
| 284 |
-
"is_enhance_query": str(state.is_enhance_query).lower()
|
|
|
|
| 285 |
}
|
| 286 |
resp = await client.post(
|
| 287 |
f"{API_BASE_URL}/chat",
|
|
@@ -598,6 +609,7 @@ class UIService:
|
|
| 598 |
}
|
| 599 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 600 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
|
|
|
| 601 |
|
| 602 |
return [
|
| 603 |
cl.Action(name="show_specs", value="specs", label="📄 Thông số kỹ thuật", payload={"action": "specs"}),
|
|
@@ -607,6 +619,7 @@ class UIService:
|
|
| 607 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 608 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 609 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
|
|
|
| 610 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 611 |
]
|
| 612 |
|
|
@@ -621,11 +634,13 @@ class UIService:
|
|
| 621 |
}
|
| 622 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 623 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
|
|
|
| 624 |
|
| 625 |
return [
|
| 626 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 627 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 628 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
|
|
|
| 629 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 630 |
]
|
| 631 |
|
|
@@ -826,6 +841,27 @@ async def on_toggle_product_search(action):
|
|
| 826 |
await UIService.send_message_with_buttons(status_message, app_state, author="assistant")
|
| 827 |
|
| 828 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
@cl.action_callback("toggle_enhance_query")
|
| 830 |
async def on_toggle_enhance_query(action):
|
| 831 |
"""Handle toggle enhance query action"""
|
|
|
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
|
| 13 |
|
| 14 |
+
API_BASE_URL = "https://sale-agent-m179.onrender.com"
|
| 15 |
|
| 16 |
|
| 17 |
@dataclass
|
|
|
|
| 26 |
product_model_search: bool = False
|
| 27 |
method: str = "dense" # "dense", "sparse", "hybrid"
|
| 28 |
is_enhance_query: bool = False # New field for query enhancement toggle
|
| 29 |
+
enhanced_image_retrieval: bool = False # New field for enhanced image retrieval toggle
|
| 30 |
# New fields for delayed cleanup - now using asyncio
|
| 31 |
pending_cleanup: bool = False
|
| 32 |
cleanup_task: Optional[asyncio.Task] = None
|
|
|
|
| 43 |
self.product_model_search = False
|
| 44 |
self.method = "dense"
|
| 45 |
self.is_enhance_query = False
|
| 46 |
+
self.enhanced_image_retrieval = False
|
| 47 |
# Reset cleanup fields but don't touch tasks
|
| 48 |
self.pending_cleanup = False
|
| 49 |
self.last_activity = datetime.now()
|
|
|
|
| 198 |
"""Toggle query enhancement mode"""
|
| 199 |
state.is_enhance_query = not state.is_enhance_query
|
| 200 |
state.last_activity = datetime.now()
|
| 201 |
+
|
| 202 |
+
@staticmethod
|
| 203 |
+
async def toggle_enhanced_image_retrieval(state: ConversationState):
|
| 204 |
+
"""Toggle enhanced image retrieval mode"""
|
| 205 |
+
state.enhanced_image_retrieval = not state.enhanced_image_retrieval
|
| 206 |
+
state.last_activity = datetime.now()
|
| 207 |
|
| 208 |
@staticmethod
|
| 209 |
async def cycle_search_method(state: ConversationState):
|
|
|
|
| 229 |
"selected_model": state.selected_model,
|
| 230 |
"product_model_search": state.product_model_search,
|
| 231 |
"method": state.method,
|
| 232 |
+
"is_enhance_query": state.is_enhance_query,
|
| 233 |
+
"enhanced_image_retrieval": state.enhanced_image_retrieval
|
| 234 |
}
|
| 235 |
return status
|
| 236 |
|
|
|
|
| 271 |
"session_id": state.session_id,
|
| 272 |
"llm_model": state.selected_model,
|
| 273 |
"debug": "Normal",
|
| 274 |
+
"is_enhance_query": str(state.is_enhance_query).lower(),
|
| 275 |
+
"enhanced_image_retrieval": str(state.enhanced_image_retrieval).lower()
|
| 276 |
}
|
| 277 |
|
| 278 |
# Use multipart form data for image upload
|
|
|
|
| 291 |
"product_model_search": str(state.product_model_search).lower(),
|
| 292 |
"method": state.method,
|
| 293 |
"llm_model": state.selected_model,
|
| 294 |
+
"is_enhance_query": str(state.is_enhance_query).lower(),
|
| 295 |
+
"enhanced_image_retrieval": str(state.enhanced_image_retrieval).lower()
|
| 296 |
}
|
| 297 |
resp = await client.post(
|
| 298 |
f"{API_BASE_URL}/chat",
|
|
|
|
| 609 |
}
|
| 610 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 611 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
| 612 |
+
enhanced_retrieval_status = "🖼️ Tìm bằng ảnh nâng cao (Đang tắt)" if not state.enhanced_image_retrieval else "🖼️ Tìm bằng ảnh nâng cao (Đang bật)"
|
| 613 |
|
| 614 |
return [
|
| 615 |
cl.Action(name="show_specs", value="specs", label="📄 Thông số kỹ thuật", payload={"action": "specs"}),
|
|
|
|
| 619 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 620 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 621 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
| 622 |
+
cl.Action(name="toggle_enhanced_image_retrieval", value="toggle_enhanced_retrieval", label=enhanced_retrieval_status, payload={"action": "toggle_enhanced_retrieval"}),
|
| 623 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 624 |
]
|
| 625 |
|
|
|
|
| 634 |
}
|
| 635 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 636 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
| 637 |
+
enhanced_retrieval_status = "🖼️ Tìm bằng ảnh nâng cao (Đang tắt)" if not state.enhanced_image_retrieval else "🖼️ Tìm bằng ảnh nâng cao (Đang bật)"
|
| 638 |
|
| 639 |
return [
|
| 640 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 641 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 642 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
| 643 |
+
cl.Action(name="toggle_enhanced_image_retrieval", value="toggle_enhanced_retrieval", label=enhanced_retrieval_status, payload={"action": "toggle_enhanced_retrieval"}),
|
| 644 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 645 |
]
|
| 646 |
|
|
|
|
| 841 |
await UIService.send_message_with_buttons(status_message, app_state, author="assistant")
|
| 842 |
|
| 843 |
|
| 844 |
+
@cl.action_callback("toggle_enhanced_image_retrieval")
|
| 845 |
+
async def on_toggle_enhanced_image_retrieval(action):
|
| 846 |
+
"""Handle toggle enhanced image retrieval action"""
|
| 847 |
+
app_state = await ensure_session_state()
|
| 848 |
+
if app_state is None:
|
| 849 |
+
await cl.Message(content="Error: Session state not found", author="assistant").send()
|
| 850 |
+
return
|
| 851 |
+
|
| 852 |
+
await StateManager.toggle_enhanced_image_retrieval(app_state)
|
| 853 |
+
|
| 854 |
+
status_message = (
|
| 855 |
+
"✅ **Đã bật tìm bằng ảnh nâng cao**\n\n"
|
| 856 |
+
"Hệ thống sẽ sử dụng Gemini để phân tích kỹ hình ảnh và tạo từ khóa tìm kiếm chi tiết."
|
| 857 |
+
if app_state.enhanced_image_retrieval
|
| 858 |
+
else "✅ **Đã tắt tìm bằng ảnh nâng cao**\n\n"
|
| 859 |
+
"Hệ thống sẽ sử dụng tìm kiếm hình ảnh thông thường (Visual Semantic Search)."
|
| 860 |
+
)
|
| 861 |
+
|
| 862 |
+
await UIService.send_message_with_buttons(status_message, app_state, author="assistant")
|
| 863 |
+
|
| 864 |
+
|
| 865 |
@cl.action_callback("toggle_enhance_query")
|
| 866 |
async def on_toggle_enhance_query(action):
|
| 867 |
"""Handle toggle enhance query action"""
|
app_new.py → app_old.py
RENAMED
|
@@ -11,7 +11,7 @@ import uuid
|
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
|
| 13 |
|
| 14 |
-
API_BASE_URL =
|
| 15 |
|
| 16 |
|
| 17 |
@dataclass
|
|
@@ -26,7 +26,6 @@ class ConversationState:
|
|
| 26 |
product_model_search: bool = False
|
| 27 |
method: str = "dense" # "dense", "sparse", "hybrid"
|
| 28 |
is_enhance_query: bool = False # New field for query enhancement toggle
|
| 29 |
-
enhanced_image_retrieval: bool = False # New field for enhanced image retrieval toggle
|
| 30 |
# New fields for delayed cleanup - now using asyncio
|
| 31 |
pending_cleanup: bool = False
|
| 32 |
cleanup_task: Optional[asyncio.Task] = None
|
|
@@ -43,7 +42,6 @@ class ConversationState:
|
|
| 43 |
self.product_model_search = False
|
| 44 |
self.method = "dense"
|
| 45 |
self.is_enhance_query = False
|
| 46 |
-
self.enhanced_image_retrieval = False
|
| 47 |
# Reset cleanup fields but don't touch tasks
|
| 48 |
self.pending_cleanup = False
|
| 49 |
self.last_activity = datetime.now()
|
|
@@ -198,12 +196,6 @@ class StateManager:
|
|
| 198 |
"""Toggle query enhancement mode"""
|
| 199 |
state.is_enhance_query = not state.is_enhance_query
|
| 200 |
state.last_activity = datetime.now()
|
| 201 |
-
|
| 202 |
-
@staticmethod
|
| 203 |
-
async def toggle_enhanced_image_retrieval(state: ConversationState):
|
| 204 |
-
"""Toggle enhanced image retrieval mode"""
|
| 205 |
-
state.enhanced_image_retrieval = not state.enhanced_image_retrieval
|
| 206 |
-
state.last_activity = datetime.now()
|
| 207 |
|
| 208 |
@staticmethod
|
| 209 |
async def cycle_search_method(state: ConversationState):
|
|
@@ -229,8 +221,7 @@ class StateManager:
|
|
| 229 |
"selected_model": state.selected_model,
|
| 230 |
"product_model_search": state.product_model_search,
|
| 231 |
"method": state.method,
|
| 232 |
-
"is_enhance_query": state.is_enhance_query
|
| 233 |
-
"enhanced_image_retrieval": state.enhanced_image_retrieval
|
| 234 |
}
|
| 235 |
return status
|
| 236 |
|
|
@@ -271,8 +262,7 @@ class ChatService:
|
|
| 271 |
"session_id": state.session_id,
|
| 272 |
"llm_model": state.selected_model,
|
| 273 |
"debug": "Normal",
|
| 274 |
-
"is_enhance_query": str(state.is_enhance_query).lower()
|
| 275 |
-
"enhanced_image_retrieval": str(state.enhanced_image_retrieval).lower()
|
| 276 |
}
|
| 277 |
|
| 278 |
# Use multipart form data for image upload
|
|
@@ -291,8 +281,7 @@ class ChatService:
|
|
| 291 |
"product_model_search": str(state.product_model_search).lower(),
|
| 292 |
"method": state.method,
|
| 293 |
"llm_model": state.selected_model,
|
| 294 |
-
"is_enhance_query": str(state.is_enhance_query).lower()
|
| 295 |
-
"enhanced_image_retrieval": str(state.enhanced_image_retrieval).lower()
|
| 296 |
}
|
| 297 |
resp = await client.post(
|
| 298 |
f"{API_BASE_URL}/chat",
|
|
@@ -609,7 +598,6 @@ class UIService:
|
|
| 609 |
}
|
| 610 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 611 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
| 612 |
-
enhanced_retrieval_status = "🖼️ Tìm bằng ảnh nâng cao (Đang tắt)" if not state.enhanced_image_retrieval else "🖼️ Tìm bằng ảnh nâng cao (Đang bật)"
|
| 613 |
|
| 614 |
return [
|
| 615 |
cl.Action(name="show_specs", value="specs", label="📄 Thông số kỹ thuật", payload={"action": "specs"}),
|
|
@@ -619,7 +607,6 @@ class UIService:
|
|
| 619 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 620 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 621 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
| 622 |
-
cl.Action(name="toggle_enhanced_image_retrieval", value="toggle_enhanced_retrieval", label=enhanced_retrieval_status, payload={"action": "toggle_enhanced_retrieval"}),
|
| 623 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 624 |
]
|
| 625 |
|
|
@@ -634,13 +621,11 @@ class UIService:
|
|
| 634 |
}
|
| 635 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 636 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
| 637 |
-
enhanced_retrieval_status = "🖼️ Tìm bằng ảnh nâng cao (Đang tắt)" if not state.enhanced_image_retrieval else "🖼️ Tìm bằng ảnh nâng cao (Đang bật)"
|
| 638 |
|
| 639 |
return [
|
| 640 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 641 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 642 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
| 643 |
-
cl.Action(name="toggle_enhanced_image_retrieval", value="toggle_enhanced_retrieval", label=enhanced_retrieval_status, payload={"action": "toggle_enhanced_retrieval"}),
|
| 644 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 645 |
]
|
| 646 |
|
|
@@ -841,27 +826,6 @@ async def on_toggle_product_search(action):
|
|
| 841 |
await UIService.send_message_with_buttons(status_message, app_state, author="assistant")
|
| 842 |
|
| 843 |
|
| 844 |
-
@cl.action_callback("toggle_enhanced_image_retrieval")
|
| 845 |
-
async def on_toggle_enhanced_image_retrieval(action):
|
| 846 |
-
"""Handle toggle enhanced image retrieval action"""
|
| 847 |
-
app_state = await ensure_session_state()
|
| 848 |
-
if app_state is None:
|
| 849 |
-
await cl.Message(content="Error: Session state not found", author="assistant").send()
|
| 850 |
-
return
|
| 851 |
-
|
| 852 |
-
await StateManager.toggle_enhanced_image_retrieval(app_state)
|
| 853 |
-
|
| 854 |
-
status_message = (
|
| 855 |
-
"✅ **Đã bật tìm bằng ảnh nâng cao**\n\n"
|
| 856 |
-
"Hệ thống sẽ sử dụng Gemini để phân tích kỹ hình ảnh và tạo từ khóa tìm kiếm chi tiết."
|
| 857 |
-
if app_state.enhanced_image_retrieval
|
| 858 |
-
else "✅ **Đã tắt tìm bằng ảnh nâng cao**\n\n"
|
| 859 |
-
"Hệ thống sẽ sử dụng tìm kiếm hình ảnh thông thường (Visual Semantic Search)."
|
| 860 |
-
)
|
| 861 |
-
|
| 862 |
-
await UIService.send_message_with_buttons(status_message, app_state, author="assistant")
|
| 863 |
-
|
| 864 |
-
|
| 865 |
@cl.action_callback("toggle_enhance_query")
|
| 866 |
async def on_toggle_enhance_query(action):
|
| 867 |
"""Handle toggle enhance query action"""
|
|
|
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
|
| 13 |
|
| 14 |
+
API_BASE_URL = os.getenv("API_BASE_URL")
|
| 15 |
|
| 16 |
|
| 17 |
@dataclass
|
|
|
|
| 26 |
product_model_search: bool = False
|
| 27 |
method: str = "dense" # "dense", "sparse", "hybrid"
|
| 28 |
is_enhance_query: bool = False # New field for query enhancement toggle
|
|
|
|
| 29 |
# New fields for delayed cleanup - now using asyncio
|
| 30 |
pending_cleanup: bool = False
|
| 31 |
cleanup_task: Optional[asyncio.Task] = None
|
|
|
|
| 42 |
self.product_model_search = False
|
| 43 |
self.method = "dense"
|
| 44 |
self.is_enhance_query = False
|
|
|
|
| 45 |
# Reset cleanup fields but don't touch tasks
|
| 46 |
self.pending_cleanup = False
|
| 47 |
self.last_activity = datetime.now()
|
|
|
|
| 196 |
"""Toggle query enhancement mode"""
|
| 197 |
state.is_enhance_query = not state.is_enhance_query
|
| 198 |
state.last_activity = datetime.now()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
@staticmethod
|
| 201 |
async def cycle_search_method(state: ConversationState):
|
|
|
|
| 221 |
"selected_model": state.selected_model,
|
| 222 |
"product_model_search": state.product_model_search,
|
| 223 |
"method": state.method,
|
| 224 |
+
"is_enhance_query": state.is_enhance_query
|
|
|
|
| 225 |
}
|
| 226 |
return status
|
| 227 |
|
|
|
|
| 262 |
"session_id": state.session_id,
|
| 263 |
"llm_model": state.selected_model,
|
| 264 |
"debug": "Normal",
|
| 265 |
+
"is_enhance_query": str(state.is_enhance_query).lower()
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
# Use multipart form data for image upload
|
|
|
|
| 281 |
"product_model_search": str(state.product_model_search).lower(),
|
| 282 |
"method": state.method,
|
| 283 |
"llm_model": state.selected_model,
|
| 284 |
+
"is_enhance_query": str(state.is_enhance_query).lower()
|
|
|
|
| 285 |
}
|
| 286 |
resp = await client.post(
|
| 287 |
f"{API_BASE_URL}/chat",
|
|
|
|
| 598 |
}
|
| 599 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 600 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
|
|
|
| 601 |
|
| 602 |
return [
|
| 603 |
cl.Action(name="show_specs", value="specs", label="📄 Thông số kỹ thuật", payload={"action": "specs"}),
|
|
|
|
| 607 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 608 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 609 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
|
|
|
| 610 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 611 |
]
|
| 612 |
|
|
|
|
| 621 |
}
|
| 622 |
method_status = method_labels.get(state.method, "🔎 Tìm kiếm: Dense")
|
| 623 |
enhance_status = "🧠 Tăng cường truy vấn (Đang tắt)" if not state.is_enhance_query else "🧠 Tăng cường truy vấn (Đang bật)"
|
|
|
|
| 624 |
|
| 625 |
return [
|
| 626 |
cl.Action(name="toggle_product_search", value="toggle_search", label=search_status, payload={"action": "toggle_search"}),
|
| 627 |
cl.Action(name="change_search_method", value="change_method", label="🔎 Đổi phương thức tìm kiếm", payload={"action": "change_method"}),
|
| 628 |
cl.Action(name="toggle_enhance_query", value="toggle_enhance", label=enhance_status, payload={"action": "toggle_enhance"}),
|
|
|
|
| 629 |
cl.Action(name="change_model", value="model", label="🔄 Đổi model", payload={"action": "model"}),
|
| 630 |
]
|
| 631 |
|
|
|
|
| 826 |
await UIService.send_message_with_buttons(status_message, app_state, author="assistant")
|
| 827 |
|
| 828 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
@cl.action_callback("toggle_enhance_query")
|
| 830 |
async def on_toggle_enhance_query(action):
|
| 831 |
"""Handle toggle enhance query action"""
|