Spaces:
Running
Running
Update app.py
Browse files
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 |
-
#
|
| 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
|
| 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=
|
| 94 |
|
| 95 |
-
# Run
|
| 96 |
-
threading.Thread(target=
|
|
|
|
| 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()
|