Spaces:
Sleeping
Sleeping
Paladugula Siva Satyanarayana commited on
Commit ·
4e3a973
1
Parent(s): d98430d
Temp folder
Browse files
backend/app/services/utility.py
CHANGED
|
@@ -5,6 +5,7 @@ from langchain_openai import ChatOpenAI
|
|
| 5 |
import sqlparse
|
| 6 |
import re
|
| 7 |
import os
|
|
|
|
| 8 |
class UtilityClass:
|
| 9 |
"""
|
| 10 |
Classifies user input as 'sql' (SQL/data context) or 'chat' (normal conversation) using an LLM.
|
|
@@ -113,8 +114,9 @@ class UtilityClass:
|
|
| 113 |
:param local_db_path: Local path to save the file. If None, saves to './downloaded_db.db'.
|
| 114 |
:return: Local file path of the downloaded DB.
|
| 115 |
"""
|
| 116 |
-
if local_db_path is None:
|
| 117 |
-
|
|
|
|
| 118 |
dbx = dropbox.Dropbox(dropbox_token)
|
| 119 |
with open(local_db_path, 'wb') as f:
|
| 120 |
metadata, res = dbx.files_download(path=dropbox_db_path)
|
|
|
|
| 5 |
import sqlparse
|
| 6 |
import re
|
| 7 |
import os
|
| 8 |
+
import tempfile
|
| 9 |
class UtilityClass:
|
| 10 |
"""
|
| 11 |
Classifies user input as 'sql' (SQL/data context) or 'chat' (normal conversation) using an LLM.
|
|
|
|
| 114 |
:param local_db_path: Local path to save the file. If None, saves to './downloaded_db.db'.
|
| 115 |
:return: Local file path of the downloaded DB.
|
| 116 |
"""
|
| 117 |
+
if local_db_path is None:
|
| 118 |
+
temp_dir = tempfile.gettempdir()
|
| 119 |
+
local_db_path = os.path.join(temp_dir, "downloaded_db.db")
|
| 120 |
dbx = dropbox.Dropbox(dropbox_token)
|
| 121 |
with open(local_db_path, 'wb') as f:
|
| 122 |
metadata, res = dbx.files_download(path=dropbox_db_path)
|