chronos / app.py
Manoj Kumar
updated question structure
39179ce
raw
history blame
888 Bytes
import json
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Define the schema for the database
db_schema = {
"products": ["product_id", "name", "price", "description", "type"],
"orders": ["order_id", "product_id", "quantity", "order_date"],
"customers": ["customer_id", "name", "email", "phone_number"]
}
def dummy_function(schema_description, user_question):
print(user_question)
# Schema as a context for the model
schema_description = json.dumps(db_schema, indent=4)
# Example interactive questions
print("Ask a question about the database schema.")
while True:
user_question = input("Question: ")
if user_question.lower() in ["exit", "quit"]:
print("Exiting...")
break
# Generate SQL query
sql_query = dummy_function(schema_description, user_question)
print(f"Generated SQL Query:\n{sql_query}\n")