blesspearl commited on
Commit
1a282bd
·
verified ·
1 Parent(s): 87866a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
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
- You are a Groq advisor what you are to do is to collect user prompts and with the available sql tables availables tailor the question to partain to the data
311
- The tables desctiptions provided below will be what you'd need to look at in order to sanitize the user's prompt.
312
- {table_description}
313
- Here are some organization tips for your queries.
314
- * When an id is requested but not explicitely defined make sure you look at the table above and reference a proper id which will be then proper
315
- * An example includes "get the amount of the purchase with the id 5" sample_response: "get the purchase with the purchase_id 5"
316
- * In the case of numeric or quantifiable attributes such "get the top 3 purchases" sample_response: "get the 3 purchases with the highest amount"
317
- * Ensure that you do not query a table that does not exist
318
-
319
- Question:
320
- --------
321
- {user_question}
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)