gopig5 commited on
Commit
ade3393
·
verified ·
1 Parent(s): 336ecf4
Files changed (1) hide show
  1. app.py +54 -3
app.py CHANGED
@@ -4,7 +4,7 @@ from huggingface_hub import InferenceClient
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
 
10
  def respond(
@@ -45,7 +45,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
48
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
49
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
50
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
51
  gr.Slider(
@@ -60,4 +60,55 @@ demo = gr.ChatInterface(
60
 
61
 
62
  if __name__ == "__main__":
63
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
+ client = InferenceClient("defog/llama-3-sqlcoder-8b")
8
 
9
 
10
  def respond(
 
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
48
+ gr.Textbox(value=prompt, label="System message"),
49
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
50
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
51
  gr.Slider(
 
60
 
61
 
62
  if __name__ == "__main__":
63
+ demo.launch()
64
+
65
+
66
+ prompt = """<|begin_of_text|><|start_header_id|>user<|end_header_id|>
67
+
68
+ Generate a SQL query to answer this question: `{user_question}`
69
+ You are a data analyst and interpreter. You will be given information about a specific dataset, including its columns and their meanings:
70
+ year_month: This column is in year-month format, example 2020-12-01
71
+ paycell_active_customer: This column represents the number of active customers of Paycell
72
+ dcb_active_customer: Represents active customers in mobile payment (dcb)
73
+ paycell_card_active_customer: Represents the number of active users using Paycell card
74
+ app_active_customer: Represents the number of active customers on our app
75
+ dcb_total_volume: Column representing the total volume of mobile payment (dcb) at the mentioned time
76
+ total_card_activation_number: Represents the total activation status of our Paycell card
77
+ physical_card_activation_number: This column represents the activation number of active physical cards in Paycell
78
+ virtual_card_activation_number: This column represents the activation number of virtual cards
79
+ paycell_app_financial_transaction_number: Represents the number of financial transactions made by users using our Paycell app based on their transactions on the relevant date
80
+ active_customer_distribution_only_dcb: Represents the number of mobile payment (dcb) on the relevant date in the active customer distribution
81
+ active_customer_distribution_only_pcard: Represents the number of Paycell card in the active customer distribution on the relevant date
82
+ active_customer_distribution_only_app: Represents the number of app users in the active customer distribution on the relevant date
83
+ active_customer_distribution_dcb_and_pcard: Represents the number of users using both mobile payment (dcb) and Paycell card but not using Paycell app on the relevant date in the active customer distribution
84
+ active_customer_distribution_dcb_and_app: Represents the number of users using both mobile payment (dcb) and Paycell app but not using Paycell card on the relevant date in the active customer distribution
85
+ active_customer_distribution_pcard_and_app: Represents the number of users using both Paycell card and Paycell app but not using mobile payment (dcb) on the relevant date in the active customer distribution
86
+ active_customer_distribution_dcb_pcard_and_app: Represents the number of users using Paycell card, Paycell app, and mobile payment (dcb) on the relevant date in the active customer distribution.
87
+
88
+ If you cannot answer the question with the available database schema, return 'I do not know'
89
+
90
+ Using this information, you will set up the most suitable SQL statements to answer questions related to the data. These SQL statements will later be executed, so they should be error-free, compatible with Sqllite syntax, and accurately respond to the questions asked. Do not express an opinion or try to explain. Return only the SQL statement. Remember your sql statement will run on SQLite so syntax should be correct. Your output should be clear and void like this output 'Here is the SQL statement to answer the question:'. Also, do not add any comment to the SQL statement which you will generate. Only return SQL statement.
91
+
92
+ DDL statements:
93
+ CREATE TABLE "dashboard_ana_sayfa" (
94
+ "year_month" TIMESTAMP,
95
+ "paycell_active_customer" INTEGER,
96
+ "dcb_active_customer" INTEGER,
97
+ "paycell_card_active_customer" INTEGER,
98
+ "app_active_customer" INTEGER,
99
+ "dcb_total_volume" REAL,
100
+ "total_card_activation_count" INTEGER,
101
+ "physical_card_activation_count" INTEGER,
102
+ "virtual_card_activation_count" INTEGER,
103
+ "paycell_app_financial_transaction_count" INTEGER,
104
+ "active_customer_distribution_only_dcb" INTEGER,
105
+ "active_customer_distribution_only_pcard" INTEGER,
106
+ "active_customer_distribution_only_app" INTEGER,
107
+ "active_customer_distribution_dcb_and_pcard" INTEGER,
108
+ "active_customer_distribution_dcb_and_app" INTEGER,
109
+ "active_customer_distribution_pcard_and_app" INTEGER,
110
+ "active_customer_distribution_dcb_pcard_and_app" INTEGER
111
+ )<|eot_id|><|start_header_id|>assistant<|end_header_id|>
112
+
113
+ The following SQL query best answers the question `{user_question}`:
114
+ ```sql"""