File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1+ import json
2+ import time
13import traceback
24from typing import List
35
68from apps .ai_model .embedding import EmbeddingModelCache
79from common .core .config import settings
810from common .core .deps import SessionDep
11+ from common .utils .utils import SQLBotLogUtil
912from ..models .datasource import CoreTable , CoreField
1013
1114
@@ -33,6 +36,7 @@ def run_fill_empty_table_embedding(session: SessionDep):
3336
3437 stmt = select (CoreTable .id ).where (and_ (CoreTable .embedding .is_ (None )))
3538 results = session .execute (stmt ).scalars ().all ()
39+ SQLBotLogUtil .info (json .dumps (results ))
3640
3741 save_table_embedding (session , results )
3842
@@ -77,7 +81,12 @@ def save_table_embedding(session: SessionDep, ids: List[int]):
7781
7882 model = EmbeddingModelCache .get_model ()
7983
84+ SQLBotLogUtil .info (json .dumps (table_schema ))
85+ SQLBotLogUtil .info ('start table embedding' )
86+ start_time = time .time ()
8087 results = model .embed_documents (table_schema )
88+ end_time = time .time ()
89+ SQLBotLogUtil .info ('table embedding finished in:' + str (end_time - start_time ) + 'seconds' )
8190
8291 for index in range (len (results )):
8392 item = results [index ]
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def calc_table_embedding(tables: list[dict], question: str):
5656 # results = model.embed_documents(text)
5757 # end_time = time.time()
5858 # SQLBotLogUtil.info(str(end_time - start_time))
59- results = [item .get ('embedding' ) for item in _list ]
59+ results = [item .get ('embedding' ) if item . get ( 'embedding' ) else ' ' for item in _list ]
6060
6161 q_embedding = model .embed_query (question )
6262 for index in range (len (results )):
You can’t perform that action at this time.
0 commit comments