Skip to content

Commit

Permalink
Update: app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
souvik03-136 committed Jul 17, 2024
1 parent 55346a3 commit 8e50f5c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .idea/book-keeping-ai.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ def extract_entities():
"ItemName": ItemName,
"ItemQuantity": ItemQuantity
})
def convert_to_dml(input_text):
parsed_data = re.match(r'(.*)\s+less than\s+(\d+)\s+rs', input_text, re.IGNORECASE)
if parsed_data:
item = parsed_data.group(1).strip()
price = int(parsed_data.group(2))
return f"SELECT {item} FROM Products WHERE Price < {price};"
else:
return "Invalid input format. Please provide something like 'apples less than 50 rs'."


@app.route('/convert_to_dml', methods=['POST'])
def convert_to_dml_endpoint():
data = request.json
input_text = data.get('text', '')

dml_code = convert_to_dml(input_text)

return jsonify({
"input_text": input_text,
"dml_code": dml_code
})

if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True)

0 comments on commit 8e50f5c

Please sign in to comment.