@@ -34,6 +34,7 @@ def _build_eval_script(self, query, query_embedding):
34
34
null, {{'scoreMethod': 'score-bm25'}}
35
35
)
36
36
.limit(100)
37
+ .bind(op.as('transcript', op.xpath('doc', '/transcript')))
37
38
.joinInner(
38
39
op.fromView('example','events', '', op.fragmentIdCol('vectorsDocId')),
39
40
op.on(
@@ -45,6 +46,7 @@ def _build_eval_script(self, query, query_embedding):
45
46
op.vec.vector(op.col('embedding')),
46
47
op.vec.vector(vec.vector({}))
47
48
)))
49
+ .select(['uri', 'transcript', 'similarity'])
48
50
.orderBy(op.desc(op.col('similarity')))
49
51
.limit(10)
50
52
.result()
@@ -56,9 +58,10 @@ def _build_eval_script(self, query, query_embedding):
56
58
def _get_relevant_documents (self , query : str ) -> List [Document ]:
57
59
query_embedding = self .embedding_generator .embed_query (query )
58
60
eval_script = self ._build_eval_script (query , query_embedding )
59
- results = self .client .eval (javascript = eval_script )
61
+ optic_rows = self .client .eval (javascript = eval_script )
62
+ print (optic_rows [1 ].keys ())
60
63
61
- print (f"Count of MarkLogic documents sent to the LLM: { len (results )} " )
62
- for result in results :
63
- print (f"URI: { result ['uri' ]} " )
64
- return map (lambda doc : Document (page_content = doc [ "text " ]), results )
64
+ print (f"Count of MarkLogic chunks sent to the LLM: { len (optic_rows )} " )
65
+ for optic_row in optic_rows :
66
+ print (f"URI: { optic_row ['uri' ]} " )
67
+ return map (lambda optic_row : Document (page_content = optic_row [ "transcript " ]), optic_rows )
0 commit comments