Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -100,7 +100,7 @@ def get_summarization(client:groq.Groq,
|
|
100 |
'''.format(user_question = use_question, df = df)
|
101 |
return chat_with_groq(client,prompt,model,None)
|
102 |
|
103 |
-
|
104 |
import re
|
105 |
from datetime import datetime
|
106 |
import numpy as np
|
@@ -307,15 +307,15 @@ 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}
|
@@ -358,6 +358,8 @@ def queryModel(user_prompt:str,model:str = "llama3-70b-8192",api_key:str=userdat
|
|
358 |
)]
|
359 |
|
360 |
fotmatted_sql_query = sqlparse.format(sql_query, reindent=True, keyword_case='upper')
|
|
|
|
|
361 |
query_n_results = "SQL Query: " + fotmatted_sql_query + "\n\n" + results_df.to_markdown()
|
362 |
summarization = get_summarization(client,user_prompt,results_df,model)
|
363 |
query_n_results += "\n\n" + summarization
|
@@ -396,5 +398,3 @@ with gr.Blocks() as demo:
|
|
396 |
|
397 |
|
398 |
demo.launch(share=True)
|
399 |
-
|
400 |
-
|
|
|
100 |
'''.format(user_question = use_question, df = df)
|
101 |
return chat_with_groq(client,prompt,model,None)
|
102 |
|
103 |
+
|
104 |
import re
|
105 |
from datetime import datetime
|
106 |
import numpy as np
|
|
|
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}
|
|
|
358 |
)]
|
359 |
|
360 |
fotmatted_sql_query = sqlparse.format(sql_query, reindent=True, keyword_case='upper')
|
361 |
+
# print(f"SQL Query: {fotmatted_sql_query}")
|
362 |
+
# print(results_df.to_markdown())
|
363 |
query_n_results = "SQL Query: " + fotmatted_sql_query + "\n\n" + results_df.to_markdown()
|
364 |
summarization = get_summarization(client,user_prompt,results_df,model)
|
365 |
query_n_results += "\n\n" + summarization
|
|
|
398 |
|
399 |
|
400 |
demo.launch(share=True)
|
|
|
|