fix bug str-get
Browse files- app/agent/reasoning.py +14 -8
- tests/react_comparison_report.md +14 -22
app/agent/reasoning.py
CHANGED
|
@@ -146,23 +146,29 @@ def build_reasoning_prompt(
|
|
| 146 |
steps_text += f" ⚠️ ĐÃ CÓ TỌA ĐỘ - KHÔNG CẦN GỌI LẠI get_location_coordinates\n"
|
| 147 |
|
| 148 |
elif action == "find_nearby_places" and observation:
|
| 149 |
-
if isinstance(observation, list):
|
| 150 |
steps_text += f" ✅ Tìm được {len(observation)} địa điểm:\n"
|
| 151 |
for i, place in enumerate(observation[:5], 1):
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
| 156 |
if len(observation) > 5:
|
| 157 |
steps_text += f" ... và {len(observation) - 5} địa điểm khác\n"
|
| 158 |
steps_text += f" ⚠️ ĐÃ CÓ DANH SÁCH - KHÔNG CẦN GỌI LẠI find_nearby_places\n"
|
| 159 |
|
| 160 |
elif action == "retrieve_context_text" and observation:
|
| 161 |
-
if isinstance(observation, list):
|
| 162 |
steps_text += f" ✅ Tìm được {len(observation)} kết quả text:\n"
|
| 163 |
for i, item in enumerate(observation[:3], 1):
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
| 166 |
steps_text += f" ⚠️ ĐÃ CÓ KẾT QUẢ TEXT - KHÔNG CẦN GỌI LẠI retrieve_context_text\n"
|
| 167 |
|
| 168 |
elif observation:
|
|
|
|
| 146 |
steps_text += f" ⚠️ ĐÃ CÓ TỌA ĐỘ - KHÔNG CẦN GỌI LẠI get_location_coordinates\n"
|
| 147 |
|
| 148 |
elif action == "find_nearby_places" and observation:
|
| 149 |
+
if isinstance(observation, list) and len(observation) > 0:
|
| 150 |
steps_text += f" ✅ Tìm được {len(observation)} địa điểm:\n"
|
| 151 |
for i, place in enumerate(observation[:5], 1):
|
| 152 |
+
if isinstance(place, dict):
|
| 153 |
+
name = place.get('name', 'Unknown')
|
| 154 |
+
dist = place.get('distance_km', 'N/A')
|
| 155 |
+
rating = place.get('rating', 'N/A')
|
| 156 |
+
steps_text += f" {i}. {name} ({dist}km, ⭐{rating})\n"
|
| 157 |
+
else:
|
| 158 |
+
steps_text += f" {i}. {place}\n"
|
| 159 |
if len(observation) > 5:
|
| 160 |
steps_text += f" ... và {len(observation) - 5} địa điểm khác\n"
|
| 161 |
steps_text += f" ⚠️ ĐÃ CÓ DANH SÁCH - KHÔNG CẦN GỌI LẠI find_nearby_places\n"
|
| 162 |
|
| 163 |
elif action == "retrieve_context_text" and observation:
|
| 164 |
+
if isinstance(observation, list) and len(observation) > 0:
|
| 165 |
steps_text += f" ✅ Tìm được {len(observation)} kết quả text:\n"
|
| 166 |
for i, item in enumerate(observation[:3], 1):
|
| 167 |
+
if isinstance(item, dict):
|
| 168 |
+
name = item.get('name', 'Unknown')
|
| 169 |
+
steps_text += f" {i}. {name}\n"
|
| 170 |
+
else:
|
| 171 |
+
steps_text += f" {i}. {item}\n"
|
| 172 |
steps_text += f" ⚠️ ĐÃ CÓ KẾT QUẢ TEXT - KHÔNG CẦN GỌI LẠI retrieve_context_text\n"
|
| 173 |
|
| 174 |
elif observation:
|
tests/react_comparison_report.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# LocalMate Agent Test Report
|
| 2 |
|
| 3 |
-
**Generated:** 2025-12-18
|
| 4 |
|
| 5 |
## Summary
|
| 6 |
|
|
@@ -8,7 +8,7 @@
|
|
| 8 |
|--------|-------------|------------|
|
| 9 |
| Total Tests | 1 | 1 |
|
| 10 |
| Success | 1 | 1 |
|
| 11 |
-
| Avg Duration |
|
| 12 |
|
| 13 |
---
|
| 14 |
|
|
@@ -21,7 +21,7 @@
|
|
| 21 |
#### Single Mode
|
| 22 |
|
| 23 |
- **Status:** ✅ Success
|
| 24 |
-
- **Duration:**
|
| 25 |
- **Tools Used:** find_nearby_places
|
| 26 |
|
| 27 |
**Workflow:**
|
|
@@ -35,37 +35,29 @@
|
|
| 35 |
Tool: `None` | Results: 0
|
| 36 |
|
| 37 |
**Response Preview:**
|
| 38 |
-
> Chào bạn! Dựa trên
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
#### ReAct Mode
|
| 43 |
|
| 44 |
- **Status:** ✅ Success
|
| 45 |
-
- **Duration:**
|
| 46 |
- **Tools Used:** get_location_coordinates, find_nearby_places
|
| 47 |
-
- **Steps:**
|
| 48 |
- **Intent Detected:** react_multi_step
|
| 49 |
|
| 50 |
**Workflow Steps:**
|
| 51 |
-
- Step 1:
|
| 52 |
Tool: `get_location_coordinates` | Results: 0
|
| 53 |
-
- Step 2:
|
| 54 |
Tool: `find_nearby_places` | Results: 5
|
| 55 |
-
- Step 3: Để giải quyết bài toán này, tôi sẽ phân tích các t...
|
| 56 |
-
Tool: `get_location_coordinates` | Results: 0
|
| 57 |
-
- Step 4: Tôi đã có tọa độ của bãi biển Mỹ Khê và đã tìm đượ...
|
| 58 |
-
Tool: `get_location_coordinates` | Results: 0
|
| 59 |
-
- Step 5: Tôi đã có tọa độ của bãi biển Mỹ Khê và đã tìm đượ...
|
| 60 |
-
Tool: `None` | Results: 0
|
| 61 |
|
| 62 |
**Response Preview:**
|
| 63 |
-
>
|
| 64 |
-
|
| 65 |
-
🍽️ **Top 3 nhà hàng gần biển Mỹ Khê**
|
| 66 |
-
|
| 67 |
-
**1. Be Man Restaurant** ⭐3.7 (0.75 km)
|
| 68 |
-
- *Nhà ...
|
| 69 |
|
| 70 |
---
|
| 71 |
|
|
@@ -75,7 +67,7 @@
|
|
| 75 |
|
| 76 |
| Test | Single Mode Tools | ReAct Mode Tools | ReAct Steps |
|
| 77 |
|------|-------------------|------------------|-------------|
|
| 78 |
-
| 2 | find_nearby_places | get_location_coordinates, find_nearby_places |
|
| 79 |
|
| 80 |
|
| 81 |
### Key Observations
|
|
|
|
| 1 |
# LocalMate Agent Test Report
|
| 2 |
|
| 3 |
+
**Generated:** 2025-12-18 01:06:05
|
| 4 |
|
| 5 |
## Summary
|
| 6 |
|
|
|
|
| 8 |
|--------|-------------|------------|
|
| 9 |
| Total Tests | 1 | 1 |
|
| 10 |
| Success | 1 | 1 |
|
| 11 |
+
| Avg Duration | 31219ms | 10765ms |
|
| 12 |
|
| 13 |
---
|
| 14 |
|
|
|
|
| 21 |
#### Single Mode
|
| 22 |
|
| 23 |
- **Status:** ✅ Success
|
| 24 |
+
- **Duration:** 31219ms
|
| 25 |
- **Tools Used:** find_nearby_places
|
| 26 |
|
| 27 |
**Workflow:**
|
|
|
|
| 35 |
Tool: `None` | Results: 0
|
| 36 |
|
| 37 |
**Response Preview:**
|
| 38 |
+
> Chào bạn! Dựa trên vị trí gần bãi biển Mỹ Khê, mình tìm được một số nhà hàng rất hay cho bạn đây:
|
| 39 |
|
| 40 |
+
**Top nhà hàng gần biển Mỹ Khê:**
|
| 41 |
+
|
| 42 |
+
1. **Cabanon Palace** (Nhà hàng Pháp)
|
| 43 |
+
* *Khoảng cách:* Chỉ ...
|
| 44 |
|
| 45 |
#### ReAct Mode
|
| 46 |
|
| 47 |
- **Status:** ✅ Success
|
| 48 |
+
- **Duration:** 10765ms
|
| 49 |
- **Tools Used:** get_location_coordinates, find_nearby_places
|
| 50 |
+
- **Steps:** 2
|
| 51 |
- **Intent Detected:** react_multi_step
|
| 52 |
|
| 53 |
**Workflow Steps:**
|
| 54 |
+
- Step 1: Để tìm nhà hàng gần bãi biển Mỹ Khê, trước tiên cầ...
|
| 55 |
Tool: `get_location_coordinates` | Results: 0
|
| 56 |
+
- Step 2: Đã có tọa độ của bãi biển Mỹ Khê. Bây giờ cần tìm ...
|
| 57 |
Tool: `find_nearby_places` | Results: 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
**Response Preview:**
|
| 60 |
+
> Xin lỗi, đã xảy ra lỗi: 'str' object has no attribute 'get'...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
---
|
| 63 |
|
|
|
|
| 67 |
|
| 68 |
| Test | Single Mode Tools | ReAct Mode Tools | ReAct Steps |
|
| 69 |
|------|-------------------|------------------|-------------|
|
| 70 |
+
| 2 | find_nearby_places | get_location_coordinates, find_nearby_places | 2 |
|
| 71 |
|
| 72 |
|
| 73 |
### Key Observations
|