Skip to content

Commit

Permalink
Merge branch 'ankit/refactor' of github.com:video-db/Spielberg into a…
Browse files Browse the repository at this point in the history
…nkit/refactor
  • Loading branch information
ashish-spext committed Oct 23, 2024
2 parents 6930f32 + e86eeb1 commit f93fec7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion backend/spielberg/agents/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(self, sample_id: str, *args, **kwargs) -> AgentResponse:
)
self.output_message.content.append(text_content)
self.output_message.push_update()
text_content.text = "This is the text status of Agent."
text_content.text = "This is the text result of Agent."
text_content.status = MsgStatus.success
text_content.status_message = "Here is your response"
self.output_message.publish()
Expand Down
26 changes: 11 additions & 15 deletions backend/spielberg/db/sqlite/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, db_path: str = "spielberg.db"):
self.conn = sqlite3.connect(self.db_path, check_same_thread=True)
self.conn.row_factory = sqlite3.Row
self.cursor = self.conn.cursor()
print("Connected to SQLite DB...")
logger.info("Connected to SQLite DB...")

def create_session(
self,
Expand Down Expand Up @@ -187,24 +187,20 @@ def delete_session(self, session_id: str) -> bool:
failed_components.append("session")
success = len(failed_components) < 3
return success, failed_components

def _table_exists(self, table_name: str) -> bool:
"""Check if a table exists in the SQLite database."""
self.cursor.execute(
"SELECT name FROM sqlite_master WHERE type='table' AND name=?;",
(table_name,),
)
return self.cursor.fetchone() is not None

def health_check(self) -> bool:
"""Check if the SQLite database is healthy and the necessary tables exist. If not, create them."""
try:
self.cursor.execute("SELECT 1")
if not (
self._table_exists("sessions")
and self._table_exists("conversations")
and self._table_exists("context_messages")
):
query = """
SELECT COUNT(name)
FROM sqlite_master
WHERE type='table'
AND name IN ('sessions', 'conversations', 'context_messages');
"""
self.cursor.execute(query)
table_count = self.cursor.fetchone()[0]
if table_count < 3:
logger.info("Tables not found. Initializing SQLite DB...")
initialize_sqlite(self.db_path)
return True

Expand Down
4 changes: 0 additions & 4 deletions infra/railway.toml

This file was deleted.

21 changes: 21 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
- type: web
name: backend
region: singapore
runtime: docker
plan: free
dockerfilePath: ./backend/Dockerfile
dockerContext: ./backend
envVars:
- key: FLASK_APP
value: spielberg.entrypoint.api.server
- key: SERVER_DEBUG
value: 1

- type: web
name: frontend
region: singapore
runtime: docker
plan: free
dockerfilePath: ./frontend/Dockerfile
dockerContext: ./frontend

0 comments on commit f93fec7

Please sign in to comment.