Spaces:
Running
Running
Update rag_routerv2.py
Browse files- rag_routerv2.py +24 -20
rag_routerv2.py
CHANGED
@@ -176,26 +176,30 @@ async def query_table(
|
|
176 |
|
177 |
@router.get("/get_tables/{user_id}")
|
178 |
async def get_tables(user_id: str):
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
199 |
|
200 |
|
201 |
@router.delete("/delete_table/{table_id}")
|
|
|
176 |
|
177 |
@router.get("/get_tables/{user_id}")
|
178 |
async def get_tables(user_id: str):
|
179 |
+
db = get_db()
|
180 |
+
tables = db.execute('''
|
181 |
+
SELECT
|
182 |
+
t.table_id,
|
183 |
+
t.table_name,
|
184 |
+
t.created_time as created_at,
|
185 |
+
GROUP_CONCAT(tf.filename) as filenames
|
186 |
+
FROM tables t
|
187 |
+
LEFT JOIN table_files tf ON t.table_id = tf.table_id
|
188 |
+
WHERE t.user_id = ?
|
189 |
+
GROUP BY t.table_id
|
190 |
+
''', (user_id,)).fetchall()
|
191 |
+
|
192 |
+
result = []
|
193 |
+
for table in tables:
|
194 |
+
table_dict = dict(table)
|
195 |
+
result.append({
|
196 |
+
'table_id': table_dict['table_id'],
|
197 |
+
'table_name': table_dict['table_name'],
|
198 |
+
'created_at': table_dict['created_at'],
|
199 |
+
'documents': [filename for filename in table_dict['filenames'].split(',') if filename] if table_dict['filenames'] else []
|
200 |
+
})
|
201 |
+
|
202 |
+
return result
|
203 |
|
204 |
|
205 |
@router.delete("/delete_table/{table_id}")
|