Fix id transmission
Browse files- app_api.py +4 -3
app_api.py
CHANGED
|
@@ -61,7 +61,8 @@ def chat(prompt):
|
|
| 61 |
tool_prompt = (
|
| 62 |
"You are a helpful assistant with access to PrestaShop product tools. "
|
| 63 |
"If the user asks for product details, features, or images, respond with ONLY a JSON object like "
|
| 64 |
-
"{\"tool\": \"get_product_details\", \"product_id\":
|
|
|
|
| 65 |
"Do not add any explanation, just the JSON. "
|
| 66 |
"If no tool is needed, answer the question normally without JSON.\n\n"
|
| 67 |
f"User: {prompt}"
|
|
@@ -70,9 +71,9 @@ def chat(prompt):
|
|
| 70 |
|
| 71 |
# Try to extract JSON from the output
|
| 72 |
try:
|
| 73 |
-
# Look for JSON in the output
|
| 74 |
import re
|
| 75 |
-
json_match = re.search(r'\{[^}]*"tool"[^}]*\}', llm_output)
|
| 76 |
if json_match:
|
| 77 |
json_str = json_match.group()
|
| 78 |
tool_call = json.loads(json_str)
|
|
|
|
| 61 |
tool_prompt = (
|
| 62 |
"You are a helpful assistant with access to PrestaShop product tools. "
|
| 63 |
"If the user asks for product details, features, or images, respond with ONLY a JSON object like "
|
| 64 |
+
"{\"tool\": \"get_product_details\", \"product_id\": ACTUAL_ID_FROM_USER}. "
|
| 65 |
+
"Use the exact product ID that the user mentioned in their question. "
|
| 66 |
"Do not add any explanation, just the JSON. "
|
| 67 |
"If no tool is needed, answer the question normally without JSON.\n\n"
|
| 68 |
f"User: {prompt}"
|
|
|
|
| 71 |
|
| 72 |
# Try to extract JSON from the output
|
| 73 |
try:
|
| 74 |
+
# Look for JSON in the output - improved regex to capture the full JSON object
|
| 75 |
import re
|
| 76 |
+
json_match = re.search(r'\{[^{}]*"tool"[^{}]*"product_id"[^{}]*\}', llm_output)
|
| 77 |
if json_match:
|
| 78 |
json_str = json_match.group()
|
| 79 |
tool_call = json.loads(json_str)
|