barathm111 commited on
Commit
00295a8
·
verified ·
1 Parent(s): fd7f44f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -69,6 +69,9 @@ def home():
69
  @app.post("/generate")
70
  def generate(request: QueryRequest):
71
  try:
 
 
 
72
  text = request.text
73
 
74
  # Fetch the database schema
@@ -82,21 +85,7 @@ def generate(request: QueryRequest):
82
 
83
  {schema_str}
84
 
85
- When creating your answers, consider the following:
86
-
87
- 1. If a query involves a column or value that is not present in the provided database schema, correct it and mention the correction in the summary. If a column or value is missing, provide an explanation of the issue and adjust the query accordingly.
88
- 2. If there is a spelling mistake in the column name or value, attempt to correct it by matching the closest possible column or value from the schema. Mention this correction in the summary to clarify any changes made.
89
- 3. Ensure that the correct columns and values are used based on the schema provided. Verify the query against the schema to confirm accuracy.
90
- 4. Include column name headers in the query results for clarity.
91
-
92
- Always provide your answer in the JSON format below:
93
-
94
- {{ "summary": "your-summary", "query": "your-query" }}
95
-
96
- Output ONLY JSON.
97
- In the preceding JSON response, substitute "your-query" with a MariaDB query to retrieve the requested data.
98
- In the preceding JSON response, substitute "your-summary" with a summary of the query and any corrections or clarifications made.
99
- Always include all columns in the table.
100
  """
101
 
102
  prompt = f"{system_message}\n\nUser request:\n\n{text}\n\nSQL query:"
@@ -113,6 +102,7 @@ def generate(request: QueryRequest):
113
  except Exception as e:
114
  raise HTTPException(status_code=500, detail=str(e))
115
 
 
116
  if __name__ == "__main__":
117
  import uvicorn
118
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
69
  @app.post("/generate")
70
  def generate(request: QueryRequest):
71
  try:
72
+ # Log the incoming request text for debugging
73
+ print(f"Received request with text: {request.text}")
74
+
75
  text = request.text
76
 
77
  # Fetch the database schema
 
85
 
86
  {schema_str}
87
 
88
+ [Additional instructions as in your original code]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  """
90
 
91
  prompt = f"{system_message}\n\nUser request:\n\n{text}\n\nSQL query:"
 
102
  except Exception as e:
103
  raise HTTPException(status_code=500, detail=str(e))
104
 
105
+
106
  if __name__ == "__main__":
107
  import uvicorn
108
  uvicorn.run(app, host="0.0.0.0", port=7860)