saadkhi commited on
Commit
9aaf33f
Β·
verified Β·
1 Parent(s): 5977ece

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -11,7 +11,7 @@ import threading
11
 
12
  torch.set_num_threads(1)
13
 
14
- app = FastAPI()
15
 
16
  BASE_MODEL = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
17
 
@@ -67,7 +67,7 @@ def generate_sql(user_input: str):
67
  return result
68
 
69
  # ─────────────────────────
70
- # FastAPI Routes
71
  # ─────────────────────────
72
  class Query(BaseModel):
73
  text: str
@@ -83,14 +83,14 @@ def generate(query: Query):
83
  # ─────────────────────────
84
  # Gradio UI (for testing)
85
  # ─────────────────────────
86
- def launch_gradio():
87
  demo = gr.Interface(
88
  fn=generate_sql,
89
  inputs=gr.Textbox(lines=3, label="SQL Question"),
90
  outputs=gr.Textbox(lines=6, label="Generated SQL"),
91
- title="SQL Generator Test UI"
92
  )
93
- demo.launch(server_name="0.0.0.0", server_port=7861)
94
 
95
- # Run Gradio in parallel thread
96
- threading.Thread(target=launch_gradio).start()
 
11
 
12
  torch.set_num_threads(1)
13
 
14
+ app = FastAPI(title="SQL Generator API")
15
 
16
  BASE_MODEL = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
17
 
 
67
  return result
68
 
69
  # ─────────────────────────
70
+ # API
71
  # ─────────────────────────
72
  class Query(BaseModel):
73
  text: str
 
83
  # ─────────────────────────
84
  # Gradio UI (for testing)
85
  # ─────────────────────────
86
+ def run_gradio():
87
  demo = gr.Interface(
88
  fn=generate_sql,
89
  inputs=gr.Textbox(lines=3, label="SQL Question"),
90
  outputs=gr.Textbox(lines=6, label="Generated SQL"),
91
+ title="SQL Generator"
92
  )
93
+ demo.launch(server_name="0.0.0.0", server_port=7860)
94
 
95
+ # Run UI in separate thread
96
+ threading.Thread(target=run_gradio).start()