Skip to content

Commit 9047d61

Browse files
authored
Merge pull request #24 from BillFarber/task/jamesUpdates
Get the transcript from the document instead of the view.
2 parents 791b570 + 4707e54 commit 9047d61

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

rag-langchain-python/vector_query_retriever.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def _build_eval_script(self, query, query_embedding):
3434
null, {{'scoreMethod': 'score-bm25'}}
3535
)
3636
.limit(100)
37+
.bind(op.as('transcript', op.xpath('doc', '/transcript')))
3738
.joinInner(
3839
op.fromView('example','events', '', op.fragmentIdCol('vectorsDocId')),
3940
op.on(
@@ -45,6 +46,7 @@ def _build_eval_script(self, query, query_embedding):
4546
op.vec.vector(op.col('embedding')),
4647
op.vec.vector(vec.vector({}))
4748
)))
49+
.select(['uri', 'transcript', 'similarity'])
4850
.orderBy(op.desc(op.col('similarity')))
4951
.limit(10)
5052
.result()
@@ -56,9 +58,10 @@ def _build_eval_script(self, query, query_embedding):
5658
def _get_relevant_documents(self, query: str) -> List[Document]:
5759
query_embedding = self.embedding_generator.embed_query(query)
5860
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())
6063

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)

setup/src/main/ml-schemas-12/tde/events.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
"val": "vec:vector(embedding)",
2121
"dimension": "1536",
2222
"invalidValues": "reject"
23-
},
24-
{
25-
"name": "text",
26-
"scalarType": "string",
27-
"val": "transcript"
2823
}
2924
]
3025
}

0 commit comments

Comments
 (0)