File size: 888 Bytes
4c735b8
 
 
 
 
 
 
 
 
 
 
 
39179ce
 
4c735b8
 
 
 
 
 
 
 
 
 
 
 
 
39179ce
4c735b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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")