Spaces:
Runtime error
Runtime error
Shreyas Gune commited on
Commit ·
f13132c
1
Parent(s): a67dcb7
fixes 6
Browse files- Dockerfile +5 -0
- app.py +3 -1
- nl_to_sql.py +2 -2
Dockerfile
CHANGED
|
@@ -22,6 +22,11 @@ RUN mkdir -p /app/models && \
|
|
| 22 |
|
| 23 |
COPY . .
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
RUN python init_db.py
|
| 26 |
|
| 27 |
EXPOSE 7860
|
|
|
|
| 22 |
|
| 23 |
COPY . .
|
| 24 |
|
| 25 |
+
RUN mkdir -p /app/database
|
| 26 |
+
RUN useradd -m -u 1000 user && chown -R user:user /app
|
| 27 |
+
|
| 28 |
+
USER user
|
| 29 |
+
|
| 30 |
RUN python init_db.py
|
| 31 |
|
| 32 |
EXPOSE 7860
|
app.py
CHANGED
|
@@ -23,9 +23,11 @@ app.secret_key = os.getenv("FLASK_SECRET_KEY")
|
|
| 23 |
# ------------------------------------------------------------------
|
| 24 |
|
| 25 |
DATABASE_URL = os.getenv("DB_URL")
|
| 26 |
-
|
| 27 |
engine = create_engine(DATABASE_URL)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
registry = extract(engine)
|
| 30 |
schema_context = registry.to_prompt_context()
|
| 31 |
|
|
|
|
| 23 |
# ------------------------------------------------------------------
|
| 24 |
|
| 25 |
DATABASE_URL = os.getenv("DB_URL")
|
|
|
|
| 26 |
engine = create_engine(DATABASE_URL)
|
| 27 |
|
| 28 |
+
with engine.connect() as startup_conn:
|
| 29 |
+
startup_conn.execute(text("SELECT 1;"))
|
| 30 |
+
|
| 31 |
registry = extract(engine)
|
| 32 |
schema_context = registry.to_prompt_context()
|
| 33 |
|
nl_to_sql.py
CHANGED
|
@@ -3,14 +3,14 @@ import re
|
|
| 3 |
from llama_cpp import Llama
|
| 4 |
# from datetime import datetime
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
# Load the model directly into memory from the local container path
|
| 9 |
llm = Llama(
|
| 10 |
model_path="/app/models/qwen.gguf",
|
| 11 |
n_ctx=2048,
|
| 12 |
verbose=False,
|
| 13 |
-
n_threads=
|
| 14 |
)
|
| 15 |
|
| 16 |
def clean_llm_sql(sql: str) -> str:
|
|
|
|
| 3 |
from llama_cpp import Llama
|
| 4 |
# from datetime import datetime
|
| 5 |
|
| 6 |
+
LOG_FILE= "app.log"
|
| 7 |
|
| 8 |
# Load the model directly into memory from the local container path
|
| 9 |
llm = Llama(
|
| 10 |
model_path="/app/models/qwen.gguf",
|
| 11 |
n_ctx=2048,
|
| 12 |
verbose=False,
|
| 13 |
+
n_threads=4
|
| 14 |
)
|
| 15 |
|
| 16 |
def clean_llm_sql(sql: str) -> str:
|