Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -307,20 +307,34 @@ def upload_file(files) -> List[str]:
|
|
307 |
|
308 |
def user_prompt_sanitization(user_prompt:str)->str:
|
309 |
guide = """
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
formatted_guide = guide.format(table_description=table_description,user_question=user_prompt)
|
325 |
api_key:str=userdata.get("GROQ_API_KEY")
|
326 |
client = groq.Groq(api_key=api_key)
|
|
|
307 |
|
308 |
def user_prompt_sanitization(user_prompt:str)->str:
|
309 |
guide = """
|
310 |
+
You are a Groq advisor. Your task is to collect user prompts and, using the available SQL tables, tailor the questions to the data. Use the table descriptions below to sanitize the user's prompt.
|
311 |
+
|
312 |
+
**Table Descriptions:**
|
313 |
+
{table_description}
|
314 |
+
|
315 |
+
**Organization Tips for Queries:**
|
316 |
+
- When an ID is requested but not explicitly defined, reference a proper ID from the table.
|
317 |
+
- Example: User prompt: "Get the amount of the purchase with the id 5"
|
318 |
+
- Response: "Get the purchase with the purchase_id 5"
|
319 |
+
- Example: User prompt: "Find the review for product 3"
|
320 |
+
- Response: "Find the review with the product_id 3"
|
321 |
+
- Example: User prompt: "Show details for user 7"
|
322 |
+
- Response: "Show details for the user with the user_id 7"
|
323 |
+
- For numeric or quantifiable attributes:
|
324 |
+
- Example: User prompt: "Get the top 3 purchases"
|
325 |
+
- Response: "Get the 3 purchases with the highest amount"
|
326 |
+
- Example: User prompt: "Show the 5 most recent orders"
|
327 |
+
- Response: "Show the 5 orders with the most recent created_at date"
|
328 |
+
- Example: User prompt: "List the top 10 rated products"
|
329 |
+
- Response: "List the 10 products with the highest rating"
|
330 |
+
- Ensure you do not query a table that does not exist.
|
331 |
+
|
332 |
+
**Question:**
|
333 |
+
--------
|
334 |
+
{user_question}
|
335 |
+
--------
|
336 |
+
"""
|
337 |
+
|
338 |
formatted_guide = guide.format(table_description=table_description,user_question=user_prompt)
|
339 |
api_key:str=userdata.get("GROQ_API_KEY")
|
340 |
client = groq.Groq(api_key=api_key)
|