Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -219,6 +219,9 @@ def create_agent_app(db_path: str):
|
|
| 219 |
# the global agent_app using the default DATABASE_URI. It returns the Flask app.
|
| 220 |
###############################################################################
|
| 221 |
# --- Application Factory ---
|
|
|
|
|
|
|
|
|
|
| 222 |
def create_app():
|
| 223 |
# Option: configure static files from uploads folder as well.
|
| 224 |
flask_app = Flask(__name__, static_url_path='/uploads', static_folder='uploads')
|
|
@@ -244,6 +247,7 @@ def create_app():
|
|
| 244 |
return
|
| 245 |
try:
|
| 246 |
query = {"messages": [("user", prompt)]}
|
|
|
|
| 247 |
result = agent_app.invoke(query)
|
| 248 |
try:
|
| 249 |
result = result["messages"][-1].tool_calls[0]["args"]["final_answer"]
|
|
@@ -294,9 +298,10 @@ def create_app():
|
|
| 294 |
file.save(db_path)
|
| 295 |
|
| 296 |
# Reinitialize the agent_app with the new database file
|
|
|
|
| 297 |
abs_file_path = os.path.abspath(db_path)
|
| 298 |
-
global agent_app
|
| 299 |
-
agent_app = create_agent_app(abs_file_path)
|
| 300 |
|
| 301 |
print(f"[INFO_PRINT]: Database file '{file.filename}' uploaded and loaded.")
|
| 302 |
socketio.emit("log", {"message": f"[INFO]: Database file '{file.filename}' uploaded and loaded."})
|
|
|
|
| 219 |
# the global agent_app using the default DATABASE_URI. It returns the Flask app.
|
| 220 |
###############################################################################
|
| 221 |
# --- Application Factory ---
|
| 222 |
+
abs_file_path = None
|
| 223 |
+
agent_app= None
|
| 224 |
+
|
| 225 |
def create_app():
|
| 226 |
# Option: configure static files from uploads folder as well.
|
| 227 |
flask_app = Flask(__name__, static_url_path='/uploads', static_folder='uploads')
|
|
|
|
| 247 |
return
|
| 248 |
try:
|
| 249 |
query = {"messages": [("user", prompt)]}
|
| 250 |
+
agent_app = create_agent_app(abs_file_path)
|
| 251 |
result = agent_app.invoke(query)
|
| 252 |
try:
|
| 253 |
result = result["messages"][-1].tool_calls[0]["args"]["final_answer"]
|
|
|
|
| 298 |
file.save(db_path)
|
| 299 |
|
| 300 |
# Reinitialize the agent_app with the new database file
|
| 301 |
+
global abs_file_path
|
| 302 |
abs_file_path = os.path.abspath(db_path)
|
| 303 |
+
#global agent_app
|
| 304 |
+
#agent_app = create_agent_app(abs_file_path)
|
| 305 |
|
| 306 |
print(f"[INFO_PRINT]: Database file '{file.filename}' uploaded and loaded.")
|
| 307 |
socketio.emit("log", {"message": f"[INFO]: Database file '{file.filename}' uploaded and loaded."})
|