This repository was archived by the owner on Jun 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 9
9
10
10
from codegate .codegate_logging import LogFormat , LogLevel , setup_logging
11
11
from codegate .config import Config , ConfigurationError
12
+ from codegate .db .connection import init_db_sync
12
13
from codegate .server import init_app
13
14
14
15
@@ -164,6 +165,7 @@ def serve(
164
165
},
165
166
)
166
167
168
+ init_db_sync ()
167
169
app = init_app ()
168
170
169
171
import uvicorn
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ def __init__(self, sqlite_path: Optional[str] = None):
35
35
}
36
36
self ._async_db_engine = create_async_engine (** engine_dict )
37
37
self ._db_engine = create_engine (** engine_dict )
38
-
39
38
if not self .does_db_exist ():
40
39
logger .info (f"Database does not exist at { self ._db_path } . Creating.." )
41
40
asyncio .run (self .init_db ())
@@ -153,7 +152,6 @@ async def record_output_stream(
153
152
if output_chunks :
154
153
# Record the output chunks
155
154
output_str = json .dumps (output_chunks )
156
- logger .info (f"Recorded chunks: { output_chunks } . Str: { output_str } " )
157
155
await self ._record_output (prompt , output_str )
158
156
159
157
async def record_output_non_stream (
@@ -181,7 +179,12 @@ async def record_output_non_stream(
181
179
182
180
def init_db_sync ():
183
181
"""DB will be initialized in the constructor in case it doesn't exist."""
184
- DbRecorder ()
182
+ db = DbRecorder ()
183
+ # Remove the DB file if exists for the moment to not cause issues at schema change.
184
+ # We can replace this in the future with migrations or something similar.
185
+ if db .does_db_exist ():
186
+ db ._db_path .unlink ()
187
+ asyncio .run (db .init_db ())
185
188
186
189
187
190
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments