Skip to content

Commit 07914a6

Browse files
committed
fixed command_history intiialization to get the rifht tables intiailziied when start_flask_server runs on npc serve.
1 parent b37d506 commit 07914a6

File tree

3 files changed

+7
-36
lines changed

3 files changed

+7
-36
lines changed

npcpy/memory/command_history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def save_jinx_execution(
443443
try:
444444
return self._execute(sql, params) # Return lastrowid if available
445445
except Exception as e:
446-
print(f"CRITICAL: Failed to save jinx execution via _execute: {e}")
446+
print(f"CRITICAL: Failed to save tool execution via _execute: {e}")
447447
return None
448448

449449
def get_full_message_content(self, message_id):
@@ -823,5 +823,5 @@ def get_available_tables(db_path: str) -> str:
823823
824824
from npcpy.memory.command_history import CommandHistory
825825
command_history = CommandHistory()
826-
command_history.create_jinx_call_table()
826+
command_history.create_tool_call_table()
827827
'''

npcpy/modes/serve.py

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,44 +1460,14 @@ def health_check():
14601460
def start_flask_server(
14611461
port=5337,
14621462
cors_origins=None,
1463+
static_files=None
14631464
):
14641465
try:
14651466
# Ensure the database tables exist
1466-
conn = get_db_connection()
1467-
try:
1468-
cursor = conn.cursor()
14691467

1470-
# Create tables if they don't exist
1471-
cursor.execute(
1472-
"""
1473-
CREATE TABLE IF NOT EXISTS command_history (
1474-
id INTEGER PRIMARY KEY AUTOINCREMENT,
1475-
timestamp TEXT,
1476-
command TEXT,
1477-
tags TEXT,
1478-
response TEXT,
1479-
directory TEXT,
1480-
conversation_id TEXT
1481-
)
1482-
"""
1483-
)
14841468

1485-
cursor.execute(
1486-
"""
1487-
CREATE TABLE IF NOT EXISTS conversation_history (
1488-
id INTEGER PRIMARY KEY AUTOINCREMENT,
1489-
timestamp TEXT,
1490-
role TEXT,
1491-
content TEXT,
1492-
conversation_id TEXT,
1493-
directory_path TEXT
1494-
)
1495-
"""
1496-
)
1469+
command_history = CommandHistory(db_path)
14971470

1498-
conn.commit()
1499-
finally:
1500-
conn.close()
15011471

15021472
# Only apply CORS if origins are specified
15031473
if cors_origins:
@@ -1509,11 +1479,12 @@ def start_flask_server(
15091479
allow_headers=["Content-Type", "Authorization"],
15101480
methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
15111481
supports_credentials=True,
1482+
15121483
)
15131484

15141485
# Run the Flask app on all interfaces
15151486
print(f"Starting Flask server on http://0.0.0.0:{port}")
1516-
app.run(host="0.0.0.0", port=port, debug=True)
1487+
app.run(host="0.0.0.0", port=port, debug=True, static_files=static_files)
15171488
except Exception as e:
15181489
print(f"Error starting server: {str(e)}")
15191490

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def package_files(directory):
8383

8484
setup(
8585
name="npcpy",
86-
version="1.0.4",
86+
version="1.0.5",
8787
packages=find_packages(exclude=["tests*"]),
8888
install_requires=base_requirements, # Only install base requirements by default
8989
extras_require={

0 commit comments

Comments
 (0)